On Sep 8, 6:46 am, Will Gorman <[email protected]> wrote: > Is it possible to get an autoincremented primary key from a sequence when > inserting with Oracle for an existing table that wasn't created with Sequel? > From what I can see from the code and based on this thread > (https://groups.google.com/d/topic/sequel-talk/fDYJABDjqDU/discussion) it > looks like it relies on creating a trigger to get the next sequence value on > an insert. Is that the only way that's currently supported?
Probably. If you have a sequence without a trigger that requires you get the next sequence value before the insert, I don't think Sequel handles that automatically. For models, you can easily use a before_create hook to do so. I'm definitely willing to accept patches in this area. I don't have access to an Oracle installation, so improvements would probably have to be contributed by others. Looking at the shared oracle adapter, it looks like the returned sequence value is not reliable if multiple connections are accessing the database at the same time. I can think of ways to fix this, but they require some changes, and without access to Oracle or someone willing to test the changes, I don't feel comfortable making the changes. Basically, the Dataset :sequence option needs to be passed to Database#execute_insert from Dataset#execute_insert, and the sequence handling should be done inside Database#execute_insert. Another complicating factor is that such insert handling code has to be added to every adapter that supports Oracle (though some code could likely be shared). Currently the oracle adapter and the jdbc oracle subadapter both support Oracle, so at the very least, both of those will need modifications and testing. Supporting other types of sequence use is possible after that change is made. We could add other Dataset options like :sequence_first or something which Database#execute_insert can check for and get a new sequence value before insert if set. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
