Re: How do I save data and then raise an exception?

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: How do I save data and then raise an exception?
Дата
Msg-id 20081003014416.GM4151@alvh.no-ip.org
обсуждение исходный текст
Ответ на How do I save data and then raise an exception?  ("Rob Richardson" <Rob.Richardson@rad-con.com>)
Ответы Re: How do I save data and then raise an exception?  ("Jaime Casanova" <jcasanov@systemguards.com.ec>)
Re: How do I save data and then raise an exception?  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
Список pgsql-general
Rob Richardson wrote:

> Here's what I need to do:
>
> IF query_check_fails THEN
>     UPDATE some_table SET some_value = 0 WHERE some_condition_is_true;
>     RAISE EXCEPTION 'Look, you idiot, do it right next time!';
> END;
>
> I need the update to work, but I need to raise the exception so the C++
> code recognizes the error.  How can I do both?

You need an autonomous transaction, which Postgres does not support
directly but you can implement using dblink or a plperl function that
connects back to the database.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

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

Предыдущее
От: "Rob Richardson"
Дата:
Сообщение: How do I save data and then raise an exception?
Следующее
От: "Jaime Casanova"
Дата:
Сообщение: Re: How do I save data and then raise an exception?