Re: PL/SQL !

From: Matt B. <gtimatt_at_home.com>
Date: Sat, 25 Aug 2001 01:37:51 GMT
Message-ID: <PjDh7.68165$MC1.22154626_at_news1.elcjn1.sdca.home.com>


[Quoted] "Jerry Metz" <jmetz1_at_ix.netcom.com> wrote in message news:3B82CEB5.7AE4C340_at_ix.netcom.com...
> If I read your code correctly (and it's certainly possible that I'm not
> with the day that I've had today!), your function will return FALSE even if
> the table exists but has no rows in it.

I don't think so (keep reading...)

> > 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;

Look again. The cursor hits user_tables and looks for the table's existence in [Quoted] the data dictionary. It will be %FOUND if it's there and %NOTFOUND if it's not [Quoted] there. Doesn't have anything to do with the table existing and the #of rows in it.

-Matt Received on Sat Aug 25 2001 - 03:37:51 CEST

Original text of this message