Groups a sequence of two or more query conditions.
int
ade_qrygroup(
ade_id condition_id1,
ade_id condition_id2);
Returns RTNORM or an error code.
condition_id1 | ID of first condition of the group. |
condition_id2 | ID of last condition of the group. |
This function affects the current query.
A query definition consists of a sequence of query conditions. Within such a sequence, you can define subsequences of two or more conditions by grouping them (by enclosing them in parentheses). You can group conditions when you first define the query. See the bggroups and endgroups parameters of ade_qrydefine. Or you can do it later using ade_qrygroup.
When you call ade_qrygroup, the condition you specify as the first condition of the group (condition_id1) must be a predecessor to the one you specify as the last (condition_id2). The function groups the first and the last and any conditions in between.
The following sample defines a location condition which utilizes a buffer fence selection option. Three additional conditions are constructed based on SQL and the resulting query defenition is displayed. Using ade_qrygroup() and the queryIds, (ownerQueryId and tele_UseQueryId) returned by ade_qrydefine(), conditions can be combined to produce a query which retrieves specific poles within a geographic area as displayed.
// Define the location condition. char* pszJoinOperator = ""; // none char* pszBgnCondGrouping = ""; // none char* pszNotOperator = ""; // none char* pszCondType = "Location"; char* pszEndCondGrouping = ""; // none ads_point bufferfencePt1; bufferfencePt1[X] = 499375; bufferfencePt1[Y] = 1451421; ads_point bufferfencePt2; bufferfencePt2[X] = 499383; bufferfencePt2[Y] = 1451502; ads_point bufferfencePt3; bufferfencePt3[X] = 499422; bufferfencePt3[Y] = 1451641; struct resbuf* pLocQueryConditionRb = acutBuildList( RTLB, RTSTR, "Bufferfence", RTSTR, "Inside", RTREAL, 100.0, RTPOINT, bufferfencePt1, RTPOINT, bufferfencePt2, RTPOINT, bufferfencePt3, RTLE, 0 ); ade_id locQueryId = ade_qrydefine( pszJoinOperator, pszBgnCondGrouping, pszNotOperator, pszCondType, pLocQueryConditionRb, pszEndCondGrouping); // Define the first SQL condition. struct resbuf* pSQL_OwnerRb = acutBuildList( RTLB, RTSTR, "Pole", RTSTR, "OWNER = 'ELECTRIC'", RTLE, 0 ); ade_id OwnerQueryId = ade_qrydefine( "AND", "", "", "SQL", pSQL_OwnerRb, ""); // Define a second SQL condition. struct resbuf* pSQLCable_UseRb = acutBuildList( RTLB, RTSTR, "Pole", RTSTR, "CABLE_USE = 'CABLECO'", RTLE, 0 ); ade_id Cable_UseQueryId = ade_qrydefine( "OR", "", "", "SQL", pSQLCable_UseRb, ""); // Define a third SQL condition. struct resbuf* pSQLTele_UseRb = acutBuildList( RTLB, RTSTR, "Pole", RTSTR, "TELE_USE = 'TELCO'", RTLE, 0 ); ade_id Tele_UseQueryId = ade_qrydefine( "OR", "", "", "SQL", pSQLTele_UseRb, "");
The current query definition would appear as the following:
Location; INSIDE BUFFER FENCE
AND SQL:SELECT * FROM Pole WHERE OWNER = 'ELECTRIC'
OR SQL:SELECT * FROM Pole WHERE CABLE_USE = 'CABLECO'
OR SQL:SELECT * FROM Pole WHERE TELE_USE = 'TELCO'
int resultCode = ade_qrygroup( OwnerQueryId, Tele_UseQueryId);
After the call to ade_qrygroup(), the query definition would appear as the following:
Location; INSIDE BUFFER FENCE
AND (SQL:SELECT * FROM Pole WHERE OWNER = 'ELECTRIC'
OR SQL:SELECT * FROM Pole WHERE CABLE_USE = 'CABLECO'
OR SQL:SELECT * FROM Pole WHERE TELE_USE = 'TELCO')
To ungroup queries, use ade_qryungroup.