Re: writing a function to mimic mysql last_insert_id

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: writing a function to mimic mysql last_insert_id
Дата
Msg-id 3D8004E4.80004@joeconway.com
обсуждение исходный текст
Ответ на Re: writing a function to mimic mysql last_insert_id  ("Beth Gatewood" <beth@vizxlabs.com>)
Список pgsql-sql
Beth Gatewood wrote:
> well, I know that I will have only a single sequence that will generate the
> primary key per table.  So basically, this type of function, for me needs
> only to return the value of the primary key.
> 
> I believe I mentioned in one of my posts the motivation behind not wanting
> to use currval()...which was to trying to avoid having the developers make a
> lot of sql revisions to their application.

Maybe you could use the *same* sequence for the primary key of all the tables, 
say "my_global_seq" (it is bigint as of 7.2 I think), and then wrap a 
last_insert_id() (or whatever it is called) function around a call to 
currval('my_global_seq').

HTH,

Joe






В списке pgsql-sql по дате отправления:

Предыдущее
От: "Beth Gatewood"
Дата:
Сообщение: Re: writing a function to mimic mysql last_insert_id
Следующее
От: Rudi Starcevic
Дата:
Сообщение: htdig & postgresql