Skip site navigation (1) Skip section navigation (2)

Support for RETURNING xxx INTO yyy for INSERT and UPDATE?

From: John Napiorkowski <jjn1056(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Support for RETURNING xxx INTO yyy for INSERT and UPDATE?
Date: 2005-02-23 06:11:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Does anyone know if Postgres supports some form of:

insert into mytable(column1,column2) 
 values ('a','b') 
 returning mytable_pk into :new_mytable_pk

Where 'mytable_pk' is defaulted to type of SERIAL?

I am really used to having this on Oracle, but can't
seem to find anything about it in the documentation or
searching around the mailing lists.

If not, what methods can I use to reliable and
efficiently return new primary keys from inserts?  I
am thinking I could use a function, but then I would
need to create one for each table in the database,
which seems really messy to me.

Sorry if this question has been answered somewhere
else. I figure it must have been, since this seems
like such a basic thing to me, but I just can't find
it :)


Do you Yahoo!? 
Yahoo! Sports - Sign up for Fantasy Baseball.


pgsql-novice by date

Next:From: Jason EarlDate: 2005-02-23 07:09:45
Subject: Re: Bad Boolean external represenation *HELP*!
Previous:From: brewDate: 2005-02-22 22:28:10
Subject: Re: execute dynamic strings

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group