on 06-02-2023 8:50 PM
Hello,
Running ASE 16 , we are reaching the max value for an integer datatype( 2,147,483,648) in a column used for unique identification, i.e a corraltive number .( each time a new row is inserted a new incremented value is added).
It's and old app , which does not use identity values for this matter.
So, which would be the best way to ovecame this matter , with the restiriction that the correlative numbers( int column) must be kept ?
We are thinking it to bcp out -in, create a new table with bigint. numeric(m,0) column.. ?
Any suggestions
Thank you!
Jose
Are these values also stored in other tables (eg, as foreign keys)?
Do you know if there are any large gaps of 'unused' numbers?
Can older records be purged/archived thus allowing you to 'wrap around' the number (ie, start over from +1)?
How easy (hard?) would it be for the application to switch to using negative values (this would allow for an additional 2+ billion values)? Could it be as easy as setting the 'next' number to -2,147,483,648 and then allow the current auto-increment (+1) start generating numbers until you get up to -5, -4, -3, -2, -1, 0 ... at which point you'd need to address the exhaustion of 4+ billion numbers (though hopefully this will be after you retire/move-on! 🙂
----------------
One option would be to convert the current column to an unsigned int (thus allowing you to increment up to 4+ billion). Since the int and unsigned int datatypes require the same 4 bytes it's as 'easy' as updating syscolumns to reference the new datatype.
Updating syscolumns consists of updating the type and usertype columns, keeping in mind these values are based on the datatype and NULLability of the column:
datatype NULLability type usertype
------------ ----------- ---- --------
int not NULL 56 7
unsigned int not NULL 66 45
int NULL 38 7
unsigned int NULL 68 45
The UPDATE statement would look like:
begin tran
update syscolumns
set type = case type when 56 then 66 when 38 then 68 else type end,
usertype = case usertype when 7 then 45 else usertype end
where id = object_id('table_name')
and name = 'column_name'
-- verify results before issuing 'commit tran'
NOTES:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another warning regarding manual update of system catalogue tables:
This is not a supported method - so if something goes wrong your are on your own. SAP Support will probably not be able to help you. Sometimes manual update of system catalog tables is the method of choice - if there is no good alternative. But in this case I rather suggest to create a new table with a larger data type (e.g. bigint) - you can then load all rows from the original to the new table. This is then completely supported.
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.