fetching the id of a new row

From: Jelle Ouwerkerk <jelle(at)openface(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: fetching the id of a new row
Date: 2001-02-08 22:28:59
Message-ID: Pine.NEB.4.10.10102081613240.3543-100000@what.openface.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

How might I insert a new row into a table and return the id of the new row
all in the same SQL statement? The id is generated by a sequence. Up to
now I've been getting the nextval of the sequence first and then inserting
with the id in a second SQL exec. Is there a faster way (in a general
case, without writing SQL or plpgsql functions)?

Thanks

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Hubert Palme 2001-02-08 22:29:31 Re: parse error in create index
Previous Message Tom Lane 2001-02-08 19:49:26 Re: PL/pgsql EXECUTE 'SELECT INTO ...'