From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Kenneth Downs" <ken(at)secdat(dot)com> |
Cc: | craigp <craigp98072(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: sequences vs oids as primary keys |
Date: | 2006-07-26 13:54:40 |
Message-ID: | b42b73150607260654t52545014x884cf74388ae01f4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 7/25/06, Kenneth Downs <ken(at)secdat(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Kenneth Downs | 2006-07-26 14:50:39 | Re: loop with circular updates |
Previous Message | Tom Kinard | 2006-07-26 13:50:24 | Database Restore errors |