Shape Relate Order By based on parent



I have a question regarding the ADO shape relate command,
I have the following query,

getTreeSQL = " SHAPE {SELECT LINK_ID a,FK_PARENT_ID
b,FK_TREE_ID,FK_TYPE_ID,NAME,LINK,FK_ORDER_TYPE_ID,SORT_INDEX from
TVL_LINK L1 WHERE FK_TREE_ID = " + treeObj.treeID + " AND FK_PARENT_ID
= " + treeObj.RootID + " ORDER BY SORT_INDEX} AS FirstLevel";
getTreeSQL += " APPEND (" ;
getTreeSQL += " (";
getTreeSQL += " SHAPE {select LINK_ID c,FK_PARENT_ID
d,FK_TREE_ID,FK_TYPE_ID,NAME,LINK,FK_ORDER_TYPE_ID,SORT_INDEX from
TVL_LINK L2 WHERE FK_TREE_ID = " + treeObj.treeID + " ORDER BY
SORT_INDEX} " ;
getTreeSQL += " APPEND (" ;
getTreeSQL += " {select LINK_ID,FK_PARENT_ID
e,FK_TREE_ID,FK_TYPE_ID,NAME,LINK,FK_ORDER_TYPE_ID,SORT_INDEX from
TVL_LINK L3 WHERE FK_TREE_ID = " + treeObj.treeID + " ORDER BY
SORT_INDEX} AS ThirdLevel " ;
getTreeSQL += " RELATE c TO e" ;
getTreeSQL += " )" ;
getTreeSQL += " ) AS SecondLevel " ;
getTreeSQL += " RELATE a TO d )";

Instead of order by Sort_index I want to order by name if the
FK_ORDER_TYPE of the parent is equal to 1 and by SORT_INDEX if it is
equal to 2.

when I wrote order by decode(firstlevel.FK_order_type,1,'name', 2,
'sort_index') I got an error that firstlevel.fk_order_type is not a
valid identifier. I want to reference the parent in the child record
set to be able to do it.

Your help is greatly appreciated

.



Relevant Pages

  • Re: Query vs form with child & parent: Deleting rows
    ... If you delete a parent record, and have 5 related tables to that main ... These child records will delete even if you just delete main ... the setup of the query WILL NOT EFFECT this ... So, if we have Customers, and Invoices tables, a left join would give us: ...
    (microsoft.public.access.forms)
  • Re: Deleting duplicate parents and grouping children to single par
    ... You will need to build the action query as a SQL statement to execute. ... To reassign 24 to 18, and then kill 24, this is the basic code: ... duplicate fields and then use a MIN function to identify the first ParentID ... undesirable parent record. ...
    (microsoft.public.access.tablesdbdesign)
  • RE: Parent-Child relations in a dataset
    ... How do I keep pending parent and children in synch? ... that actually exist in the database. ... use those placeholder values for your pending child rows. ... "SELECT SCOPE_IDENTITY" query to retrieve the last identity ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Updating and Retrieving Data
    ... How do I keep pending parent and children in synch? ... that actually exist in the database. ... use those placeholder values for your pending child rows. ... "SELECT SCOPE_IDENTITY" query to retrieve the last identity ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Query vs form with child & parent: Deleting rows
    ... subordinate to that record, that is, all individuals (and sometimes child ... companies) whose Owner field contains the record key of the parent company. ... That second form is fed by this query: ... But I have a child table called "Channel"; ...
    (microsoft.public.access.forms)