Re: Example of RETURNING clause to get auto-generated keys

From: "John D(dot) Burger" <john(at)mitre(dot)org>
To: Ken Johanson <pg-user(at)kensystem(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Example of RETURNING clause to get auto-generated keys
Date: 2007-01-25 03:31:51
Message-ID: 6268334A-22A3-4EFA-96B8-E5484B70591F@mitre.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-01-25 03:49:46 Re: Example of RETURNING clause to get auto-generated keys
Previous Message Merlin Moncure 2007-01-25 03:06:36 Re: Idle in transaction - Explination ..