WSO2 DSS: Issue in Creating Data services using an oracle Stored Procedure with Ref Cursor and other Scalar out parameter -
i learning wso2 dss. trying implement 1 of use case using dss , oracle stored procedure.
oracle stored procedure using has 1 input parameter , 2 scalar out parameter while 1 ref cursor.
database script
create table dss_dept ( dept_id varchar2(10), dept_name varchar2(10) ); create table dss_emp ( emp_id varchar2(10), fname varchar2(10), lname varchar2(10), title varchar2(10) ); create table dss_emp_dept ( dept_id varchar2(10), emp_id varchar2(10) ); create or replace procedure get_emp_data( p_emp_id in dss_emp.emp_id%type, p_emp_fname out dss_emp.fname%type, p_emp_lname out dss_emp.lname%type, p_dep_rset out sys_refcursor ) begin select fname, lname p_emp_fname , p_emp_lname dss_emp emp_id = p_emp_id; open p_dep_rset select dept_id dss_emp_dept emp_id = p_emp_id; end; /
data insert script
insert dss_dept (dept_id,dept_name) values ('inv','inventory'); insert dss_dept (dept_id,dept_name) values ('sal','sales'); insert dss_emp (emp_id,fname,lname,title) values ('2','alpesh','b','se'); insert dss_emp (emp_id,fname,lname,title) values ('1','alps','b','se'); insert dss_emp_dept (dept_id,emp_id) values ('sal','1'); insert dss_emp_dept (dept_id,emp_id) values ('inv','2'); insert dss_emp_dept (dept_id,emp_id) values ('sal','2'); commit;
dss configuration:
<data name="mydsstest" transports="http https local"> <description>testing wso2 dss oracle</description> <config enableodata="false" id="dbtest"> <property name="carbon_datasource_name">dbtest</property> </config> <query id="getempdata_qry" useconfig="edbtest"> <sql>call get_emp_data (:p_emp_id ,:p_emp_fname,:p_emp_lname,:p_dep_rset)</sql> <result element="employees" rowname="employee"> <element name="p_emp_id" query-param="p_emp_id" xsdtype="string"/> <element column="p_emp_fname" name="p_emp_fname" xsdtype="string"/> <element column="p_emp_lname" name="p_emp_lname" xsdtype="string"/> <element column="dept_id" name="dept_id" xsdtype="string"/> </result> <param name="p_emp_id" sqltype="string"/> <param name="p_emp_fname" sqltype="string" type="out"/> <param name="p_emp_lname" sqltype="string" type="out"/> <param name="p_dep_rset" sqltype="oracle_ref_cursor" type="out"/> </query> <operation name="getempdata"> <call-query href="getempdata_qry"> <with-param name="p_emp_id" query-param="p_emp_id"/> </call-query> </operation> <resource method="get" path="getempdata/{p_emp_id}"> <call-query href="getempdata_qry"> <with-param name="p_emp_id" query-param="p_emp_id"/> </call-query> </resource> </data>
result of rest call
<employees> <employee> <p_emp_id>2</p_emp_id> <p_emp_fname>alpesh2</p_emp_fname> <p_emp_lname>bhalodia2</p_emp_lname> <dept_id>inv</dept_id> </employee> <employee> <p_emp_id>2</p_emp_id> <p_emp_fname>alpesh2</p_emp_fname> <p_emp_lname>bhalodia2</p_emp_lname> <dept_id>sal</dept_id> </employee> </employees>
result format want
<employees> <employee> <p_emp_id>2</p_emp_id> <p_emp_fname>alpesh2</p_emp_fname> <p_emp_lname>bhalodia2</p_emp_lname> <depts> <dept_id>inv</dept_id> <dept_id>sal</dept_id> </depts> </employee> </employees>
i want department values cursor exported complex element show above. tried different type of combination in setting output mapping in dss nothing worked.
i know can achieved using xslt on top of results don't want that.
am doing wrong in setting output mapping? how export cursor result array in dss?
this expected behavior. each dept_id in there employee row in result set.
Comments
Post a Comment