如何创建oracle sql脚本假脱机文件
我有一个关于假脱机程序结果的问题。我的示例 sql 脚本如下所示。
whenever sqlerror exit failure rollback
set heading off
set arraysize 1
set newpage 0
set pages 0
set feedback off
set echo off
set verify off
declare
ab varchar2(10) := 'Raj';
cd varchar2(10);
a number := 10;
c number;
d number;
begin
c := a+10;
select ab,c into cd,d from dual;
end;
SPOOL
select cd,d from dual;
SPOOL OFF
EXIT;
上面的脚本不起作用,但我想做这样的事情,在开始结束块中我们计算一些值,并且我想假脱机这些结果。
谢谢。
I have a question about spooling the the results of my program. My sample sql script looks like this.
whenever sqlerror exit failure rollback
set heading off
set arraysize 1
set newpage 0
set pages 0
set feedback off
set echo off
set verify off
declare
ab varchar2(10) := 'Raj';
cd varchar2(10);
a number := 10;
c number;
d number;
begin
c := a+10;
select ab,c into cd,d from dual;
end;
SPOOL
select cd,d from dual;
SPOOL OFF
EXIT;
The above script does not work, but I want to do something like this where in the begin end block we compute some values and i want to spool those results.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这会将匿名块的输出假脱机到名为
output_.txt
的文件中,该文件位于本地 PC C: 驱动器的根目录中,其中
是当前日期:希望它有帮助...
编辑:
在您发表评论后,为游标的每次迭代输出一个值(我意识到在这个示例中每个值都是相同的,但您应该了解我的要点 正在做):
This will spool the output from the anonymous block into a file called
output_<YYYYMMDD>.txt
located in the root of the local PC C: drive where<YYYYMMDD>
is the current date:Hope it helps...
EDIT:
After your comment to output a value for every iteration of a cursor (I realise each value will be the same in this example but you should get the gist of what i'm doing):
带线轴:
With spool:
从
BEGIN
END
块进行假脱机非常简单。例如,如果您需要将两个表的结果假脱机到一个文件中,则只需使用for 循环
。下面给出示例代码。To spool from a
BEGIN
END
block is pretty simple. For example if you need to spool result from two tables into a file, then just use thefor loop
. Sample code is given below.为了在plsql中执行spool文件
转到文件->新建->命令窗口->粘贴您的代码->执行。进入该目录,您将找到该文件。
In order to execute a spool file in plsql
Go to File->New->command window -> paste your code-> execute. Got to the directory and u will find the file.