-
Hi all,
How do you keep leading zeros in a number(6) field? I need the leading zeros to be stored. I have the folwoing code :
UPDATE my_emp
SET SSN = LPAD(emp_no,3,0)||9999;
The script runs fine except the leading zeros are truncated because of the datatype. Is there a way to keep the leading zeros?
Thanks,
-
SQL> select to_char(123, '099999') from dual;
TO_CHAR
-------
000123
SQL> col a format 0999999;
SQL> select 123 a from dual;
A
--------
0000123
-
Hi Leonard,
I don't think there is any way of storing leading zeros in number datatype in the database. While retrieving it however you can do so by using the format Shestakov specified. I would prefer keeping the field as a char/varchar2 type!
Thanks,
-Shyami
-
Why need keep leading zeros, usually need only show this zeros in screen forms or
print its in document.