? Nextval increments even if the insert after this fails [message #8523] |
Thu, 28 August 2003 06:04 |
Rolf Winterscheidt
Messages: 2 Registered: August 2003
|
Junior Member |
|
|
Hi,
I'm quite new in Oracle but know something more about MySQL. In MySQL I can assign an auto-increment to my IDs and everything works fine. But in Oracle it looks like I need to create my own nextvals. So I try this:
$dbh->do("insert into R_$table values (R_$table_SEQ.nextval, '$variable')") || print "ERROR! $opt_c cannot insert $variable int
o $tablen";
So far so good. But in the case the insert fails the current nextval is lost. If I repeat this, I get more and more nextvals but no inserts. So I got a loop where my actual nextval is 1000000 but I have about 10 elements in it. Do I have to program my own routine to reset the nextval to currval if something goes wrong?
Rolf
|
|
|
|
Re: ? Nextval increments even if the insert after this fails [message #8531 is a reply to message #8525] |
Thu, 28 August 2003 09:38 |
Rolf Winterscheidt
Messages: 2 Registered: August 2003
|
Junior Member |
|
|
Thanks a lot, it's an interesting article.
Well, I don't have a real reason for the gap-free IDs, too. But if I have 100 Elements which are pointed to with IDs from 1 to 1000000 it just looks bad.
And the more important thing is that I always had to alter the table to number(x+1). I didn't thought I had to change is so many times :-). Maybe number(9) is enough for this.
Ok, I have realized that it's more a cosmetic design than a real problem with these high numbers.
I didn't know this from MySQL so I was surprised, but obviously it's normal :-).
Thank you,
Rolf
|
|
|