Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: PLSQL: how to test if a table exists?

Re: PLSQL: how to test if a table exists?

From: Keith Jamieson <keith_jamieson_at_hotmail.com>
Date: Thu, 4 Dec 2003 11:25:37 -0000
Message-ID: <TQEzb.3209$nm6.17959@news.indigo.ie>


Look for the tablename in the datadictionary. eg

     BEGIN

      select * from user_tables
       where table_name = 'BLAH';

       if SQL%ROWCOUNT = 0
       THEN
                 NULL; /* Table doesn't exist so do nothing
       else
                --  Code when table does exist
       end if;



"NoName" <nobody_at_nowhere.com> wrote in message news:bqmunc$9nq$1_at_fata.cs.interbusiness.it...
> Hello,
>
> in a PLSQL script, I want to execute code only if a certain table exists.
> A pseudo-solution could be:
>
> declare
> cursor c1 is select * from notable;
> begin
> open c1;
> if c1%ISOPEN then
> -- statements to execute if table exists
> end if;
> end;
>
> Obviously, the above code is not correct, first of all the script throws
an
> execption if "notable" doesn't exist.
> Any workaround?
>
> Thank you
>
>
Received on Thu Dec 04 2003 - 05:25:37 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US