On 6/7/07 3:04 AM, Cees Hek wrote: > On 6/7/07, Neal Clark <[EMAIL PROTECTED]> wrote: >> Thank you for the prompt reply. I am not entirely sure I understood >> it, and I probably didn't give the right details when I mailed the >> list earlier today. If I change my id column from serial to integer >> it will not, to put it in mysql terms, auto_increment. > > I think what John meant was mark the column as an integer in your > Rose::DB class, but leave it as a serial in the database.
Exactly. >> Also, I do not understand why Rose::DB goes to the trouble of getting tangled >> up in the serial sequence when a value 'DEFAULT' for the id to the statement >> handler would do the same thing. > > Usually this is done so that the code knows exactly what the primary > key for the row is going to be. If you just insert using DEFAULT, > then you usually have to make an extra call to the DB to retrieve the > record again to find out what id was assigned to the row Right, that's why RDBO pre-allocates the serial value. I believe the Pg call to "get me the last value pulled from this sequence in this session" is also a safe way to do it, but I'm not 100% sure. Pre-allocating is 100% safe in that, if the insert succeeds, I know for sure what value it used, with no worries about race conditions. -John ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object