0
CREATE OR REPLACE PACKAGE abc
IS
 TYPE abc_cur IS REF CURSOR;

 FUNCTION TEST
  RETURN abc_cur;
 END;
/    

CREATE OR REPLACE PACKAGE BODY abc
IS
FUNCTION TEST
RETURN abc_cur
IS
v_select   VARCHAR2(2000);
 BEGIN
 v_select                   := 'Select a1,a2 from pqr';
 OPEN abc_cur FOR v_select;
 RETURN abc_cur;
 END TEST;
END abc;

This is the dummy package that I have created, in function test select is dynamic that mean data column varies. Now my issue is that when I call this function from any other procedure or function, I get the ref cursor, then how can I fetch the data from that cursor if I don't know which column it is returning dynamically?

1 Answer 1

1

If a1 and a2 are dynamic, change during runtime - you could consider using dbms_sql instead of refcursor. Here is an example of how dynamically the rows are fetched where number of columns and their type is not known until runtime. You could change it according to your requirement.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.