exceptions in SPL
Posted in 1996
Topics: Stored Procedures & SPL, Jobs, Consulting & Announcements
Using SPL, I wrote the following to see if a given record was in the
database, then if it was not found, to insert it. Either way, the
procedure is intended to return the serial number of the address. I
assumed this was an ideal situation for using the "NOT FOUND" exception
but in fact the code in the exception is never executed. On tracing the
code I find that if the address is not present then address_id is set to
NULL. So for the moment I've rewritten the code to test for NULL
instead, but I am puzzled by this behaviour.
Kathy Carter
BEGIN
ON EXCEPTION IN (
100 -- NOT FOUND
)
INSERT INTO address
VALUES (0, org, dep, str, twn, cnty, pcode, ctry); address_id = dbinfo("sqlca.sqlerrd1");
END EXCEPTION;
SELECT addr_id
INTO address_id
FROM address
WHERE
organisation = org
AND department = dep
AND street = str
AND town = twn
AND county= cnty
AND postcode = pcode
AND country = ctry;END;
RETURN address_id;
--
Kathleen Carter PhD
Consultant
Motiv Systems Ltd WWW: http://www.motiv.co.uk
Orwell House Tel: +44 1223 576318
Cowley Road Fax: +44 1223 576319
Cambridge CB4 4WY Email: k.carter@motiv.co.uk