Navigation
Recent Posts
Archive
If you have a batch file set to run multiple SQLPlus queries and to then perform some other action such as merge the results together into a single file, or copy the files elsewhere you need to physically exit SQLPlus or the batch file will not continue to run and execute the commands.
To exit SQLPlus automatically skip a line after your last query and type exit as in
Tags:SQLPlus |Oracle |DOS |bat |batch file
To run multiple SQLPlus queries as part of a DOS batch file place all the queries in a separate SQL file. For Example
Save the file as runall.sql. Then use this file in your batch file
Tags:SQLPlus |bat |DOS |Oracle
You can use the result of a SQLPlus query as a variable in a windows batch file by spooling the output to a .bat file
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET WRAP OFF
SET LINESIZE 1000
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF
SPOOL c:cdr_count.bat;
select
'@echo off' from dual
UNION ALL
select
'SET CDR='||''||count(ddi) from cdrs where trunc(sysdate) = trunc(adj_start_time);
SPOOL OFF;
This creates or replaces a batch file and outputs
@echo off
SET CDR=643950
I am then able to call that batch file from within another batch file and use the SQL query result as it is defined as a variable.
call c:cdr_count.bat
IF %CDR% EQU 0 GOTO END
Tags:SQLPLus |Oracle |DOS |Batch files
© Eriginal Ltd 2011, all rights reserved