This documentation is for WSO2 Data Services Server 3.2.2. View documentation for the latest release.
Defining Nested Queries - Data Services Server 3.2.2 - WSO2 Documentation
||
Skip to end of metadata
Go to start of metadata

Nested queries help you to use the result of one query as an input parameter of another, and the queries executed in a nested query works in a transactional manner. The steps below show how to add a nested query to a data service:

  1. First ,add the query with an input parameter, which is evaluated as the result of another query. In this example, thecustomerNumber input mapping is the result of another query.
  2. Next, add the querycustomerOrderSQL, which generates the customerNumber.
  3. Select Add New Output Mapping option of the above query, and define the mappings as follows:
    In this case, the mapping type is query. It allows you to select the query name and define query parameter mapping. As shown below, the query customerNameSQL is invoked with customerNumber parameter, which is a result of customerOrderSQL.

    Invoking the query

  4. In order to test the nested query, add an operation to the querycustomerOrderSQL as follows:
  5. When the operation is invoked, results contain the nested result elementCustomer, which returns from customerNameSQL query.
  6. In the configuration syntax, you can define thecall-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 and call-query/with-param/@column attributes, only one is used in a single call-query/with-param element.

Also see Nested Query Sample for a demonstration of how nested queries work.

  • No labels