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: Testing a table existence

Re: Testing a table existence

From: George Barbour <gbarbour_at_csc.com>
Date: Mon, 10 Dec 2001 16:10:13 -0000
Message-ID: <3c14de7b$1@pull.gecm.com>


Try this .--------
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;

George Barbour.
"Sylvain BOURDETTE" <sbourdette_at_danet.fr> wrote in message news:3c14cac6$0$3179$626a54ce_at_news.free.fr...
> How in PL SQL, can test if a table exists ?
>
> I try this
>
> IF EXISTS MyTable THEN
>
> END IF;
>
> But it doesn't work
>
> Thanks
>
>
Received on Mon Dec 10 2001 - 10:10:13 CST

Original text of this message

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