In my korn shell - I have a sql with say 6 columns whose output i am redirecting to a file and attaching this file while sending a mail. While all this happens correctly, i face issues in the format of this file.
my intended output is
Column_1 Column_2 Column_3 Column_4 Column_5 Column_6
abcde John Hammer Club Cool Forever
cdfes Cathy Hello Wow Hot Obselete
But my outout is like
Column_1 Column_2 Colu Column_4 Column_5 Colu
abcde John Hammer Club Cool Forever
cdfes Cathy Hello Wow Hot Obselete
Note here the "Column_3" was cut down to "colu" and the again the "Column_6" was cut down to Colu.
Can someone please tell me how am i supposed to print the entire heading from my sql alias in my output file too.
Please always use code tag if you are posting code fragments or data samples.
You can do following in SQL:-
set echo off head off feed off pagesize 0 trimspool on linesize 1000
select 'Column_1 Column_2 Column_3 Column_4 Column_5 Column_6' from dual;
select Column_1,Column_2,Column_3,Column_4,Column_5,Column_6 from your_table;
Unless you show us what you did to produce the truncated output, we can't do anything but guess about what might cause what you're seeing. Please post your code (and use code tags).
Ok ill keep that in mind next time to use these code tags.
Please find my code here -
sqlplus -s / >$my_file <<EOF
set serveroutput on;
set pagesize 400;
set heading on;
set lines 10000;
set feedback off;
set linesize 10000;
set verify off;
spool $spooled_file
SELECT a.column_1 Column_1,
b.column_2 Column_2 ,
c.column_3 Column_3,
a.column_4 Column_4,
a.column_5 Column_5,
b.column_6 Column_6
FROM table_a a,
table_b b,
table_c c
WHERE a.p_id=b.p_id
AND b.c_id=c.f_id
spool off
exit sql.sqlcode
EOF
If i do that all the column headers are printed fully but the formatting between the column headers and the data is lost. The data doesnt fall correctly under the corresponding header.