How do you keep leading zeros in a number(6) field? I need the leading zeros to be stored. I have the folwoing code :
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?
SQL> select to_char(123, '099999') from dual;
SQL> col a format 0999999;
SQL> select 123 a from dual;
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!
Why need keep leading zeros, usually need only show this zeros in screen forms or
print its in document.