Oracle - 输出格式不正确

时间:2009-07-30 15:47:37

标签: oracle format

我在sqlplus中设置了以下参数来显示我的视图输出放在unix框中,但它在两个记录之间显示一个行差距。我不希望两个记录之间有一个行间隔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"," "

请帮助我实现上述输出。

2 个答案:

答案 0 :(得分:2)

我相信你的问题是你的lineize设置为125,但你的输出是187个字符(无论如何对于第一行)。当sqlplus包装你的行时,它会在那里放置额外的空间,让你知道一个包裹的行结束而另一行开始的位置。

要么将行大小更改为大于125的行(个人,我总是在我的脚本中将行大小设置为5000 - 我可以自己创建包装,谢谢你,sqlplus),或者通过sed运行结果来删除空白:

cat myResultFile.txt | sed '/^$/d' > newResultFile.txt

答案 1 :(得分:0)

您可能已启用记录分隔:

SET RECSEP EACH

尝试:

SET RECSEP OFF