如何从 Oracle CSV 导出中删除注释行?
我使用 spool 命令将数据从 Oracle 数据库导出到 csv 文件,如下所示:
set heading off
set linesize 1000
set long 1000
set pagesize 0
set echo off
set verify off
spool D:\OVERNIGHT\TEMP_FILES\SE_NEW_PFRA_CRYSTAL_OUTPUT.txt
SELECT
TRIM(FU_BAN) ||'|'||
TRIM(CASE_ID) ||'|'||
TRIM(case when fu_type is null then 'unknown' else fu_type end) ||'|'||
TO_CHAR(FU_OPEN_DATE,'DD/MM/YYYY') ||'|'||
TO_CHAR(FU_DUE_DATE,'DD/MM/YYYY') ||'|'||
TO_CHAR(FU_LATEST_DATE,'DD/MM/YYYY') ||'|'||
TRIM(X_CASE2X_BUS_ORG) ||'|'||
TRIM(TOPIC1) ||'|'||
TRIM(TOPIC2) ||'|'||
TRIM(TOPIC3)||'|'||
TRIM(FU_OPENED_BY1) ||'|'||
TRIM(FU_ASSIGNED1_TO) ||'|'||
TRIM(CASE_STATE2CONDITION) ||'|'||
TRIM(FU_STATUS) ||'|'||
TRIM(FU_OPENED_BY) ||'|'||
TRIM(FU_ASSIGNED_TO)
FROM SE_PFRA_REPORT_WRK T1;
SPOOL OFF
EXIT;
数据已导出,但底部有一个行,然后是一行,说明选择了 xxxx 行。
如何设置脚本使其不导出这些行?
预先感谢您的帮助。
史蒂夫
I am exporting data from an Oracle database to csv file using the spool command as follows:
set heading off
set linesize 1000
set long 1000
set pagesize 0
set echo off
set verify off
spool D:\OVERNIGHT\TEMP_FILES\SE_NEW_PFRA_CRYSTAL_OUTPUT.txt
SELECT
TRIM(FU_BAN) ||'|'||
TRIM(CASE_ID) ||'|'||
TRIM(case when fu_type is null then 'unknown' else fu_type end) ||'|'||
TO_CHAR(FU_OPEN_DATE,'DD/MM/YYYY') ||'|'||
TO_CHAR(FU_DUE_DATE,'DD/MM/YYYY') ||'|'||
TO_CHAR(FU_LATEST_DATE,'DD/MM/YYYY') ||'|'||
TRIM(X_CASE2X_BUS_ORG) ||'|'||
TRIM(TOPIC1) ||'|'||
TRIM(TOPIC2) ||'|'||
TRIM(TOPIC3)||'|'||
TRIM(FU_OPENED_BY1) ||'|'||
TRIM(FU_ASSIGNED1_TO) ||'|'||
TRIM(CASE_STATE2CONDITION) ||'|'||
TRIM(FU_STATUS) ||'|'||
TRIM(FU_OPENED_BY) ||'|'||
TRIM(FU_ASSIGNED_TO)
FROM SE_PFRA_REPORT_WRK T1;
SPOOL OFF
EXIT;
The data is exported but at the bottom there is a linesace then a line stating xxxx rows selected.
How can I set the script so it doesn't export these lines?
Thanks in advance for your help.
Steve
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是您正在寻找的命令。
完整示例在这里... http://www.jlcomp.demon.co.uk /faq/flatfile.html
is the command you are looking for.
Full example here... http://www.jlcomp.demon.co.uk/faq/flatfile.html
刚刚找到答案。
对于那些不知道的人,我添加了该行
,这清除了有问题的行。
Just found the answer.
For thos who don't know I added the line
and this cleared the offending lines.
除了(已经提到且正确的)
设置反馈关闭
之外,您可能还需要设置 Trimspool 开启
。这将切断最后一个空格之后的行。如果没有它,假脱机的每一行最终都会有 1000 个字符宽度(如
set linesize
中设置)。In addition to the (already mentioned and correct)
set feedback off
you might also want toset trimspool on
.This will cuts lines after the last space. Without it, every line spooled would end up with 1000 characters width (as set in
set linesize
).