2011-03-08 81 views
2

当我假脱机多选select查询输出到一个txt文件。每次选择查询后,我都会看到空白的新行,我该如何摆脱它。Oracle假脱机设置

define spool_file = 'D:\test1' 

--set serveroutput on; 

SET ECHO OFF 

SET NEWPAGE 0 

SET SPACE 0 

SET PAGESIZE 0 

SET FEEDBACK OFF 

SET HEADING OFF 


-- set echo on ; 

spool D:\test1; 

select 'H,correction.csv,' || to_char(sysdate,'DD/MM/YYYY') from dual; 

select 'D,' ||record_id  from cl_record where status=15; 

select 'T,correction.csv,' from cl_record where status=15; 

spool off; 

回答

1

尝试TRIMSPOOL

SET FEEDBACK OFF 
SET HEADING OFF 
SET TRIMSPOOL ON 

我改变你的脚本

define spool_file = '/home/alain/test.log' 
--set serveroutput on; 
SET ECHO OFF 
SET NEWPAGE 0 
SET SPACE 0 
SET PAGESIZE 0 
SET FEEDBACK OFF 
SET HEADING OFF 
SET trimspool on 
--set echo on ; 
spool /home/alain/test.log; 
select sysdate from dual; 
select 'hello ' || 'world' from dual; 
spool off; 

产量为

$ cat test.log 
SQL> select sysdate from dual; 
03-08-2011 07:48:26 
SQL> select 'hello ' || 'world' from dual; 
hello world 
SQL> spool off; 
+0

非常感谢。它不接受SET trimspool on命令。不知道为什么会这样。另外我不想要显示的SQL> select查询 – Arav 2011-03-09 03:30:55