I have a.bat file which looks like this:
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?
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.
myfile1.sql:
select * from dept;
myfile2.sql:
select empno, ename, job, sal
from emp
where deptno = 10;
mypath1.sql:
@"myfile1"
@"myfile2"
exit;
mybat.bat:
sqlplus scott/tiger@orcl@mypath1.sql > mylog.txt
-----------
this redirects output into mylog.txt file
Running the mybat.bat
at the command prompt:
C:\>mybat
C:\>sqlplus scott/tiger@orcl@mypath1.sql 1>mylog.txt
There's no output to screen; everything is contained in mylog.txt
file so - let's check it:
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:\>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.