I need to output the results of a query to a fixed length flat file. My query is :
spool test.txt
select rpad(b.col1, 3)||
rpad(a.col2,5)||
rpad(substr(to_char(b.effective_date,'yyyy/mm/dd'),1,4),4)||
rpad(substr(to_char(b.effective_date,'yyyy/mm/dd'),6,2),2)||
rpad(substr(to_char(b.effective_date,'yyyy/mm/dd'),9,2),2)||
from table1 a, table2 b;
spool off
But if any of the columns is empty or null, the formatting goes awry. Is there any way, I can format the query to output to a fixed length flat file.
Thanks.
spool test.txt
select rpad(b.col1, 3)||
rpad(a.col2,5)||
rpad(substr(to_char(b.effective_date,'yyyy/mm/dd'),1,4),4)||
rpad(substr(to_char(b.effective_date,'yyyy/mm/dd'),6,2),2)||
rpad(substr(to_char(b.effective_date,'yyyy/mm/dd'),9,2),2)||
from table1 a, table2 b;
spool off
But if any of the columns is empty or null, the formatting goes awry. Is there any way, I can format the query to output to a fixed length flat file.
Thanks.