pl/sql best practices
Date: 31 Jan 2002 09:48:31 -0800
Message-ID: <8f9f2c0b.0201310948.7ce6fac6_at_posting.google.com>
hi.
Having written a few stored procedures i recognized the need to read some 'clever books'. So i started with oracle pl/sql programming. Very nice, but fat. Actually before i could learn some new clever syntax, i found following rule:
'never write implicit cursors (in other words, never use SELECT INTO syntax).'
But, this i used (copy&pasted from similar code) very often. So, please, could someone explain me, how should a !good! code look like?
My code is here:
FUNCTION update_xxx(p_id_constraint IN NUMBER, p_base_condition IN VARCHAR2) RETURN BOOLEAN IS
test_id NUMBER;
BEGIN
SELECT id_constraint INTO test_id
FROM my_table
WHERE id_constraint = p_id_constraint;
UPDATE my_table
SET base_condition = p_base_condition
WHERE id_constraint = p_id_constraint;
RETURN TRUE;
EXCEPTION
WHEN no_data_found THEN
RETURN FALSE;
END update_xxx;
The aim is to make sure, that there was a row updated.
many thanks Received on Thu Jan 31 2002 - 18:48:31 CET