We had someone that was running something like the following then manually modifying the file when done. I want to get rid of manual processes like this. I rewrote this today but my script now writes the data to a file but the fields are not fixed length. How do I easily do that.
WHENEVER SQLERROR EXIT FAILURE ROLLBACK
set head off
set space 0
set feedback off
set pagesize 0
set echo off
set termout off
spool \\path\file_name.txt
set linesize 106
column id_no format a3
column alt_id format a9
column start_date format a8
column stop_date format a8
column tp_number format a15
column routing_data format a3
column partner_name format a60
SELECT UPPER(SUBSTR(valid_code, 1, 3)) id_no,
SUBSTR(UPPER(alt_id), 1, 9) alt_id,
TO_CHAR(start_date,'YYYYMMDD') start_date,
TO_CHAR(stop_date,'YYYYMMDD') stop_date,
UPPER(tp_number) tp_number,
SUBSTR(UPPER(routing_data_vc), 1, 3) routing_data,
UPPER(partner_name) partner_name
FROM prov.pro_partner_control pro,
del_valid_code del
WHERE del.valid_code_type = pro.company_vc
AND trunc(start_date) <= trunc(sysdate)
AND NVL(trunc(stop_date), '31-DEC-2099') >= trunc(sysdate)
ORDER BY id_no, alt_id, start_date, stop_date;
spool off
exit
WHENEVER SQLERROR EXIT FAILURE ROLLBACK
set head off
set space 0
set feedback off
set pagesize 0
set echo off
set termout off
spool \\path\file_name.txt
set linesize 106
column id_no format a3
column alt_id format a9
column start_date format a8
column stop_date format a8
column tp_number format a15
column routing_data format a3
column partner_name format a60
SELECT UPPER(SUBSTR(valid_code, 1, 3)) id_no,
SUBSTR(UPPER(alt_id), 1, 9) alt_id,
TO_CHAR(start_date,'YYYYMMDD') start_date,
TO_CHAR(stop_date,'YYYYMMDD') stop_date,
UPPER(tp_number) tp_number,
SUBSTR(UPPER(routing_data_vc), 1, 3) routing_data,
UPPER(partner_name) partner_name
FROM prov.pro_partner_control pro,
del_valid_code del
WHERE del.valid_code_type = pro.company_vc
AND trunc(start_date) <= trunc(sysdate)
AND NVL(trunc(stop_date), '31-DEC-2099') >= trunc(sysdate)
ORDER BY id_no, alt_id, start_date, stop_date;
spool off
exit