Leading Zeroes
Posted in 1999
Topics: Data Types & Schema Design
In an INSERT INTO SELECT... statement I would like to have it put an integer into a varchar field but padded with leading zeros. For example if the integer field has a value of 3 it should be inserted as '000003'. Is there some function that will do this in Informix. Thanks in advance, Rob D.
In article <7tavag$b93$1@cougar.golden.net>, Rob Drummond
<robdSPAMBEGONE@golden.net> writes
>In an INSERT INTO SELECT... statement I would like to have it put an integer
>into a varchar field but padded with leading zeros. For example if the
>integer field has a value of 3 it should be inserted as '000003'. Is there
>some function that will do this in Informix.
>
Which Informix version? If 7 then try
NOTE: I havn't check the syntax of this!
USE DBACCESS NOT ISQL TO CREATE!!!
USE DBACCESS NOT ISQL TO CREATE!!!
USE DBACCESS NOT ISQL TO CREATE!!!
create procedure padit( coldata char(50),len int)
define str char(50)
let str = "&&&&&&&&&&&&&&&&&&&&&&&";
let str = str[1,len];
let coldata = coldata using str;
return coldata;
end procedure;
then
insert into select padit(mycol,6),....
will give mycol as "000006"
>Thanks in advance,
>
>Rob D.
>
>
--
David Williams