Re: problem in with clause: if table1 is empty select from table2

From: Mladen Gogala <>
Date: 30 Mar 2008 13:13:13 GMT
Message-ID: <47ef91e9$0$1341$>

On Sun, 30 Mar 2008 00:48:03 -0700, nova1427 wrote:

> Please help me to write query like this
> WITH table_not_empty AS
> (
> if (SELECT * FROM Table1) is not empty return it_self else return
> (SELECT * FROM Table2)
> )

That cannot be achieved in SQL as SQL is not procedural language. PL/SQL can return ref_cursor variable without a problem, but it's not the same as SQL. The best one can do in SQL is union, but there are assumptions on both table.

Received on Sun Mar 30 2008 - 08:13:13 CDT

Original text of this message