Converting integer column from XXXXXN to XXXXXNN
Posted in 1996
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi,
We have to convert one of our table's integer column from
XXXXXN to XXXXXNN because we need to have 100 records for each
XXXXX instead of the 10 we use now.
XXXXX can be from 10000 to 99999.
N can be 0 to 9.
NN can be from 00 to 99.
Ex. From 444440 to 4444400
From 444449 to 4444409
We use Informix C-compiler (not RDS) version 5 and ISQL version
5 in a SCO computer.
I have already made up a 4gl program that basically does this (pls
excuse syntax errors)
# START PROGRAM
database our_db
globals define
a,b,c,d char[7],
e,f,g integer
end globals
main
declare x cursor for
select int_col from tab_name
where int_col >= 100000
# we still haven't decided yet what to do with records whose
# int_col is less than 100000 (10000 - 0)
foreach x into a
let d = a
let b = d[1,5]
let c = d[6,6]
let e = (b * 100) + c
update tab_name set int_col = e where int_col = a
end foreach
end main
# END PROGRAM
I have not run this program yet because I'm not sure if the update
would work, plus I think it's going to be slow. Is there another way
to make this work? Pls. email or post. Thanks!
John