[英]SQLCL console print to file instead of stdout
I have a.bat file which looks like this:我有一个 .bat 文件,它看起来像这样:
start C:\sqlcl-latest\sqlcl\bin\sql javi/pwd@tnsname @"mypath1"
The script it calls looks like this:它调用的脚本如下所示:
select 1 from dual;
select 2 from dual;
exit;
Is there any way to log everything in the cmd and the sqlcl console into a file instead/in addition to being printed in stdout?有没有办法将 cmd 和 sqlcl 控制台中的所有内容记录到一个文件中,而不是/除了在标准输出中打印?
I have tried the below, but it creates an empty log file:我试过下面的方法,但它创建了一个空的日志文件:
start C:\sqlcl-latest\sqlcl\bin\sql javi/pwd@tnsname @"mypath1" > mylog.txt
I don't have SQLCL, but this ( redirection to file ) should (at least, I hope so) work at operating system command prompt.我没有 SQLCL,但是这个(重定向到文件)应该(至少,我希望如此)在操作系统命令提示符下工作。
myfile1.sql:我的文件 1.sql:
select * from dept;
myfile2.sql:我的文件 2.sql:
select empno, ename, job, sal
from emp
where deptno = 10;
mypath1.sql:我的路径1.sql:
@"myfile1"
@"myfile2"
exit;
mybat.bat:我的蝙蝠.bat:
sqlplus scott/tiger@orcl@mypath1.sql > mylog.txt
-----------
this redirects output into mylog.txt file
Running the mybat.bat
at the command prompt:在命令提示符下运行
mybat.bat
:
C:\>mybat
C:\>sqlplus scott/tiger@orcl@mypath1.sql 1>mylog.txt
There's no output to screen;没有要筛选的output; everything is contained in
mylog.txt
file so - let's check it:一切都包含在
mylog.txt
文件中 - 让我们检查一下:
C:\>type mylog.txt
SQL*Plus: Release 18.0.0.0.0 - Production on Čet Sij 19 08:18:58 2023
Version 18.5.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Active code page: 1250
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
EMPNO ENAME JOB SAL
---------- ---------- --------- ----------
7782 CLARK MANAGER 2450
7839 KING PRESIDENT 5000
7934 MILLER CLERK 1300
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
C:\>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.