Re: scope of WHENEVER statement
Posted in 2000
Topics: General Discussion
---- you wrote: > If I have a WHENEVER statement somewhere else than in main(), will it not > catch SQL errors in main()? Will it catch all SQL errors in functions (in > functions...) called by the function in which it was defined? The WHENEVER statement has nothing to do with logic flow Dude. It is a compiler switch that is picked up at compile time only. So if your WHENEVER was the last one found in the lines of code before your function, then that will be the condition in effect for that function. But this is regardless of function boundaries in your source file. AB ---------------------------------------------------------------- Get your free email from AltaVista at http://altavista.iname.com
a_blonde@mindless.com wrote in message <85cur3$jn3$1@news.xmission.com>...
>The WHENEVER statement has nothing to do with logic flow Dude. It is a
compiler switch that is
WHENEVER can be changed at runtime, so it does have "scope"...
example:
main
whenever error call error_handler
...
call xyz()
...
end main
function xyz()
whenever error continue
create table newtable
(
some char(10),
more char(20)
)
whenever error call error_handler
end function
Steve
--
Steven L Cooper
Manager, Systems Engineering
---------------------------------------
Please reply to NG only, so others may be enlightened...
The views expressed here are mine and
you can't have them...unless you agree!
a_blonde@mindless.com wrote in message <85cur3$jn3$1@news.xmission.com>...
>
> ---- you wrote:
>> If I have a WHENEVER statement somewhere else than in main(), will it not
>> catch SQL errors in main()? Will it catch all SQL errors in functions (in
>> functions...) called by the function in which it was defined?
>
>The WHENEVER statement has nothing to do with logic flow Dude. It is a
compiler switch that is picked up at compile time only. So if your WHENEVER
was the last one found in the lines of code before your function, then that
will be the condition in effect for that function. But this is regardless of
function boundaries in your source file.
>
>AB
>----------------------------------------------------------------
>Get your free email from AltaVista at http://altavista.iname.com
>
Whenever is essentially a compiler directive. from the INFIRMIX-4GL manual
page 3-280
"Using whenever is equivalent to including code after every SQL stmnt.....
to take the specified action if the exceptional condition is detected."
From page 3-281
"The scope of WHENEVER stmnt is from its location in a program block until
the next WHENEVER stmnt .... in the same module, ..... the WHENEVER stmnt
remains in effect...... until the end of the module."
You can of course set different WHENEVER error actions for each function if
you wish, as in Steve's example. It is not however being changed at run
time, the error checking code added by the compiler is different for
function xyz because of the placement of the WHENEVER stmnts.
Mmm, you can see why I'm a programmer and not an English teacher eh! ;o))
The big question is how do you indent the whenever stmnts in your code when
they can span function definitions?
HTH
---------------------------------------
Tony Flaherty aef@mfs.misys.co.uk
Analyst Programmer
Misys Financial Systems
All statements and opinions are my own,
Misys don't pay me enough to have opinions
on their behalf
.
Steven L Cooper wrote in message ...
>a_blonde@mindless.com wrote in message <85cur3$jn3$1@news.xmission.com>...
>>The WHENEVER statement has nothing to do with logic flow Dude. It is a
>compiler switch that is
>
>WHENEVER can be changed at runtime, so it does have "scope"...
>
>example:
>main
> whenever error call error_handler
>...
> call xyz()
>...
>end main
>
>function xyz()
> whenever error continue
> create table newtable
> (
> some char(10),
> more char(20)
> )
> whenever error call error_handler
>end function>
>Steve
>--
>Steven L Cooper
>Manager, Systems Engineering
>---------------------------------------
>Please reply to NG only, so others may be enlightened...
>The views expressed here are mine and
>you can't have them...unless you agree!
>
>a_blonde@mindless.com wrote in message <85cur3$jn3$1@news.xmission.com>...
>>
>> ---- you wrote:
>>> If I have a WHENEVER statement somewhere else than in main(), will it
not
>>> catch SQL errors in main()? Will it catch all SQL errors in functions
(in
>>> functions...) called by the function in which it was defined?
>>
>>The WHENEVER statement has nothing to do with logic flow Dude. It is a
>compiler switch that is picked up at compile time only. So if your WHENEVER
>was the last one found in the lines of code before your function, then that
>will be the condition in effect for that function. But this is regardless
of
>function boundaries in your source file.
>>
>>AB
>>----------------------------------------------------------------
>>Get your free email from AltaVista at http://altavista.iname.com
>>
>
>
Tony Flaherty wrote: > -------- cut --------------- > > Mmm, you can see why I'm a programmer and not an English teacher eh! ;o)) > > The big question is how do you indent the whenever stmnts in your code when > they can span function definitions? > > HTH Here is where an English teacher could show you a few tricks ;-). -- Compliments of QueriX -------------------------------------------------------------------------------------------------- QueriX 4GL Compilers are Informix 4GL Compatible, and Connection to other RDBMS such as Oracle. Hydra 4GL Compiler Compile once, run everywhere Phoenix Windows GUI. Chimera Java GUI The only GUI you will ever need... Arachne Web Technology For more details visit: http://www.querix.com/ ---------------------------------------------------------------------------------------------------