我有一个 SQL 脚本,它将数据假脱机到一个文件中。现有 SQL 脚本示例:
whenever sqlerror exit failure rollback
spool test.txt
set serveroutput on
select * from emp;
spool off
/
但是,我想在假脱机数据之前在这个脚本中编写一个 SQL 查询。我不想硬编码假脱机文件的名称,那么如何从表或查找中获取文件名?
我希望代码类似于
var filename varchar2(30);
select fname into :filename from table where script = 'abcscript';
spool :filename
set serveroutput on
select * from emp;
spool off
/
谢谢。