Gustav Brock wrote:
> 
> Hi Gonzalo
> 
> >> "Do not" is stronger than "don't"
> >> - actually very close to "you must not".
> 
> > Yep, I know... that's the reason of my doubt.. why must i 
> avoid specifying
> > values on a DEFAULT SERIAL? what's the disadvantage? or 
> what problems could
> > it cause to do so...? am i breaking the number generator in any way?
> > For example, if a have the following:
> > Table: TABLE1
> > Columns:
> >     ID INTEGER DEFAULT SERIAL 1,
> >     VAL VARCHAR(10)
> 
> > I insert 3 values ('a', 'b', 'c') and the number generator 
> assigns the ID 1,
> > 2 and 3 to them. Later, i insert a new value 'd' but i 
> specify ID = 4. The
> > next time i insert a value without specifying the ID, which 
> number will it
> > get? 5? or ill get a Duplicated primary key when it tries 
> to assign 4?
> 
> Well ... just don't specify that ID.
> 
> I don't know if SAP DB chokes if you do - why not make a quick test?

And that test shows that 5 will be used taking the highest value
user_specified or calculated internally for the serial column, adding 1
and using this new value.

--> If you want to make the number generator do its duty you have
specified it for, do not specify values by your own for the serial column.
And if you specify for a very specific reason assure that the value
is higher than the last value used by the number generator, but not too
high as the numbers between the last used value and that high user_specified
value are lost, not used in the future.

Elke
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to