Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I create a dynamic order by clause in a cursor?

leebeeryMar 28 2007 — edited Mar 28 2007
I have the following in a form procedure.
I want to be able to pass in the column I want to sort this cursor by.
The following does not work, when it executes, it acts like it ignores the order by clause.
How do I get this to work?
It doesn't have to be in forms, it could be a db procedure, pkg, functon, etc.

declare
cursor c1(v_o in varchar2) is
select batch,
airport,
contract_no,
contract_descr,
contractor_name,
milestone_no,
milestone_descr,
sched_date,
frcst_act_date
from pc_milestones_cms
where print_rec = 'Y'
order by v_o;

v_order_by varchar2(500);
begin
open c1(v_order_by);
loop
fetch c1
into v_batch,
v_airport,
v_contract_no,
v_contract_descr,
v_contractor_name,
v_milestone_no,
v_milestone_descr,
v_sched_date,
v_frcst_act_date;
exit when c1%notfound;
.
.
.
end loop;
close c1;
end;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2007
Added on Mar 28 2007
6 comments
312 views