Re: A question regarding WHENEVER
Posted in 1996
In article <571e3e$he6@cssun.mathcs.emory.edu>, Marco Greco <marcog@ctonline.it> writes >Stuart, >If you have 4Gl compiled, you can easily get answers to questions like this >by having a look at the c code produced by c4gl. > Correct >In any case, WHENEVER is just a compiler directive, so it only affects code >physically placed after it in the same module, and not code from other >modules being executed after it (am I clear ?!? :-) >so your WHENEVER ERROR STOP will only be effective for any function >following your func1. > Correct. >Also, note that > >- it makes a difference whether you place it at the end of a function or at >the beginning of the next: in the first case, if you hit error -1318 >(parameter count mismatch), the program will (ahem...) gracefully terminate, >in the second you are very likely to get a core dump > Correct. >- even though it's a directive, you can only put WHENEVER within procedural >code. So there's no way to prevent the entry code of the first function in a >module from terminating the program in case of a -1318 error (JL, I'm ready >to be corrected by you, here :-). Correct, again - I'd never thought or this..amazing what you miss. Peter Breuton mentioned the use of WHENEVER ANYERROR. This only applies in 4GL version 6.x. It means significance of WHENEVER ANYERROR <action> IN VERSION 6 means that non-SQL errors E.g. Character to numeric conversion errors also cause the <action> to be taken. In 4GL verison 6.x WHEWNEVER ERROR <action> only causes action to be taken when an SQL error occurs. In order allow people to easily port code from version 4 of the 4GL to version 6 Informix added a new flag to the c4gl command. This is the -anyerr flag. NOTE: The -anyerr option MUST be the FIRST paramater to c4gl. i.e. Use c4gl -anyerr.... In the usage statement generated when you just type c4gl the -anyerr option is listed as the first parameter...perhaps the ordering of parameters to c4gl has now become important. Note c4gl will not give any errors if the -anyerr option appears later in the command, it just means the option is ignored!!! -- David Williams