Search Postgresql Archives

Re: output inserted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux