public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Chamath Sajeewa <[email protected]>
Cc: [email protected]
Subject: Re: PGSQL returning into in insert statement
Date: Wed, 29 Jul 2020 23:05:39 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CACpofegcG+Ke2r4yoCpwRKPnV8r+fiGfB1w=ur4M3KHvTFKkpg@mail.gmail.com>
References: <CACpofegcG+Ke2r4yoCpwRKPnV8r+fiGfB1w=ur4M3KHvTFKkpg@mail.gmail.com>
Chamath Sajeewa <[email protected]> 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
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: PGSQL returning into in insert statement
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox