| From: | Ryan Kelly <rpkelly22(at)gmail(dot)com> |
|---|---|
| To: | Peter Kroon <plakroon(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: output inserted |
| Date: | 2012-11-21 13:45:26 |
| Message-ID: | 20121121134526.GA7889@llserver.lakeliving.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Johnston | 2012-11-21 13:50:09 | Re: output inserted |
| Previous Message | David Johnston | 2012-11-21 13:42:53 | Re: Escaping regexp special characters in field value |