On Aug 2, 2004, at 1:21 PM, Laurence Gellert wrote:
>> You have to know what the primary key value is before you can insert
>> the
> record.
>
> I won't know the next value until postgres assigns it though a
> mini-transaction it does during the insert. I just want it to be a
> unique
> number. Building a manual PK handler feels like reinventing the wheel,
> it
> runs slower, and has opportunity to loose database key integrity.
I know what you mean about this method not always being the best choice.
MySql offers autonumbers, and Oracle offers sequences, which one of my
clients uses to drive primary key gerenation for their data. Each time
I consider Cayenne, the activation energy gets me. The particularly
icky bit here is that Oracle sequences should be queried _before_ the
insert, while MySql ids should be queried after insert to find out what
you ended up with.
I need to port our code that selects from an Oracle sequence or from
the mysql table, but I just have not had the time. Someday.
NB - before MySql supported autonumbers, we used a table design very
similar to the AUTO_PK_TABLE. It worked pretty well, but I am kind of
glad to have left it behind. From what I recall, though, the code was
not huge.
Sure would help me, though, if Cayenne offered a "grab from sequence or
autonumber" option for pks.
Scott
This archive was generated by hypermail 2.0.0 : Mon Aug 02 2004 - 17:16:19 EDT