Bat command running db task (script)

Rem How to run
Rem the 3rd arg for the bat will be the data file name pattern
Rem the 2nd args for the bat is the DATE

@ECHO off
SET “configfile=C:\Batch\scripts\dbconnx.daz”
SET “ClientPath=C:\Oracle\product\11.2.0\client_1\BIN”

IF NOT EXIST %configfile% GOTO ExitLogInError

REM IF NOT EXIST %datafile% GOTO ExitError

SET /p connstr= <%configfile%
%ClientPath%\sqlplus %connstr% @C:\Batch\scripts\Db_task.sql

IF %ERRORLEVEL% gtr 0 GOTO Exit_failure

:Exit_Success

SET ERRORLEVEL=0
ECHO “Success!
GOTO Exit_last

:Exit_failure

SET ERRORLEVEL=3
ECHO “Failure”
Exit 3

:ExitLogInError
ECHO config File %configfile% does not exist
EXIT 1

:Exit_last

ECHO “Exit code is %ERRORLEVEL% for this run”

—-

set serveroutput on;
EXEC SCHEMA_NAME.PKG_NAME.SP_NAME;
exit;

Leave a Reply

Your email address will not be published. Required fields are marked *