Hello,
I have a SELECT query(pasted below) that I use to output a file. The users now want the total number of checks and sum of checs outputted at the end of the file with labels. I thought dbms_output.put_line would work but it gives me an error. Please help !
SET FEEDBACK off
SET HEADING off
SET TERM off
SET VERIFY off
SET ECHO OFF
SET TRIMSPOOL OFF
set linesize 140
col col2 format 140
col col3 format 140
col col1 format 140
SPOOL C:\output.txt
select '01' || '000' || '1234512345' ||
rpad(substr(a.check_number, 2, 10) || ' ', 10) ||
rpad(to_char(a.check_date, 'yyyymmdd') || ' ', 8)||
rpad(lpad(trunc(a.check_amt * 100, 0), 11, '0') || ' ', 11)||
rpad(' ',15) ||
decode(a.check_recon_status, 'V', 'V',' ')||
rpad(' ',80) as col1
from table a, table b
where a.tran_id = b.tran_id
Union
select '01' || '000' || '1234512345' ||
lpad(count(a.check_number),10,0)||
rpad(to_char(a.check_date, 'yyyymmdd') || ' ', 8) ||
rpad(lpad(trunc(sum(a.check_amt) * 100, 0), 11, '0') || ' ', 107) as col2
from table a, table b
where a.tran_id = b.tran_id
group by a.check_date
Union
select '01' || '000' || '1234512345' ||
lpad(count(a.check_number),10,0)||
rpad(to_char(a.check_date, 'yyyymmdd') || ' ', 8) ||
rpad(lpad(trunc(sum(a.check_amt) * 100, 0), 11, '0') || ' ', 107) as col3
from table a, table b
where a.tran_id = b.tran_id
group by a.check_date;
dbms_output.put_line('Number of Checks = '||lpad(count(a.check_number),10,0);
SPOOL off
SET PAGESIZE 14
SET TERM on
SET VERIFY on
SET FEEDBACK on
SET HEADING on
exit
Thanks.
I have a SELECT query(pasted below) that I use to output a file. The users now want the total number of checks and sum of checs outputted at the end of the file with labels. I thought dbms_output.put_line would work but it gives me an error. Please help !
SET FEEDBACK off
SET HEADING off
SET TERM off
SET VERIFY off
SET ECHO OFF
SET TRIMSPOOL OFF
set linesize 140
col col2 format 140
col col3 format 140
col col1 format 140
SPOOL C:\output.txt
select '01' || '000' || '1234512345' ||
rpad(substr(a.check_number, 2, 10) || ' ', 10) ||
rpad(to_char(a.check_date, 'yyyymmdd') || ' ', 8)||
rpad(lpad(trunc(a.check_amt * 100, 0), 11, '0') || ' ', 11)||
rpad(' ',15) ||
decode(a.check_recon_status, 'V', 'V',' ')||
rpad(' ',80) as col1
from table a, table b
where a.tran_id = b.tran_id
Union
select '01' || '000' || '1234512345' ||
lpad(count(a.check_number),10,0)||
rpad(to_char(a.check_date, 'yyyymmdd') || ' ', 8) ||
rpad(lpad(trunc(sum(a.check_amt) * 100, 0), 11, '0') || ' ', 107) as col2
from table a, table b
where a.tran_id = b.tran_id
group by a.check_date
Union
select '01' || '000' || '1234512345' ||
lpad(count(a.check_number),10,0)||
rpad(to_char(a.check_date, 'yyyymmdd') || ' ', 8) ||
rpad(lpad(trunc(sum(a.check_amt) * 100, 0), 11, '0') || ' ', 107) as col3
from table a, table b
where a.tran_id = b.tran_id
group by a.check_date;
dbms_output.put_line('Number of Checks = '||lpad(count(a.check_number),10,0);
SPOOL off
SET PAGESIZE 14
SET TERM on
SET VERIFY on
SET FEEDBACK on
SET HEADING on
exit
Thanks.