Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: How to find out if a table already exists with PL/SQL
use the DBMS_SQL package to execute the DROP statement. "wrap" the PARSE in anonymous block, to catch the exception if the table does not exist.
v_csr := ...
v_drop_stmt := 'DROP TABLE TEMPTBL';
BEGIN
DBMS_SQL.PARSE( v_csr , v_drop_stmt );
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
check the PL/SQL docs for information on executing "dynamic SQL"
for examples. in Oracle 8.1.x, there is new syntax that is easier to
use than the DBMS_SQL package...
"NoSpam" <NoSpam_at_NoSpam.com> wrote in message news:8uekvs$ibi$1_at_ih292.ea.unisys.com...
> Hi,
>
> I'm porting a Sybase script to Oracle. There is this thing that we do in
> Sybase but I just can't do in Oracle. In Sybase, we do:
>
> if exists (select * from sysobjects where name = 'TEMPTBL')
> begin
> print "Deleting table TEMPTBL....."
> drop table TEMPTBL
> end
> go
>
> Just how do I do this in Oracle?
>
> TIA
>
>
>
>
Received on Thu Nov 09 2000 - 23:57:13 CST
![]() |
![]() |