Append Leading Zero's
696393Feb 26 2010 — edited Apr 3 2012Hi ,
the follwing SQL generates Zero's prefixed to the rownum. While inserting the data into table all the zero's go away
why ?
How can i insert data with Zero's ?
<SQL>
select
(Case length(rownum)
when 1 then '0000'||rownum
when 2 then '000'||rownum
when 3 then '00'||rownum
when 4 then '0'||rownum
else
to_char(rownum)
END )
from
(
SELECT o.class_code d
FROM sun_oracle_schedule_backup@ougbs_ougbs.world o
Union
SELECT to_number(m.schedule_id,'99999') d
FROM sun_MYSQL_schedule_backup@ougbs_ougbs.world M
Union
SELECT o.class_code d
FROM sun_internal_schedule_backup@ougbs_ougbs.world o
)
<SQL>
Out put of the above query
-----------------------------------------------
00001
00002
00003
00004
00005
00006
00007
When used with INSERT statement the table has the values as
--------------------------------------------------------------------------------------
1
2
3
4
5
6
7
Where did the Zero's GO?????
the table column data type is Number......
Thanks
--- Raj