Nested queries help you to use the result of one query as an input parameter of another. The steps below show how to add a nested query to a data service:
- First ,add the query with an input parameter, which is evaluated as the result of another query. In this example, the
customerNumber
input mapping is the result of another query. - Next, add the query
customerOrderSQL,
which generates thecustomerNumber
. - Select Add New Output Mapping option of the above query, and define the mappings as follows:
In this case, the mapping type isquery
. It allows you to select the query name and define query parameter mapping. As shown below, the querycustomerNameSQL
is invoked withcustomerNumber
parameter, which is a result ofcustomerOrderSQL
.Invoking the query
- In order to test the nested query, add an operation to the query
customerOrderSQL
as follows: - When the operation is invoked, results contain the nested result element
Customer
, which returns fromcustomerNameSQL
query. - In the configuration syntax, you can define the
call-query
element as a result of a query as follows:Description of the child elements and attributes of the call-query are as follows.
- call-query/@href : Name of the nested query
- call-query/with-param : Define the input parameter to be passed to nested query
- call-query/with-param/@name : name of the parameter as defined in the nested query
- call-query/with-param/@query-param : name of the parameter as returned from this query
- call-query/with-param/@column : name of the parameter as returned from the immediate parent result element
From
call-query/with-param/@query-param
andcall-query/with-param/@column
attributes, only one is used in a singlecall-query/with-param
element.
Also see Nested Query Sample for a demonstration of how nested queries work.