[英]Generate the output in same spool in Oracle
SPOOL c:\out.SPL
SELECT * FROM a WHERE ACCOUNT_NUMBER='&CRN' ;
SELECT * FROM b WHERE ACCOUNT_NUMBER='&CRN' ;
Spool off
accept op prompt 'Do u want to generate el spool,type y ' default 'n'
SAVE c:\query2.SQL
select * from getm_liab where liab_no='a' ;
column c me new_value x
set termout off
select decode(lower('&op'),'y','C:\query2.SQL','n', 'null') c from dual;
spool c:\out.SPL APPEND
@&x
The above script is I run set of queries first and I will run remaining set of queries only when user types y. 上面的脚本是我首先运行查询集,并且仅当用户键入y时,我才会运行其余查询集。 But it is not working please suggest
但这不起作用,请建议
content of q1.sql: q1.sql的内容:
accept op prompt 'Do u want to generate el spool,type y ' default 'n'
column c new_value x
set veri off
set echo off
set head off
spool qyn.sql
select decode(lower('&op'),'y','@','n', '--')||'q2' from dual;
spool off
@qyn '&1'
content of q2.sql: q2.sql的内容:
select 'boe' from dual where dummy = '&1';
select 'oops' from dual where dummy = '&1';
sqlplus foo/far@orcl @q1 X output with Y: sqlplus foo / far @ orcl @ q1 X输出Y:
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jun 26 15:00:13 2014
Copyright (c) 1982, 2012, Oracle. All rights reserved.
Verbonden met:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Do u want to generate el spool,type y y
@q2
boe
oops
output with N: N输出:
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jun 26 15:00:54 2014
Copyright (c) 1982, 2012, Oracle. All rights reserved.
Verbonden met:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Do u want to generate el spool,type y n
--q2
This is one of the ways to handle this. 这是处理此问题的方法之一。 Easiest is to use the positional variables but you can also define them as named variables.
最简单的方法是使用位置变量,但您也可以将它们定义为命名变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.