Skip site navigation (1) Skip section navigation (2)

Re: FW: RETURNING in stored procedure

From: "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: FW: RETURNING in stored procedure
Date: 2009-05-23 10:41:34
Message-ID: 200905231241.34509.leif@solumslekt.org (view raw or flat)
Thread:
Lists: pgsql-novice
On Saturday 23. May 2009, Jasen Betts wrote:
>On 2009-05-22, Mehrotra, Abhinav (GE Healthcare) 
<Abhinav(dot)Mehrotra(at)ge(dot)com> wrote:
>>>Val:= insert into temp("hello") RETURNING seq;
>
>postgres seems to translate anything after a := into a select,
>(something I often exploit)
>
>thus you can do
>
>  var := expression FROM table_name WHERE condition_expression ;
>
>etc.
>
>but INSERT-RETURNING isn't treated like an expression, or like a
>query so it doesn't work as above.
>
>> INSERT INTO temp("hello") RETURNING seq INTO val;
>
>yeah.

I still think that OP's syntax is the most intuitive one, and IMO it 
should be possible to do variable assignments this way in plpgsql from 
RETURNING values. It's the ┬źnormal┬╗ way of doing assignments in almost 
every other computer language that I know of.
-- 
Leif Biberg Kristensen | Registered Linux User #338009
Me And My Database: http://solumslekt.org/blog/

In response to

Responses

pgsql-novice by date

Next:From: Just E. MailDate: 2009-05-23 21:05:39
Subject: Create Database/Tables -PostgreSQL
Previous:From: Jasen BettsDate: 2009-05-23 10:22:39
Subject: Re: FW: RETURNING in stored procedure

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group