Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux