Re: How to check the existance of a table ?

From: <maarten.scharroo_at_wkap.nl>
Date: Thu, 31 Aug 2000 12:16:07 +0200
Message-ID: <8olb99$kbp$1_at_nereid.worldonline.nl>


Robert,

Try the following code.

FUNCTION sp_tableexists( i_s_tablename IN VARCHAR2) RETURN BOOLEAN IS

    CURSOR cq_usertab (i_s_tablename) 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;

Maarten

"Robert Vabo" <robert.vabo_at_gecko.no> wrote in message news:2npr5.12195$541.2514526_at_juliett.dax.net...
> I want tocheck if a table exist in the database via a SP.
>
> Procedure SP_TableExist
> ( TableName varchar2)
> IS
> if exists(select * from User_Objects WHERE Object_Name = || TableName)
> return 1;
> else
> return 0;
> end if;
> end SP_TableExist;
>
> Any suggestions ?
>
> --
> Regards
> Robert Vabo
> Application developer
> Gecko Informasjonssystemer AS
> www.gecko.no
> robert.vabo_at_gecko.no
>
>
Received on Thu Aug 31 2000 - 12:16:07 CEST

Original text of this message