假脱机测试.sql:
SPOOL test.log
CLEAR SCREEN
SET VERIFY OFF
PROMPT Queries will appear in spool
select sys_context('USERENV', 'INSTANCE_NAME') from dual;
PROMPT Output from the HOST command will not
HOST ECHO %COMPUTERNAME%
SPOOL OFF
sqlplus 输出:
Queries will appear in spool
SYS_CONTEXT('USERENV','INSTANCE_NAME')
---------------------------------------------------
wibble
Output from the HOST command will not
AWESOMESERVERNAME
SQL>
测试日志:
Queries will appear in spool
SYS_CONTEXT('USERENV','INSTANCE_NAME')
--------------------------------------------------------------------------------
wibble
Output from the HOST command will not
如果无法捕获 HOST 输出,有人可以提出解决方法。
是的,spool 只捕获 SQLPlus 本身的输出。试试这个 - 在调用你的操作系统命令之前,关闭假脱机。然后将输出通过管道传输到文件末尾。然后你可以使用 spool append 从你离开的地方再次开始假脱机: