[Solar-talk] autoincrement vs sequence
stefan bogdan
stefan_bogdan_daniel at yahoo.com
Mon Dec 11 03:40:52 PST 2006
hi,
i saw that Solar use sequences even if the rdbms doesn't support this features.
i want to ask if we implement this thnk diffrent depending on database driver. so , in driver we introduce new property like pk_generator when you can specify the way pk is generated.
i guess using autoincrement field is more elegant solution, even to postgres or oracle. why? because in postrges you can put at default value the formula to generate the pk and in oracle you can make a trigger to generated. the only problem will be in firebird where , as far as i know ,sequences (generators) are not kept in session, but globaly.
of course implementing pk_generator is also helpful. the values for the new property should be 'autoincrement' and 'sequence'.
basically the nextSequence method should consider the pk_generator. if is set to 'autoincrement' in the insert statment the pk should not appear.
after insert automatically should be call last_insert_id( but not the pdo's one because not allways work) and get the new value inserted.
when pk_generator is set to 'sequence' we will keep the existing behaivour with one minor modification. the name of sequence should be kept as in postgres, because that way will be unique on database level. so the name of the sequence should be tablename_fieldname_seq.
what do you think?
bogdan
____________________________________________________________________________________
Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.com/unlimited
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.killersoft.com/pipermail/solar-talk/attachments/20061211/50d0ccb7/attachment.htm
More information about the solar-talk
mailing list