Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Call SQL script from Windows .bat file with error checking **NEWBIE**
Thanks JP! I appreciate your assistance... I had seen something along
those lines in sample script I had pulled from somewhere, but I wanted to
make sure that it did what I wanted it to...
Thanks Again!!
Andy
"J.P." <jp_boileau_at_yahoo.com> wrote in message
news:7e388bc3.0206070616.52ba2818_at_posting.google.com...
> Piece of cake.
>
> Make sure your SQL script contains this line at the beginning:
>
> WHENEVER SQLERROR EXIT SQL.SQLCODE;
>
> Make sure it has a normal EXIT; at the end
>
> In your batch script, check for the error this way:
>
> IF ERRORLEVEL=(sql error code) (do something)
>
> JP
>
>
> "Andrew King" <kingster_1969_at_hotmail.com> wrote in message
news:<ufv66g7e7ta8c3_at_corp.supernews.com>...
> > I am currently trying to call a SQL*Plus script from a Windows batch
file.
> > I have figured it all out, except for one little piece - I need an error
> > code returned to the %errorlevel% environment variable if there is a
problem
> > in the execution of the script/stored proc.
> >
> > This is what I have so far in my batch file:
> >
> > set ORACLE_SID=edwm
> > set ORACLE_HOME=d:\oracle\ora81ee
> > D:
> > cd D:\ora\edwm\whs\sql
> > d:\oracle\ora81ee\bin\sqlplus username/password @whsverify.sql
> >
> > I have seen things in some scripts/stored procs that I have looked at
like
> > "whenever sqlerror exit SQL.SQLCODE". Will this do what I am looking
for?
> >
> > Thanks,
> >
> > Andy
Received on Fri Jun 07 2002 - 19:05:09 CDT
![]() |
![]() |