SQL request for single object parameters

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-04 01:29 PM
The following request gives back only the whole column of the parameters names:
"SELECT XX.PARAMETERS.NAME FROM FLAT(OBJECTS, PARAMETERS) AS XX"
GDL object creation: b-prisma.de
- Labels:
-
Data management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-04 08:33 PM
It will give you some additional info that may help.
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac28

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-04 09:27 PM
I was going crazy trying to get this to work ... and it turns out that the ArchiCAD SQL interpretter only allows single quote for text strings... I was using double quotes for half an hour!

The attached is an example that works to display the value of the 'A' parameter for all placed instances of a particular chair:
select flc.parameters.name, flc.parameters.value from flat(objects,parameters) as flc where (library_part_name='Armchair 01 12') and (flc.parameters.variable_name = 'A' )I tried using the parameter value ('value')in the where clause, but it is of type 'gdlvariant' (permitting text, integer, floating point, etc) - and the only way to get a valid comparison is to use a type coercion function ... and I could not find any that were accepted by the interpreter. If you happen to figure that out, please post.
Cheers,
Karl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-04 09:36 PM
laszlonagy wrote:From his example that calls the flattened table 'XX', it is likely that Joachim was working from those pages...
Check the section on SQL on Page 52 in the 04 AC 12 Calculation Guide.pdf file in the Documentation folder within the ArchiCAD folder.
It will give you some additional info that may help.
But, thanks, Laszlo for pointing out this reference! The 5 pages there are an excellent tutorial for the SQL feature which was introduced in ArchiCAD 8.0 with no documentation at that time. I did not realize that something had finally been written up since then...and I see these same pages in the AC 10 and AC 11 Calculation Guide. So, good news!
Cheers,
Karl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-04 10:05 PM
(It is a little odd that the ODBC help, including this syntax, is in a Microsoft Windows CHM format help file, that is not accessible to Mac users - even though the SQL Query window does work on mac. It is only ODBC that is Windows-only.)
Cheers,
Karl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-04 10:14 PM
Yes, I used the Calculation Guide. And as you write it, Karl, I remember the SQL Guide, that I downloaded some years ago.
I still have acess to Windows, so it wil be no problem for me, to read it.
I hope it will help and I will post if I find out news.
Thank You again!
GDL object creation: b-prisma.de

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-04 10:17 PM
Karl wrote:I originally wrote this short introduction for Graphisoft for AC9 and it has not changed since. As stated there, there is a lot more that can be done with SQL than is described in those few pages.laszlonagy wrote:From his example that calls the flattened table 'XX', it is likely that Joachim was working from those pages...
Check the section on SQL on Page 52 in the 04 AC 12 Calculation Guide.pdf file in the Documentation folder within the ArchiCAD folder.
It will give you some additional info that may help.
But, thanks, Laszlo for pointing out this reference! The 5 pages there are an excellent tutorial for the SQL feature which was introduced in ArchiCAD 8.0 with no documentation at that time. I did not realize that something had finally been written up since then...and I see these same pages in the AC 10 and AC 11 Calculation Guide. So, good news!🙂
Cheers,
Karl
But thanks for chiming in Karl, I think you are probably the one who knows the most of SQL in practice.
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac28

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-04 11:04 PM
laszlonagy wrote:I'm glad that they had you do that! (And, sorry I had not noticed it! I was so used to the Calculate Guide getting no improvements, that I stopped looking closely at it!)
I originally wrote this short introduction for Graphisoft for AC9 and it has not changed since.
Thanks!
Karl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-05 12:35 PM
Karl wrote:ODBC manual (odbc.chm) describes GDLVARIANT as totally unconvertable (Graphisoft SQL Language Reference->Data Type Conversion chapter). May be you can use "GDL Helper Object" trick as a workaround.
I tried using the parameter value ('value')in the where clause, but it is of type 'gdlvariant' (permitting text, integer, floating point, etc) - and the only way to get a valid comparison is to use a type coercion function ... and I could not find any that were accepted by the interpreter. If you happen to figure that out, please post.
Create 'SQL_Tst_1' object with 'Tst_1' variable as a parameter. Define this variable with absolutely the same type, as the type of the field you want to search for (pen number in my case). And set it to the value you want to search for. Place the object and execute this instruction:
SELECT *
FROM
flat(objects,parameters) as T_1,
flat(objects,parameters) as T_2
WHERE
(T_1.library_part_name = 'Built-in Elevation Marker')
and
(T_1.parameters.variable_name = 'AC_TextPen_1')
and
(T_2.parameters.variable_name = 'Tst_1')
and
(T_1.parameters.value = T_2.parameters.value)
It is very important to write WHERE part carefully. We have to select rows with the same GDL type of comparable parameters. Otherwise SQL reports a bug.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-05 06:42 PM
Cheers,
Karl