Skip to Main Content

APEX

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!

Sort problem on dynamic query !!

user575752Mar 24 2011 — edited Mar 25 2011
Hi,

I have a dynamic query written in pl/sql, when I check "Sort" for each field in Report Attribute, error message raised up as "ORA-01785: ORDER BY item must be the number of a SELECT-list expression".
If I do not check Sort, it works fine. In my apps I need all fields sorted by user, how to fix this problem?

My query as below:

declare
query varchar2(2000):='select';
s_class varchar2(1000);
cursor c1 is select * from demo_preference;
begin
for c1_val in c1 loop
if c1_val.login is not null then
query := query ||' ' || 'login' || ',';
end if;
if c1_val.id is not null then
query := query ||' ' || 'id' || ',';
end if;
.......
end loop;
query := SUBSTR(query, 1, length(query)-1);

s_class := '(NVL(:P2_class, ''%'' || ''null%'') = ''%'' || ''null%'' OR
EXISTS (SELECT 1 FROM apex_collections WHERE collection_name = ''P2CLASSCOL'' AND c001 = class))';

query := query ||' ' || 'from ming.reg_report_view1 where'
|| ' ' || s_class;
return(query);
end;
This post has been answered by Vee on Mar 24 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 22 2011
Added on Mar 24 2011
2 comments
296 views