Re: Capturing return value of a function

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: Capturing return value of a function
Дата
Msg-id 2EBC0B3F-0103-4EC1-8994-16729CD5092C@seespotcode.net
обсуждение исходный текст
Ответ на Capturing return value of a function  ("Jasbinder Singh Bali" <jsbali@gmail.com>)
Список pgsql-general
On Jul 16, 2007, at 15:55 , Jasbinder Singh Bali wrote:

> I was wondering what would the function return if insert fails.
> I want it to return 'success'  upon a successful insert and
> 'failure' if
> insert fails.

Depends on what you mean by "failed". Do you mean an error was
raised? Then you'll just get a normal error message. To catch this,
check the error trapping section of the PL/pgSQL documentation.

Do you mean nothing was inserted? If so, you won't catch this in your
above code. You can check the FOUND special variable after the INSERT
to see if anything was inserted and set your result message based on
that.

> Would the following implementation work for that?

No. BEGIN/END blocks in PL/pgSQL are not equivalent to SQL BEGIN/
COMMIT transactions.


Michael Glaesemann
grzm seespotcode net



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

Предыдущее
От: "Sébastien Boutté"
Дата:
Сообщение: Re: pg_dump without blobs
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: Capturing return value of a function