Re: problem in with clause: if table1 is empty select from table2
From: Mladen Gogala <mgogala_at_yahoo.com>
Date: 30 Mar 2008 13:13:13 GMT
Message-ID: <47ef91e9$0$1341$834e42db@reader.greatnowhere.com>
Date: 30 Mar 2008 13:13:13 GMT
Message-ID: <47ef91e9$0$1341$834e42db@reader.greatnowhere.com>
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.
-- http://mgogala.freehostia.comReceived on Sun Mar 30 2008 - 08:13:13 CDT