This documentation is for WSO2 Data Services Server 3.2.2. View documentation for the latest release.
Page Comparison - Nested Query Sample (v.1 vs v.12) - Data Services Server 3.2.2 - WSO2 Documentation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel3
minLevel3

Introduction

Sometimes, In a data service, sometimes the result of one query may be used as an input parameter for another query. In such situations, we use the nested query feature available in the WSO2 Data Services Server.

...

Table of Contents
maxLevel3
minLevel3

About the sample

The sample data service NestedQuerySample should be deployed using the instructions in Samples Setup section.

Running the sample

The sample service can be run using the TryIt tool, which is bundled with the WSO2 Data Services Server, or a code-generated java client sample as discussed in the Data Services Clients section.

Service description

The service contains the following queries.

...

(NestedQuerySample) contains the following operations:

  • employeesInOffice - The employeesInOfficeSQL query takes in an office code and prints the details of all the employess in that office.
  • listOfficesSQL - Lists listOffices - The listOfficesSQL query lists all the offices in the database. When office information is printed, all the employees that belong to an office are also printed using a nested query, which refers to the employeesInOfficeSQL querythe employeesInOfficeSQL query, which is invoked by the "employeesInOffice" operation.
  • customerNameSQL - Takes The customerNameSQL query takes in the customer number as a parameter and returns the customer name. In the result section of this query, there is no "rowName" defined ; (only an element wrapper). With this option, a separate element will not be created for every record in the result. But However, the record content will be directly added to the outer element. This is best used in a query where , there is only one record to be returned.
  • customerOrdersSQL - Prints customerOrders - The customerOrdersSQL query prints the details of all the orders that are in the database. In the result elements, a nested query which references the the customerNameSQL query  query is used. In this way, the name of the customer who placed the order can also be returned with the order details.

See Data Services and Resources for a definition of data services and operations.

...

Sample run

Sample run of the service using the TryIt tool is shown below.

Nested query based operation invocation using the "listOfficesSQL" query:

Image Removed

Nested query based operation invocation using the "customerOrdersSQL" query:

Image Removed

Nested query based operation invocation using the "customerNameSQL" query:

Image Removed

Building the sample

The sample data service NestedQuerySample should be deployed using the instructions in Samples Setup.

Running the sample

The sample service can be run using the TryIt tool, which is bundled with the WSO2 Data Services Server, or a code-generated java client sample as discussed in the Data Services Clients section.

Follow the steps below to demonstrate this functionality using the TryIt tool:

  1. Log in to the management console of your server and click List under Services in the navigator. The NestedQuerySample will be listed here.
  2. Click Try this service to open the TryIt tool.
  3. Select an operation and click Send to execute the operation. You will get the product list in the response as shown below.
    • Operation invoking the listOfficesSQL query:
      Image Added 
    • Operation invoking the customerOrdersSQL query:
      Image Added 
    • Operation invoking the customerNameSQL query:

      Enter "103" as the customer name and send the request as shown below.
      Image Added 
    • Operation invoking the employeesInOfficeSQL query:

      First, see the result of "listOffices" operation to get the office code. Then, enter the office code ("1") and send the request as shown below. 
      Image Added