Re: INSERT doc discrepancy

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Kristo Kaiv <kristo(dot)kaiv(at)skype(dot)net>
Cc: Postgres-General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: INSERT doc discrepancy
Date: 2007-08-28 12:58:44
Message-ID: 20070828125844.GG7962@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kristo Kaiv wrote:
> INSERT INTO table [ ( column [, ...] ) ]
> { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...]
> | query }
> [ RETURNING * | output_expression [ AS output_name ] [, ...] ]
>
> but it seems if i want to return the result into a record i have to use it
> with INTO clause in the end:
>
> INSERT INTO tablename (
> a
> ,b
> ,c
> ) VALUES (
> in_a
> ,in_b
> ,in_c
> ) RETURNING * INTO _r;

Where's the discrepancy? INTO is not supported in the RETURNING clause.

... thinks for a while ...

Ah, you are using it in plpgsql! OK, but the explanation to the
discrepancy is that the second INTO is not part of the SQL sentence;
it's plpgsql only, and is parsed by its internal parser, so not really
part of the SQL grammar.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2007-08-28 13:06:32 Re: delete vs insert vs update due to primary key dups -> which is better
Previous Message btober 2007-08-28 12:57:11 Re: [GENERAL] One database vs. hundreds?