Re: sequences vs oids as primary keys
От | Merlin Moncure |
---|---|
Тема | Re: sequences vs oids as primary keys |
Дата | |
Msg-id | b42b73150607260654t52545014x884cf74388ae01f4@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: sequences vs oids as primary keys (Kenneth Downs <ken@secdat.com>) |
Список | pgsql-general |
On 7/25/06, Kenneth Downs <ken@secdat.com> wrote: > craigp wrote: > > >1) does it make sense (and would it be possible) to make a rule which would, > >say, somehow write into the oid field of a tuple to be returned by lastoid? i'm > >assuming here that the database would not have oid's enabled. > > > > > > > We do this in a trigger. We assign the NEXTVAL to a variable, write > that to the row, then raise its value as a notice. Then we just > retrieve the notice. another way to to this is make a dynamic plpgsql function that takes an insert statement and sequence name as parameters and returns the currval on the way out. to the op I would suggest that you can inline currval into insert statements following the original insert e.g. insert into master default values; insert into detail(currval('master_id_seq'), foo, bar); merlin
В списке pgsql-general по дате отправления: