Re: How to get a return code from an host command in SQL*Plus ?

From: <manu_b_at_my-deja.com>
Date: 2000/05/16
Message-ID: <8frqh9$clb$1_at_nnrp1.deja.com>#1/1


Hello Maykeule,

If you are posting a question about Oracle, I must to try to reply something to help you.
At this time, the production database here are working fine. Just a little problem to be solved... After 6 month away, I can be back today. But your question is not easy for a newbie like me. First, why do you use Windaube ??
Well, perhaps your program could be encapsulted in a script like this : manu.bat :
start /I /WAIT yourprog.exe
if %ERRORLEVEL% LEQ 0 goto okay
echo exit > toto.sql
goto fin
:okay
 echo prompt continue ... > toto.sql
:fin

And, in your sql*plus session :
host manu.bat
_at_toto.sql

I hope that this can help you

A plus

Manu

In article <8errsg$17bh$1_at_news5.isdnet.net>,   "Michel Cadot" <micadot_at_netcourrier.com> wrote:
> Marc,
>
> Thanks for your answer.
> That's a good idea. I have to slighty modify it:
>
> SQL> var marc number
> SQL> !ls fhfhfhh; echo exec :marc := $? >marc.sql
> fhfhfhh not found
>
> SQL> _at_marc.sql
>
> PL/SQL procedure successfully completed.
>
> SQL> print marc
>
> MARC
> ----------
> 2
>
> This works well in Unix but actually i have to
> do that on NT and it seems that neither chaining
> the commands nor %errorlevel% (the same as $?) is
> recognized in SQL*Plus/NT:
>
> SQL>var marc number
> SQL>host dir ggggg.hhh; echo exec :marc := %errorlevel% >marc.sql
> Fichier introuvable
>
> SQL>host type marc.sql
> Le volume dans le lecteur C s'appelle PC20941
> Le numéro de série du volume est 7808-5A6A
>
> Répertoire de C:\
>
> Répertoire de C:\
>
> Répertoire de C:\
>
> Répertoire de C:\
>
> SQL>host echo %errorlevel% >tmp.txt
>
> SQL>host type tmp.txt
> Le fichier spécifié est introuvable.
>
> SQL>host type marc.sql; host type tmp.txt
>
> marc.sql
>
> Le volume dans le lecteur C s'appelle PC20941
> Le numéro de série du volume est 7808-5A6A
>
> Répertoire de C:\
>
> Répertoire de C:\
>
> Répertoire de C:\
>
> Répertoire de C:\
>
> Le fichier spécifié est introuvable.
> Une erreur est survenue lors du traitement de : host.
> Le fichier spécifié est introuvable.
> Une erreur est survenue lors du traitement de : type.
> Le fichier spécifié est introuvable.
> Une erreur est survenue lors du traitement de : tmp.txt.
>
> Can you or anyone else help me?
>
> --
> Regards
> Michel
>
> <marcpark_at_my-deja.com> a écrit dans le message :
 8epftt$574$1_at_nnrp1.deja.com...
> > Yes, it is possible to get the return code form a host command
> > An example in unix
> > variable marc number
> > !ls ajdadfaldjfl; echo select $? into marc from dual >
 marc_select.sql
> > !echo "/" >> marc_select.sql
> > _at_marc_select
> > Which would return 2 into the bind varaible marc.
> >
> > Then create a pl/sql script.
> > You look at the bind_variable and determine if to continue
> > or not.
> > declare
> >
> > begin
> > IF :marc = 0 THEN
> > update emp set ...
> > END IF
> > END;
> >
> > This is not trivial and would need more word to ensure it works,
> > but the general concept is there
> >
> > Marc Parkinson
> > Oracle Developer
> >
> >
> >
> > In article <8ep751$2vca$1_at_news4.isdnet.net>,
> > "Michel Cadot" <micadot_at_netcourrier.com> wrote:
> > >
> > > In a SQL*Plus script, i have to launch an host command,
> > > then test its return code and go on with the SQL script
> > > only if it is 0.
> > >
> > > How to get and test this return code?
> > >
> > > Example:
> > > SQL> select * from emp where ...;
> > > SQL> host myProg
> > > SQL> if myProg return code is not 0 exit <-- Can i do this and
 how?
> > > SQL> update emp set ...
> > >
> > > --
> > > Thanks
> > > Michel
> > >
> > >
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Tue May 16 2000 - 00:00:00 CEST

Original text of this message