0

Lets say I have a table temp123 as

Column      |      Type         |       Modifiers
------------+-------------------+------------------------
id          | integer           | not null default nextval('temp12_id_seq'::regclass)
description | character varying |

I would like to combine the ID returned by

INSERT INTO temp123 (description) 
      VALUES ('TESTING') RETURNING ID;

with a `SELECT'. For example (doesn't work):

SELECT 23, x.* 
FROM (INSERT INTO temp123 (description) 
       VALUES ('TESTING') RETURNING id ) AS x;

PostgreSQL v9.0.2

0

1 Answer 1

4

The SELECT part is not needed in your example. The desired result would be obtained like this with any PG version that supports INSERT...RETURNING (>=8.2):

insert into temp123(description) values('TESTING') returning 23,*;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.