dynamically giving order by
hi
i want to write a procedure that accepts a parameter for setting up the order by and return the result in a cursor.. i wrote the procedure as follows .
CREATE OR REPLACE Procedure Proc_ord
(cur out sys_refcursor,ord number)
as
begin
open cur for
select company_id,company_name from company order by ord;
end ;
/
SQL> variable a refcursor;
SQL> exec P(:a,1);
PL/SQL procedure successfully completed.
though this retrieves data its not giving the correct order by ..what could be wrong with this? plz let me know what change i have to do....
regards
Faisal S