Re: [HACKERS] Enhancing PGSQL to be compatible with Informix SQL
Bruce Momjian <pgman@candle.pha.pa.us>
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Rod Chamberlin <rod@querix.com>, pgsql-hackers@postgresql.org
Date: 2000-01-06T16:11:32Z
Lists: pgsql-hackers
> However, if you need to know what value is being given to the
> inserted tuple, much the cleanest solution is to select nextval
> before inserting:
>
> SELECT nextval('sequenceobject');
> INSERT INTO table VALUES(... , value-you-just-got, ...);
>
> If you are always going to do that, then a trigger is a waste of cycles.
He can do:
INSERT INTO table VALUES(... , nextval('sequenceobject'), ...);
and currval() will get him the previous nextval() value.
--
Bruce Momjian | http://www.op.net/~candle
maillist@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026