On 1/25/06, John Siracusa <[EMAIL PROTECTED]> wrote: > On 1/25/06, Todd Hepler <[EMAIL PROTECTED]> wrote: > > John Siracusa wrote: > >> Either way, after the insert, I'll need a way to get the value that was > >> used--and do so in a concurrency-safe way. What's The Oracle Way to do > >> that? > > > > In my experience, it's best way is to select the nextval from the > > sequence before doing the insert, and then providing that value to the > > insert statement. > > That's what I do for Pg, but that approach seems incompatible with the > trigger-based approach described earlier, which will overwrite that > value with a new one on insert.
You could do it in two statements, but the trigger allows the column to behave as close to AUTO_INCREMENT as possible. > > I would recommend, on the first pass at least, to not worry about BEFORE > > INSERT triggers. Just get: > > > > select <SEQUENCE_NAME>.nextval from dual; > > > > working before the insert statement, where SEQUENCE_NAME is specified by > > the user. > > Yeah, that sounds the simplest. But if the trigger-based approach is > really common, we're not doing Oracle users any favors by punting on > this... It's the approach that several different Oracle DBAs have given me, plus it's recommended in their manual. > (BTW, anyone know why dual is named dual?) No clue. :-) Rob ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642 _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object