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: PL/SQL !

Re: PL/SQL !

From: Jeff <jeff_at_work.com>
Date: Thu, 30 Aug 2001 12:28:15 GMT
Message-ID: <9mlbgv$lr2$1@cronkite.cc.uga.edu>

This works, but why do you have to do this via an explicit cursor??? Why not just return a COUNT(*) into a variable. If it's 1, it's there... 0, not.

In article <3b876b74$1_at_pull.gecm.com>, "George Barbour" <gbarbour_at_csc.com> wrote:
>It does work, but, I have a confession, s'not my code. I gratefully acquired
>it during an 'ora surf/trawl'.
>When I find the author I will give credit. (keep better records George).
>
>George Barbour.
>
>"Matt B." <gtimatt_at_home.com> wrote in message
>news:PjDh7.68165$MC1.22154626_at_news1.elcjn1.sdca.home.com...
>> "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
>> the data dictionary. It will be %FOUND if it's there and %NOTFOUND if
>it's not
>> there. Doesn't have anything to do with the table existing and the #of
>rows in
>> it.
>>
>> -Matt
>>
>>
>
>
Received on Thu Aug 30 2001 - 07:28:15 CDT

Original text of this message

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