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: Is there an equivalent to the SQL Server "if exists" statement?

Re: Is there an equivalent to the SQL Server "if exists" statement?

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Fri, 9 Jul 1999 15:58:36 +0100
Message-ID: <931532844.28.0.nnrp-13.9e984b29@news.demon.co.uk>

Can you expand on why you don't want
to use PL/SQL ?

A 'hidden PL/SQL' option if you have Oracle 8.1.5 - Create a table 'tables_to_drop (t_name varchar2(32)); create an after row trigger with the 'autonomous transaction' pragma The trigger should check in PL/SQL to see if the table identified by :new.t_name exists, and drop if it does so (or just drop it and catch the exception if it doesn't)

Your SQL code would then be:

    insert into table_to_drop values ('my_table');     rollback;

Actually, this might even be one of the examples that Thomas Kyte wrote up in his latest Digging in to 8i' article. Check out his SIG next time he sends a message

--

Jonathan Lewis
Yet another Oracle-related web site: www.jlcomp.demon.co.uk

Franklin Bowen wrote in message <3785FB82.58F9FB07_at_my-deja.com>...
>In SQL Server one can do this:
>
>if exists (select * from sysobjects where id = object_id('dbo.x') and
>sysstat & 0xf = 3)
> drop table dbo.x
>
>to drop a table only if it exists. I want to do the same thing in
>Oracle SQL (*NOT* PL/SQL) if possible.
>
Received on Fri Jul 09 1999 - 09:58:36 CDT

Original text of this message

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