Page 1 of 1

Relational / Hierarchical Select

Posted: Thu 28 Feb 2008 02:57
by KW
Is there an elegant way to do a select on a parent table which then only retrieves its child rows based on what was selected in the parent table?

Basically, I'd like to use the built in feature of startrecord and maxRecords. I'd like to say, give me the first 4k records of this parent table and also retrieve all child tables that belong to the selected 4k records. In this way, you won't fail a contraint check, where as you would possibly if you said just give me the first 4k records in both parent and child tables. Obviously, in a larege database you can't simply say Select all.

Is there a built in way to do this?

Posted: Thu 28 Feb 2008 12:41
by Alexey.mdr
Unfortunately, we do not provide such built-in functionality.

Probably, if the selecting criteria for the parent table is known beforehand you might use this code:

Code: Select all

SELECT * FROM childTable WHERE (FK_id_PT = SELECT id_PT FROM parantTable WHERE (columnName=:paramName));
Additionally, if you are making a master-detail datagrids you might be interested in the following sample:
%Program Files%CoreLab\MyDirect.NET2\Samples\WinForms\