Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Re: sql%found problem
Instead of checking the sql%found, check on the number of rows
retuned:
declare
v number(10);
begin
select count(name) into v from str;
if v > 0 then
dbms_output.put_line('yes '||to_char(v)); else
dbms_output.put_line('no '||to_char(v));
end if;
end;
HTP.
Gunawan Yuwono
Oracle DBA
Kansas City, MO
>--- Original Message ---
>From: "Sultan" <ssyed_at_fine.co.ae>
>To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
>Date: 7/18/00 1:14:11 PM
>
>HAI all,
>
>The problem not with SQL%found ,problem with count function.
>
>If you use count function definitely it will return value Zero
or more than
>zero.
>It means SQL Stmt executed successfully and returning rows also,so
It will
>never go to 'No' section in your coding .
>
>By the way for your information
>If you used Count funtion in SQL Stmt You no need to define
Exception WHEN
>NO_DATA_FOUND since the count function never return 'no rows';
>
>
>Regards.
>SUL.
>
>
>----- Original Message -----
>To: Multiple recipients of list ORACLE-L <oracle-l_at_fatcity.com>
>Sent: Tuesday, July 18, 2000 06:35 AM
>
>
>> Select count statement always returns a number whether there
exists rows
>in the table or not.
>>
>> If there are no rows the outcome is 1 row with count as 0.
>> If there are some rows in the table output is 1 row with count
of Number
>of rows.
>> As always there is a row returned SQl %found is always TRUE
>> So as per ur logic, it will always go to YES part...
>>
>> Saji
>>
>> ---------------------------------------- Message
>History ----------------------------------------
>>
>>
>>
>> Please respond to ORACLE-L_at_fatcity.com
>>
>> To: ORACLE-L_at_fatcity.com
>> cc:
>>
>>
>>
>> hi all,
>> i had a problem over this query.could u tell me what is
wrong in that
>query.
>> ========
>> declare
>> v number(10);
>> begin
>> select count(name) into v from str;
>> if sql%found then
>> dbms_output.put_line('yes '||v);
>> else
>> dbms_output.put_line('no '||v);
>> end if;
>> end;
>> it displays only "yes'' even though the table contins or
not contain any
>rows.
>> could u tellme what went wrong.
>> paul
>>
>>
>>
>>
>> --
>> Author:
>> INET: saji.rajp_at_db.com
>>
>> Fat City Network Services -- (858) 538-5051 FAX: (858)
538-5051
>> San Diego, California -- Public Internet access / Mailing
Lists
>> --------------------------------------------------------------------
>> To REMOVE yourself from this mailing list, send an E-Mail
message
>> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru')
and in
>> the message BODY, include a line containing: UNSUB ORACLE-L
>> (or the name of mailing list you want to be removed from).
You may
>> also send the HELP command for other information (like subscribing).
>
>--
>Author: Sultan
> INET: ssyed_at_fine.co.ae
>
>Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
>San Diego, California -- Public Internet access / Mailing
Lists
>--------------------------------------------------------------------
>To REMOVE yourself from this mailing list, send an E-Mail message
>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru')
and in
>the message BODY, include a line containing: UNSUB ORACLE-L
>(or the name of mailing list you want to be removed from).
You may
>also send the HELP command for other information (like subscribing).
>
>