community.borland.com

Article #25564: How can I tell if a record was found by a select in a stored procedure?

Problem:
How can I tell if a record was found by a select in a stored procedure?

Solution:
*****************************************************************************************
Note: The information in this document was tested under InterBase version 5.0.
*****************************************************************************************
Use the 'exists' operator in the select statement to tell you if 
the select statement returned any records.  

Here is an example of a script that demonstrates how this works:

connect "d:tempdeleteme.gdb"; 
set term !;
create procedure test_count
  returns (result integer)
AS
BEGIN
IF (not exists(SELECT BREED FROM BREEDLIST WHERE BREED='MUTT')) 
   THEN
     result =5;
END!
SET TERM ;!

Last Modified: 26-OCT-00