![]() |
![]() |
![]() |
Oracle - SQL 'insert' Question Hi:
New to DB
Does the primary key column is an autonumber column ?
Milton
In Oracle, you want to use a sequence in the Insert statement.
will
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:
Stress
Milton, have you ever actually USED Oracle?
HeWhoMustBeConfused
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.
ko
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.
T. Norman
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.
T. Norman
"The OP doesn't mention the database but seq.nextval generally means oracle."
anon
ko:
HeWhoMustBeConfused
HeWhoMustBeConfused: my bad. i skip the titles, just read the comment. My apologies to you and all.
ko
ko: Mine too ... too many pre-Christmas beers makes for grumpy typing ... *grin*
HeWhoMustBeConfused
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.
ko
|