Re: output inserted - Mailing list pgsql-general

From Ryan Kelly
Subject Re: output inserted
Date
Msg-id 20121121134526.GA7889@llserver.lakeliving.com
Whole thread Raw
In response to output inserted  (Peter Kroon <plakroon@gmail.com>)
List pgsql-general
On Wed, Nov 21, 2012 at 02:41:24PM +0100, Peter Kroon wrote:
> How to I output the insert in PostgreSQL?
>
> DROP TABLE IF EXISTS a_001;
> CREATE TEMP TABLE a_001(
> vl text
> );
> DROP TABLE IF EXISTS a_002;
> CREATE TEMP TABLE a_002(
> vl text
> );
>
> INSERT INTO a_001
> OUTPUT INSERTED.* INTO a_002 --mssql
> SELECT 'text for insertion';
>
> SELECT vl FROM a_002;

WITH data AS (
    INSERT INTO a_001
    SELECT 'text for insertion'
    RETURNING *
)
INSERT INTO a_002
SELECT * FROM data;

This is one possible solution.

-Ryan P. Kelly


pgsql-general by date:

Previous
From: "David Johnston"
Date:
Subject: Re: Escaping regexp special characters in field value
Next
From: "David Johnston"
Date:
Subject: Re: output inserted