Re: Conditionally executing multiple statements in series as single SQL statement
От | Rory Campbell-Lange |
---|---|
Тема | Re: Conditionally executing multiple statements in series as single SQL statement |
Дата | |
Msg-id | 20091218131845.GD22707@campbell-lange.net обсуждение исходный текст |
Ответ на | Conditionally executing multiple statements in series as single SQL statement (Nathaniel Trellice <naptrel@yahoo.co.uk>) |
Список | pgsql-novice |
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
В списке pgsql-novice по дате отправления: