Hello,
when using a serial column in a table, if i drop some of the last data lines inserted, can i fixe the value of the coming serials of this column? (not let a gap between the new and the existing lines in the serial columns).
Thks.
Hi,
This works to let the next serial numbers to begin with 1000 if there is no one greater than 1000.
for example if i have :
serial_num
-------
1
2
3
2500
ALTER TABLE my_table MODIFY (serial_num serial (1000))
would not affect the next coming serial_num (it will be 2501).
Any way this may help!
what i 've done is that i 've unloaded data and droped the table, then re-created the table and loaded again data.
this worked. But with Informix SE many times we could have duplicated serial numbers which is not normal! and that cause a problem to reloas the data.
You can use the MODIFY clause to reset the next value of a SERIAL or SERIAL8 column. You cannot set the next value below the current maximum value in the column because that action can cause the database server to generate duplicate numbers. You can set the next value, however, to any value higher than the current maximum, which creates a gap in the series of values. If the new serial value that you specify is less than the current maximum value in the serial column, the maximum value is not altered.
Do you know, that it is allowed to insert a fixed value into a serial column? Maybe this is of help:
example:
given the following serials are in your table
1
2
3
2000
It's TRUE.
So i can create a function for eliminating the gap :
-it inserts a calculated identifier if there is an empty place.
-if not, it uses the regular insert.
LIKE this :
select max(serial_num) into max0 from mytable where serial_num < (select max(serial_num) from mytable) ;
select max(serial_num) into max1 from mytable;
if max0 < max1 then
inserts (max0)
else
inserts (0)
end if
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.