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
H,
Create a function like:-
FUNCTION sp_tableexists( i_s_tablename IN VARCHAR2) RETURN BOOLEAN IS
CURSOR cq_usertab (i_s_tablename VARCHAR2) IS
SELECT table_name FROM user_tables
WHERE table_name = i_s_tablename;
l_r_tablerow cq_usertab%rowtype;
BEGIN
OPEN cq_usertab (i_s_tablename);
FETCH cq_usertab INTO l_r_tablerow;
IF cq_usertab%notfound THEN
CLOSE cq_usertab; RETURN FALSE; ELSE CLOSE cq_usertab; RETURN TRUE;
HTH.
George Barbour.
"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 Fri Nov 10 2000 - 04:51:02 CST
![]() |
![]() |