Oracle - SQL 'insert' Question
New to DB
Does the primary key column is an autonumber column ?
In Oracle, you want to use a sequence in the Insert statement.
If you're sure an Oracle sequence is used to generate the primary key for this table, then yes, use seq.nextval in your insert statement. For example:
Milton, have you ever actually USED Oracle?
HeWhoMustBeConfused: Milton is answering the question for SQL Server for which his advice is correct. The OP doesn't mention the database but seq.nextval generally means oracle. If you've never used oracle, you probably wouldn't know that and it could be pseudocode stuff. Don't blast someone just because they are answering the question based on their exp.
Do you mind if there are gaps in the 1..N? Using sequence.nextval is likely to produce gaps, because rollbacks will not backtrack the sequence.
Actually it won't be locking errors that you'll get, it would be a unique key violation. Locking errors would occur on simultaneous inserts only if you used a separate table to hold the value of N, which you updated after every insert.
"The OP doesn't mention the database but seq.nextval generally means oracle."
HeWhoMustBeConfused: my bad. i skip the titles, just read the comment. My apologies to you and all.
ko: Mine too ... too many pre-Christmas beers makes for grumpy typing ... *grin*
just curious... how do you skip the title? don' tyou have to click on it to read the thread???
yes, but it's only in short term memory as a link, not as a title and in my mind, not really related to the content. And often i find in this forum, the title is only covered by the first or second poster and then everyone moves on to other things.
Fog Creek Home