Re: What is the difference between INSERT...RETURN and pl/pgsql RETURNING?

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: What is the difference between INSERT...RETURN and pl/pgsql RETURNING?
Дата
Msg-id 1394643752797-5795727.post@n5.nabble.com
обсуждение исходный текст
Ответ на What is the difference between INSERT...RETURN and pl/pgsql RETURNING?  (Adam Mackler <postgresql@mackler.org>)
Список pgsql-novice
Adam Mackler-4 wrote
> 2. What is the meaning of the error, _i.e._, since the trigger
>    function needs a value to return, and since the `INSERT` is the
>    final statement of the trigger function, why does the query have no
>    destination for the result data?

This is a false assumption.  The final statement of the block is the "END;"
(or, arguably, an implicit RETURN since one was not specified).  However you
want to define it the INSERT...RETURNING does not make its output available
as a return value, only RETURN is capable of doing that.  If you fail to
issue RETURN then either (not sure at the moment the circumstances for each
possibility) you will get an error when you reach the end of the function or
you will implicitly call "RETURN;" (i.e., return nothing).

Unlike some other languages the result of the last statement in a function
is not automatically used as a return value.  All returned values must be
explicitly sent.

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/What-is-the-difference-between-INSERT-RETURN-and-pl-pgsql-RETURNING-tp5795721p5795727.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


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

Предыдущее
От: David Johnston
Дата:
Сообщение: Re: What is the difference between INSERT...RETURN and pl/pgsql RETURNING?
Следующее
От: Daryl Foster
Дата:
Сообщение: Re: Cannot insert to 'path' field using EclipseLink