Friday, January 2, 2009

Replace 'no rows selected'

I wanted to replace the message 'no rows selected' with an alternate message.

SQL> select * from dual where 1=0;

no rows selected

SQL>

I found a good one by using NOT EXISTS clause

SQL> select * from dual where 1=0
           UNION
           select 'no data found' from dual where not exists (select * from dual where 1=0); 

DUMMY
no data found

1 row selected.

SQL>


Popular Posts