Question

I'm facing wso2 data service problem with simple query.

Expected query: I want to use IN clause with multiple value. This is my sample query:

SELECT ORGANIZATION_ID, ORGANIZATION_NAME FROM ORGANIZATION WHERE ORGANIZATION_ID IN (?)
ORDER BY ORGANIZATION_NAME ASC

Getting error: When i try web service using "1,2,3" value, i get javax.xml.stream.XMLStreamException error.

How can i write above query in WSO2 DSS?

Please advice me on that.

Thanks, Eba

Was it helpful?

Solution

Refer the following data service query configuration which contains a sample input parameter of type "ARRAY" which you can effectively use to get your requirement fulfilled.

<query id="setSalaryForEmployeesQuery" useConfig="default">
          <sql>update Employees set salary=:salary where employeeNumber in (:employeeNumbers)</sql>
          <param name="salary" ordinal="1" paramType="SCALAR" sqlType="DOUBLE" type="IN"/>
          <param name="employeeNumbers" ordinal="2" paramType="ARRAY" sqlType="INTEGER" type="IN"/>
</query>

There, if you refer the input mapping configuration named "employeeNumbers", it basically addresses the same requirement mentioned in your query.

To try this functionality, you can use the "tryIt" functionality provided with each data service(similar to other service types) and the data service request format corresponding to the aforementioned configuration would look like what's depicted below.

<p:setSalaryForEmployees xmlns:p="http://ws.wso2.org/dataservice/samples/rdbms_sample">
              <!--Exactly 1 occurrence-->
              <xs:salary xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1000</xs:salary>
              <!--1 or more occurrences-->
              <xs:employeeNumbers xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1011</xs:employeeNumbers>
              <xs:employeeNumbers xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1022</xs:employeeNumbers>
</p:setSalaryForEmployees>

The complete data service configuration which contains the above configuration snippet can be located in the "DSS_HOME/sample/dbs/rdbms/RDBMSSample.dbs" which resides in DSS product archive.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top