From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: FW: RETURNING in stored procedure |
Date: | 2009-05-24 11:43:08 |
Message-ID: | gvbbsc$g72$1@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On 2009-05-23, Leif B. Kristensen <leif(at)solumslekt(dot)org> wrote:
> 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.
I agree, however Insert...returning can't be used as a subquery.
which is effectively what he was doing.
I'm not sure why it can't be used as a subquery.
From | Date | Subject | |
---|---|---|---|
Next Message | Luiz Eduardo Cantanhede Neri | 2009-05-24 17:54:47 | INHERIT and FOREIGN KEY issues |
Previous Message | Just E. Mail | 2009-05-23 21:05:39 | Create Database/Tables -PostgreSQL |