Re: Return code from system function.
Posted in 1998
Topics: Stored Procedures & SPL, Server Administration
Paul Watson <watson@mcmail.com> '''''''' ' ''''''
<359BC5E8.F683434D@mcmail.com>...
> Ray O'Hagan wrote:
>
> > Hi,
> >
> > I'm running Informix 7.32 on Windows NT server 4.0, and
> > within a SP I'm executing a system command - but how
> > do I return the return code to my calling application.
> > I've tried the ON EXCEPTION and it didn't work e.g.
> >
> > CREATE PROCEDURE dummy(p_file char(35))> >
> > <defines removed>
> >
> > on exception set sql_err, isam_err, err_info
> >
> > return 1;
> >
> > end exception;
> >
> > system "c:\\bin\\runme.exe"
> >
> > return 0;
> >
> > END PROCEDURE;
> >
> > The command executes fine and returns a non-zero on
> > error, but the SP never gets the exception and hence
> > always returns 0 to me.
> >
> > Is this the right way to do this, or should I go
> > about it differently.
> >
> > TIA.
> >
> > Ray.
>
> system calls can not return parameters back to the SPL. If you really
> need to do it then pass it back via a table and get the calling program
> to check the table
>
> --
> Paul Watson #
> WF Software Ltd # I don't suffer from stress -
> Tel: +44 1436 674729 # I'm a carrier.
> Fax: +44 1436 678693 #
> www.wfsoftware.co.uk #
>
But next example is work (7.22 on SCO)
1) /u/informix/tst.sh - script
-------------------
let a=16
exit $a
-------------------
2). SQL
-------------------
CREATE PROCEDURE tst_proc () RETURNING INT; DEFINE dummy_ INT;
DEFINE res_ INT;
ON EXCEPTION IN (-668)
SET dummy_, res_
RETURN res_;
END EXCEPTION;
SYSTEM "/u/informix/tst.sh";
RETURN 0;
END PROCEDURE;
EXECUTE PROCEDURE tst_proc();-----------------
execute in dbaccess and returns -16
Roman Soudakov