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!

Dynamic order by using case statement

Nabila islamFeb 23 2017 — edited Mar 14 2017

Hi All

I am writing a LOV query in tabular form column. But the problem is I am unable to do a dynamic order by inside the query.

select name as d,code as r

from test_table

where category= :COLUMN1

order by (case when category= 'A' then code;

          case when category= 'B' then name;

          else code, length(code)

         end)

The error I am getting is: ORA-00905: missing keyword

It is because of line 06. In else case I have used 2 different columns for order by. Removing this all works fine.

Is there a way I can use 2 columns for order by.

Using the following:

Oracle APEX 5.0.3

Theme: Universal Theme - 42

Database: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

I have come across another discussion:Select list in Tabular Form using PL/SQL Function Body returning SQL Query
where I found that in Apex 5, for tabular form column LOV type, pl/sql function body returning SQL query doesn't work (Is a bug I think). So I am unable to use that option for the above query also.

Any suggestions will be highly appreciated.

Thanks

Nabila

Message was edited by: Nabila Islam

This post has been answered by fac586 on Feb 24 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 11 2017
Added on Feb 23 2017
13 comments
3,676 views