Re: PGSQL returning into in insert statement

From: Chamath Sajeewa <csgsajeewa(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: PGSQL returning into in insert statement
Date: 2020-07-30 06:56:26
Message-ID: CACpofeiBnKyFFf4a3_rFGSkx+_18drQVBv6mMkYQo4W5+oi0JA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Btw oracle support this in plain sql too.

On Thu, 30 Jul 2020, 11:42 Chamath Sajeewa, <csgsajeewa(at)gmail(dot)com> wrote:

> Understood. Thank you!
>
> On Thu, 30 Jul 2020, 08:35 Tom Lane, <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> Chamath Sajeewa <csgsajeewa(at)gmail(dot)com> writes:
>> > I want to use "returning into" in insert statement. I tried below,
>>
>> > insert into test_table(key,value) values('key1',5) returning value into
>> > returnvalue;
>>
>> > and below error occurred- syntax error at or near "into".
>>
>> That is perfectly legit syntax within a plpgsql function, but it
>> would produce the mentioned syntax error if you tried to use it
>> directly at the SQL level. So I conclude that you're fuzzy about
>> the difference between SQL and plpgsql. You can use plpgsql
>> statements within plpgsql-language function definitions, and
>> within DO blocks. But not as plain SQL. (Plain SQL has no concept
>> of variables either, so "into returnvalue" makes no sense there
>> anyway.)
>>
>> regards, tom lane
>>
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Stephen Frost 2020-07-30 14:28:52 Re: PGSQL insert data to a oid column using SOCI
Previous Message Chamath Sajeewa 2020-07-30 06:12:13 Re: PGSQL returning into in insert statement