http://stackoverflow.com/questions/1716590/pl-sql-optional-conditions-in-where-clause-without-dynamic-sql
https://community.oracle.com/message/9767808#9767808
http://stackoverflow.com/questions/3574667/setting-the-order-by-clause-from-plsql-procedure-parameters
http://stackoverflow.com/questions/4956120/oracle-dynamic-desc-and-asc-in-order-by
http://stackoverflow.com/questions/27015623/sql-dynamic-asc-and-desc?rq=1
http://www.toadworld.com/platforms/oracle/w/wiki/4757.using-decode#using-decode-in-order-by-and-group-by-clauses
SELECT * FROM USERS user WHERE DELETED != true and (:roleId is null or ROLE_ID = :roleId) ORDER BY case when :rev = 'ASC' then DECODE(:orderBy, 'NAME', NAME, NAME) end ASC, case when :rev='DESC' then DECODE(:orderBy, 'NAME', NAME, NAME) end DESC
No comments:
Post a Comment