Re: Serial key
От | John Sidney-Woollett |
---|---|
Тема | Re: Serial key |
Дата | |
Msg-id | 3567.192.168.0.64.1076696509.squirrel@mercury.wardbrook.com обсуждение исходный текст |
Ответ на | Re: Serial key ("Chris Smith" <cdsmith@twu.net>) |
Ответы |
Re: Serial key
|
Список | pgsql-jdbc |
Chris Smith said: The only other approach is to > use > some unique set of columns in the table other than your numeric key, and > immediately follow your insert statement with a select. This only works > if > your records are unique without regard to the generated key. As an > example, > you'd do: > > insert into mytable (name, department, position, hiredate) > values('jdoe', 'eng', 'manager', DATE '10-12-1994'); > > select empid from mytable where > name = 'jdoe' AND > department = 'eng' AND > position = 'manager' AND > hiredate = DATE '10-12-1994'; > Alternatively, if you could use a sequence object for the primary key value (instead of a serial column), and you switched autocommit off, you should be able to determine the last allocated PK id AFTER creating the record by querying the currval on the sequence. John Sidney-Woollett
В списке pgsql-jdbc по дате отправления: