RE: Whenever related Query!
Posted in 1999
The whenever clause has been called before the open statement. I expected the whenever to catch all negative errors. The idea was to localize all (negative) error trapping to my error_func() any ideas? > ---------- > From: Jonathan Leffler[SMTP:jleffler@earthlink.net] > Reply To: jleffler@earthlink.net > Sent: Tuesday, March 09, 1999 11:06 PM > To: informix-list@iiug.org > Subject: Re: Whenever related Query! > > PINTOR@valuerx.com wrote: > > The whenever error call func_x() statement calls func_x() whenever a > > negative sqlcode error occurs. > > > > I have a situation where a database remote connection fails after > > a certain period of time. The next open statement fails and this > > returns a -936 sql error. > > > > Q.Why did the whenever error function not call func_x(). This was a > > negative error???? > > Most probably because the function where the OPEN fails does not > have WHENEVER ERROR CALL func_x in effect. The WHENEVER statement > looks like an executable statement, and can only be placed where > executable statements can appear, but it is nevertheless a compiler > directive. Consequently, unless your code definitely includes the > WHENEVER ERROR CALL func_x before the OPEN, it will not not call the > error function. > > Also, most SQL statements can fail for odd reasons such as this, so > most SQL statements should be protected with WHENEVER ERROR CONTINUE > before the statement, and a WHENEVER ERROR STOP (or CALL func_x) after > the statement, with some error detecting code in the program. > > -- > Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) > Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN > #include <disclaimer.h> >