20
Views
3
Comments
Solution: Oracle Store Procedure with Cursor in Advance SQL

Recently we faced one scenario where we had to return data from oracle store procedure using "Advance SQL". Unfortunately, we didn't find any solution from community or even from support. 

The final answer from support was, It's not possible in OutSystems. 


Luckily we was able to find the solution. Here I am sharing the solution. 


***************************************************

Declare cur_data sys_refcursor;

BEGIN

    PKD_EMPLOYEE_CRUD.PRD_GET_EMPLOYEES(Cur_data);

    dbms_sql.return_result(cur_data);

END;

****************************************************


Explanation:

Here, PKD_EMPLOYEE_CRUD is the package name & PRD_GET_EMPLOYEES  is the procedure name. Find below sample procedure.


****************************************

CREATE OR REPLACE PROCEDURE PRD_GET_EMPLOYEES(Cur_Data OUT SYS_REFCURSOR)

IS

BEGIN

  OPEN Cur_Data FOR 

  SELECT *   FROM   EMPLOYEE;

END PRD_GET_EMPLOYEES;

****************************************

Can you share sample OML that how the result is assigned to Out System object?

Sorry, it's not possible for me to share OML as personal environment does not support oracle. Please see below screenshot for reference. It's straight forward, just add structure in output. 


Thanks a lot. We will try it for future work.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.