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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to find out if a table already exists with PL/SQL

Re: How to find out if a table already exists with PL/SQL

From: George Barbour <george.barbour_at_gecm.com>
Date: Fri, 10 Nov 2000 10:51:02 -0000
Message-ID: <3a0bd1fb$1@pull.gecm.com>

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;

    END IF;
END sp_tableexists;

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

Original text of this message

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