Oracle - output not coming in right format
Question
I have set the below parameters in sqlplus to display my view out put on unix box,However it is displaying one line gap between two records.I don't want that one line gap between two records Ex-
set feedback off
SET NEWPAGE NONE
set HEADING Off
set pagesize 0
set linesize 125
SET TRIMSPOOL ON
set termout off
spool /export/home/43276826/Rep_Tran_oracle_$DATE_FILE.txt
select RecordID||','||C_S||','||P_R||','||AccountingDate||','||SettlementDate||','||Sec
Description||','||ISIN||','||MessageRef||','||Amount||','||Department||','||AssignedTo||','||LastUpdate||','||CashAmount||','
||CashAmountUSD||','||LastNoteText||','||LastNoteUser||','||CashCurrency||','||BIMASNumber||','||RelatedReference||','||Sende
rToRec||','||OpType||','||OriginalISIN from HSBC_ALL_OI_T;
201280,C,R,21.4.2009,21.4.2009,"HSBC HLDG","GB0005405286","00001/20090421-1006851",188.00
0000,"TITBB/F"," ",22.4.2009,0.00,,"NOTHING GENEVA","ADK"," ","GB411161","SF-0357690"," ","FR"," "
"201279,C,P,21.4.2009,21.4.2009,"HSBC HLDG","GB0005405286","00001/20090421-1401548",188.00
0000,"TITBB/F"," ",22.4.2009,0.00,,"NOTHING GENEVA","ADK"," ","GB411161","SF-0357689"," ","FD"," "
there is a gap of one line between two records,I don't want that one line gap.I want output in the below format:
201280,C,R,21.4.2009,21.4.2009,"HSBC HLDG","GB0005405286","00001/20090421-1006851",188.00
0000,"TITBB/F"," ",22.4.2009,0.00,,"NOTHING GENEVA","ADK"," ","GB411161","SF-0357690"," ","FR"," "
"201279,C,P,21.4.2009,21.4.2009,"HSBC HLDG","GB0005405286","00001/20090421-1401548",188.00
0000,"TITBB/F"," ",22.4.2009,0.00,,"NOTHING GENEVA","ADK"," ","GB411161","SF-0357689"," ","FD"," "
Please help me out in achieving the above output.
Solution
I believe your problem is that your linesize is set to 125, but your output is 187 characters (for the first line anyway). When sqlplus wraps your lines, it puts the extra space there to let you know where one wrapped line ends and the other begins.
Either change your line size to something greater than 125 (personally, I always set linesize to 5000 in my scripts - I can do my own wrapping, thank you, sqlplus), or run the results through sed to remove the blanks:
cat myResultFile.txt | sed '/^$/d' > newResultFile.txt
OTHER TIPS
You might have record separation turned on:
SET RECSEP EACH
Try:
SET RECSEP OFF