If the executing event is the only instance of this event, what will be the value of NumActive will it be 0 (excluding the current instance) or 1 (including the current instance)? By the way I have seen code like this:
Is it necessary to cast the value? |
The value will be '1' in this case. The event_parameter function always returns a string, so you need to cast it when comparing with an integer. so coding it like this will fail?: IF EVENT_PARAMETER( 'NumActive' ) = 1 THEN 2
@Martin: In your proposed statement the numeric 1 will be automatically cast to the string '1' and if EVENT_PARAMETER('NumActive') returns '1' then you will end up with the behaviour that you wanted. 2
There is a small correction to the above. The comparison domain between a string and any exact numeric is NUMERIC (see a slightly dated whitepaper I wrote for version 9.0):
Given this, technically the CAST to integer is not required because the same semantics are used without the cast. However, mixed domain comparisons are subtle and is a best practice to use CAST to make the code clearer. There is a further consideration when using a cast in that it constrains the string to really be an integer an not NUMERIC value:
(02 Apr '11, 15:29)
Ivan T. Bowman
Replies hidden
Comment Text Removed
I'm forced to join in Breck's sigh: "If Ivan had a blog..." - cf. http://sqlanywhere.blogspot.com/2009_04_01_archive.html.
(04 Apr '11, 03:18)
Volker Barth
Comment Text Removed
|