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

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: What is the difference between INSERT...RETURN and pl/pgsql RETURNING?
Date: 2014-03-12 17:02:32
Message-ID: 1394643752797-5795727.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Daryl Foster 2014-03-12 17:12:20 Re: Cannot insert to 'path' field using EclipseLink
Previous Message David Johnston 2014-03-12 16:54:28 Re: What is the difference between INSERT...RETURN and pl/pgsql RETURNING?