Gotcha! –function versus variable name
The gotcha below is for the TRUE function in QVW but is true of any function
QVW has a function named True() but also allows variables to exist with the same name in any case e.g. TRUE, true, True etc.
When intending to use the function always provide the parenthesis e.g. True ()
If you forget the parenthesis QVW will assume you had intended to use a variable named True (or whatever capitalization was used) and locate its value. If the variable did not exist, it will automatically be created with a value of NULL
Example1
Bad:
WHERE EXISTS (fieldname) = True ;
Good
WHERE EXISTS (fieldname) = True ();
Example2
Bad:
LOAD
IF ( EXISTS (fieldname, expression) = True, 'Yes', 'No')
etc
Good
LOAD
IF ( EXISTS (fieldname, expression) = True (), 'Yes', 'No')
etc
And for functions that either can return NULLs or functions or expressions that generate errors, which QVW returns a NULL to represent, this can be very confusing.
Note: Obviously in the Example1 above the EXISTS function does not need to be compared to a TRUE value. QVW will automatically do that in a WHERE clause
Gotcha! - Watch your parenthesis
Tip – Immediately after typing a function name always type the left and right parenthesis before putting any parameters or expressions in the parenthesis. This will help avoid either missing or mismatched parenthesis.
No comments:
Post a Comment