Navigation
Recent Posts
Archive
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
Posted in: Business
Tags: SQLPLus | Oracle | DOS | Batch files
© Eriginal Ltd 2011, all rights reserved