Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Simple Select Return Record

RE: Simple Select Return Record

From: Ken Naim <kennaim_at_gmail.com>
Date: Thu, 9 Jun 2005 09:20:27 -0500
Message-ID: <42a8502b.3f988bab.3589.36cd@mx.gmail.com>


Declare
V_count number(1);
Begin
Select count(1) into v_count from employee_tbl where employee_id=employee_id_in and rownum<=1; If v_count=1
Then ...
Else ....
End if;
End;

By using the rownum<=1 oracle will optimize the query to retrieve 1 record. Also count always returns a record; If the set doesn't have any records, it returns 0.

Ken Naim

-----Original Message-----

From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Kean Jacinta
Sent: Wednesday, June 08, 2005 10:46 PM
To: oracle-l_at_freelists.org
Subject: Simple Select Return Record

hi,

Trying to query a select statement to check if return record existed or not existed.

select employeeid from employee_tbl
where employeeid=5;

If i type this in SQL*PLus, or sql worksheet , i can easily know if the record is found or record not existed in the table.Becoz it will display result if found .

How to know if a record is found or not found in programming code.I need the sql statement to return 0 if not found and return 1 if found.



Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
--

http://www.freelists.org/webpage/oracle-l

--

http://www.freelists.org/webpage/oracle-l Received on Thu Jun 09 2005 - 10:25:42 CDT

Original text of this message

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