Subject RE: [firebird-support] Newbie on SPs: HELP ON STORED PROCEDURE
Author Clay Shannon
<< I am trying to make a SP to check if the record already exists.>>

Carol,

Try something like this:

SELECT 1 FROM rdb$database WHERE EXISTS
(SELECT 1 FROM <a table> WHERE <conditions>)

If result = 1, the record exists; otherwise, it doesn't.

BTW, didn't you used to work with Bob what's-his-face on "Let's Make a
Deal"?

Clay Shannon,
Dimension 4 Software
-----Original Message-----
From: Carol Milius [mailto:lista@...]
Sent: Tuesday, February 01, 2005 12:58 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Newbie on SPs: HELP ON STORED PROCEDURE


Hi!

I am trying to make a SP to check if the record already exists.
The SP below is something I am trying but it is not working..
I am reading de IB manuals but can not get an clear exemple..
Any coments are welcome (links too)

Best Regards,

Carol

Input: IN_FIELDNAME, IN_TABLENAME, IN_FIELDVALUE
Output: OUT_EXISTS
Var: VAR_FIELDVALUE

begin
OUT_EXISTS = 'No';

For Execute Statement

'Select ' || IN_FIELDNAME ||
' From ' || IN_TABLENAME
Into :VAR_FIELDVALUE
Do
if (VAR_FIELDVALUE = IN_FIELDVALUE) Then
OUT_EXISTS = 'Yes';

suspend;

end







Yahoo! Groups Links