Link to home
Create AccountLog in
Avatar of marcia1
marcia1Flag for Malta

asked on

How can I sort data within a sys_refcursor

very urgent

i am using an oracle procedure that have an out parameter of sys_refCursor, BUT i need to order the data with in the cursor by one of the attributes in the cursor. How can this be achieved. Attached i am including the PL/SQL

create or replace procedure cursor_test ( v_sql in varchar2 , v_data_set out sys_refcursor)

is

--v_sql varchar2(100) := 'select * from dual';
v_cursor varchar2(25) := 'open v_data_set for ';

v_all_cursor varchar2(1000);

v_mycursor  sys_refcursor;

begin

v_all_cursor := v_cursor||v_sql;


OPEN v_data_set FOR v_sql ;


commit;

end;
/
Avatar of YANN0S
YANN0S

Simply put the desired order by in the cursor's statement.

For example

v_sql :=  'select * from dual ORDER BY 1';
Avatar of marcia1

ASKER

DEAR YANNOS

THANKS FOR YOUR HELP BUT I NEED TO SORT THE DATA AFTER GETTING THE CURSOR NOT DURING THE EXECUTION OF  THE CURSOR.
ASKER CERTIFIED SOLUTION
Avatar of Sujith
Sujith
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer