Re: Example of RETURNING clause to get auto-generated keys - Mailing list pgsql-general

From John D. Burger
Subject Re: Example of RETURNING clause to get auto-generated keys
Date
Msg-id 6268334A-22A3-4EFA-96B8-E5484B70591F@mitre.org
Whole thread Raw
In response to Re: Example of RETURNING clause to get auto-generated keys  (Ken Johanson <pg-user@kensystem.com>)
List pgsql-general
Ken Johanson wrote:

> Just to be sure, will the RETURNING clause work with custom
> sequences (say, non numeric or increment by two) or other types of
> key generators?... And how will triggers interfere with it (if at
> all)?

RETURNING has nothing to do with sequences per se - it's just a way
of getting at any of the columns of the new row, regardless of how
they got filled.
> The optional RETURNING clause causes INSERT to compute and return
> value(s) based on each row actually inserted. This is primarily
> useful for obtaining values that were supplied by defaults, such as
> a serial sequence number. However, any expression using the table's
> columns is allowed. The syntax of the RETURNING list is identical
> to that of the output list of SELECT.
http://www.postgresql.org/docs/8.2/interactive/sql-insert.html

- John Burger
   MITRE

pgsql-general by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: Idle in transaction - Explination ..
Next
From: Alvaro Herrera
Date:
Subject: Re: Example of RETURNING clause to get auto-generated keys