I use to execute on a remote .bat machine that calls SQL * Plus and executes the script. Only the result is written in the log, in the form of a message, so much strings are involved, or if an error occurred, then the error code.
.bat text:
set nls_lang = american_america.cl8mswin1251
Call Sqlplus SYS / PASS @ TNSALIAS AS SYSDBA @ RESTARTQUEUESSSTEM.SQL & GT; Restartquesessystem.log
Pause
EXIT.
Where:
restartquesessystem.sql
This is a file with a scriptrestartquesessystem.log
file containing execution log, which writes SQL * Plus itself
How can I configure log entry into SQL * Plus or upgrade the script so that the execution result is written in the log?
For example:
In restartquesessystem.sql
recorded Select * from table;
.
Then in restartquesessystem.log
I want to see not only execution notification, but also the result of the query select * from table;
.
Answer 1, Authority 100%
Use SQL * Plus User’s Guide and reference .
Many teams described in GL. 12 SQL * Plus Command Reference Serve to control output when executing SQL offers in the script.
working example for starts
Example.Bat:
set nls_lang = american_america.cl8mswin1251
SQLPLUS -S -L User / Pass @ DBServer: 1521 / Service @ example.sql & gt; example.log.
Pause
example.sql:
Whenever SQLERROR EXIT FAILURE ROLLBACK
Set Feedback On Timing ON
Prompt.
Prompt ## Creating Table ...
CREATE TABLE ITEMS AS
SELECT ROWNUM ID, 'ITEM' || ROWNUM Item
from xmltable ('1 to 3')
RUN
Prompt.
Prompt ## Updating Table ...
Update Items Set Item = Item || '**'
WHERE ID = 2
RUN.
Prompt.
Prompt ## Querying Table ...
SELECT *
From Items.
RUN
Prompt.
Prompt ## Droping Table ...
Drop Table Items.
RUN
EXIT.
When starting from CMD terminal:
& gt; Example.Bat.
The following log file containing commands and results of their execution will be created:
## Creating Table ...
1 CREATE TABLE ITEMS AS
2 SELECT ROWNUM ID, 'ITEM' || ROWNUM ITEM
3 * from xmlTable ('1 to 3')
Table Created.
Elapsed: 00: 00: 00.33
## Updating Table ...
1 Update Items SET Item = Item || '**'
2 * WHERE ID = 2
1 Row Updated.
Elapsed: 00: 00: 00.02
## Querying Table ...
1 SELECT *
2 * from Items
ID Item.
---------- -------------------------------------------- -----
1 Item 1.
2 Item 2 **
3 Item 3.
3 rows selected.
Elapsed: 00: 00: 00.01
## Droping Table ...
1 * Drop Table Items
Table dropped.
Elapsed: 00: 00: 00.27