On 18/12/09, Nathaniel Trellice (naptrel@yahoo.co.uk) wrote:
> In other words, later statements will only be executed if all before
> them have 'gone well'. When a statement 'fails', no further
> expressions are executed.. The variable 'status' is non-zero if, and
> only if, all four things were successfully executed.
You could do something along the following lines:
CREATE OR REPLACE FUNCTION
fn_test ( integer) RETURNS INTEGER
AS $$
DECLARE
input ALIAS for $1;
status INTEGER := 0;
returner INTEGER := 0;
BEGIN
PERFORM fn_test1 (input);
IF NOT FOUND THEN
RETURN returner;
ELSE
SELECT INTO status * FROM fn_test2 (input);
IF status != 1 THEN
RAISE NOTICE 'status from fn_test2 not expected %' % status
RETURN returner;
ELSE
...etc...
END IF;
returner = 1
RETURN returner;
END IF;
END;$$
LANGUAGE plpgsql;
-
Rory Campbell-Lange
Director
rory@campbell-lange.net
Campbell-Lange Workshop
www.campbell-lange.net
0207 6311 555
3 Tottenham Street London W1T 2AF
Registered in England No. 04551928