Question: I'm trying to pad a query with leading
zeros. The query is
SELECT PAD(CAST(NVL(CL.ALT_NUM,0)AS
VARCHAR2(15)),15,'0') from dual.
Whenever the output length is less than 15 digit, i want the zero's to
be padded in left to make it as 15 digit. When i run the query in
oracle database i get the 15 digit where as when the shell script is run
and an excel is created I don't get the leading Zero's.
Answer (By Laurent Schneider): A
workaround to force keeping the leading 0 is to use a formula instead of
a static string.
CODE
SQL> select to_char(deptno,'FM000000000000000') deptno
from dept;
DEPTNO
----------------
000000000000010
000000000000020
000000000000030
000000000000040
DEPTNO
10
20
30
40
CODE
SQL> select '="'||to_char(deptno,'FM000000000000000')||'"'
deptno from dept;
DEPTNO
-------------------
="000000000000010"
="000000000000020"
="000000000000030"
="000000000000040"
DEPTNO
000000000000010
000000000000020
000000000000030
000000000000040