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

From David Johnston
Subject Re: What is the difference between INSERT...RETURN and pl/pgsql RETURNING?
Date
Msg-id 1394643752797-5795727.post@n5.nabble.com
Whole thread Raw
In response to What is the difference between INSERT...RETURN and pl/pgsql RETURNING?  (Adam Mackler <postgresql@mackler.org>)
List 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 by date:

Previous
From: David Johnston
Date:
Subject: Re: What is the difference between INSERT...RETURN and pl/pgsql RETURNING?
Next
From: Daryl Foster
Date:
Subject: Re: Cannot insert to 'path' field using EclipseLink