OBJECTIVE: call a store procedure which return a list of data
PROVIDED: we have procedure in database
PROCEDURE retrieve_allusers_same_roles(p_user_name IN VARCHAR2,
user_details_list OUT refcursor) IS
BEGIN
OPEN user_details_list FOR
SELECT DISTINCT user1.user_id as usrUserID,
user1.user_name as usrUsername,
user1.full_name as usrFullname
FROM BPMDB.LSW_USR_XREF user1 inner join BPMDB.lsw_usr_grp_mem_xref usergrp2 on user1.user_id=usergrp2.user_id
WHERE usergrp2.group_id in (
SELECT usergrp1.group_id
FROM BPMDB.LSW_USR_GRP_MEM_XREF userGrp1 inner join BPMDB.LSW_GRP_GRP_MEM_XREF grpgrp1 on usergrp1.group_id = grpgrp1.group_id
,BPMDB.lsw_usr_grp_xref grp1
,BPMDB.LSW_USR_XREF user2
WHERE upper(user2.user_name)=upper(p_user_name)
AND user2.user_id = usergrp1.user_id
AND grp1.group_id = grpgrp1.container_group_id
AND grp1.group_name = 'Business Team');
END retrieve_allusers_same_roles;
SOLUTION:
1. Prepare param list
tw.local.parameters = new tw.object.listOf.SQLParameter();
var parameter = new tw.object.SQLParameter();
parameter.value = tw.local.username;
parameter.type = 'VARCHAR';
parameter.mode = 'IN';
tw.local.parameters.insertIntoList(tw.local.parameters.listLength, parameter);
var parameter = new tw.object.SQLParameter();
parameter.value = tw.local.results;
parameter.type = 'ORACLE_CURSOR';
parameter.mode = 'OUT';
tw.local.parameters.insertIntoList(tw.local.parameters.listLength, parameter);
NOTE: the tw.local.result datatype: list of "UserDetail"
"UserDetail" complex object defined in PD:
usrUsername: String
usrFullname: String
usrUserID : String
With this technique of controlling the Output of proc, BPM automatically maps the output of this pro "retrieve_allusers_same" into list of UserDetails for us
2. Set the sql for the "SQL Call Stored Procedure"
CALL retrieve_allusers_same_roles(?,?)
3. Configure the "SQL Call Stored Procedure" service

tw.local.results is list of "UserDetail". BPM automatically map the result list into a list of business object for us.