Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to return just one row after finding it
Use this method, you may have to adjust it to do what you want it to do but
the concept would be the same.
declare
lvtest char(1) defualt 'N';
begin
begin
select 'Y' into lvtest from dual where exists
(select dummy from table where condition);
exception when no_data_found then
lvtest:='N';
end;
if lvtest='N' then
dbms_output.put_line('record not found');
else
dbms_output.put_line('record found');
end if;
end;
md_at_doc.us.dell.com wrote in message <37f4cc14.346267062_at_news.us.dell.com>...
>Hi all,
>How would I write a query so, that it will stop searching as soon as
>it finds the first record in the table?
>The reason I would like to do that is so, the query doesn't go on and
>search for next 100,000 records for other records matching the same
>criteria. I just want the first one matching criteria and stop.
>
>For example: I want to find PartDate where PartNumber = 1000 from
>PartHistory table.
>
>Thanks in advance,
>-MD
Received on Mon Oct 04 1999 - 03:13:19 CDT
![]() |
![]() |