Conditionally executing multiple statements in series as single SQL statement

Поиск
Список
Период
Сортировка
От Nathaniel Trellice
Тема Conditionally executing multiple statements in series as single SQL statement
Дата
Msg-id 95970.29891.qm@web25008.mail.ukl.yahoo.com
обсуждение исходный текст
Ответы Re: Conditionally executing multiple statements in series as single SQL statement  (Sean Davis <sdavis2@mail.nih.gov>)
Re: Conditionally executing multiple statements in series as single SQL statement  (Rory Campbell-Lange <rory@campbell-lange.net>)
Re: Conditionally executing multiple statements in series as single SQL statement  (Mladen Gogala <mladen.gogala@vmsinfo.com>)
Error on Vacuum?  ("John J. Urbaniak" <jjurban@attglobal.net>)
Список pgsql-novice
Hi all,

In C, and many other programming languages, statements like the following are popular:

int status = (do_first_thing() && do_second_thing() && do_third_thing() && do_fourth_thing());

With this kind of expression, the program calls the function 'do_first_thing'. If, and only if, that returns non-zero,
'do_second_thing'will be executed. Again, if and only if that returns non-zero, 'do_third_thing' is executed. Etc. 

In other words, later statements will only be executed if all before them have 'gone well'. When a statement 'fails',
nofurther expressions are executed.. The variable 'status' is non-zero if, and only if, all four things were
successfullyexecuted. 

For convenience, I'd really like to be able to achieve similar behaviour within an SQL statement, i.e. present multiple
statements(such as INSERT statements) and only execute the later ones if the earlier ones have been executed without
error.And I'd like to be able to present all the statements within a single, compound SQL statement to the database. 

Is such a thing possible, using any fancy SQL syntactic tricks?


Nathaniel






В списке pgsql-novice по дате отправления:

Предыдущее
От: "Jean-Yves F. Barbier"
Дата:
Сообщение: Re: UTC timestamp
Следующее
От: Sean Davis
Дата:
Сообщение: Re: Conditionally executing multiple statements in series as single SQL statement