When your request is completed, the analyzer will notice that the second use :"SOURCECHAR10" used in the place where an integer is expected. Therefore, it will always convert the contents: SOURCECHAR10 to an integer for this position, even if it is not used, if the string is not integer.
Actually, Firebird does not use :"SOURCECHAR10" as parameters, but does your connection library convert it into two separate fill parameters ? , and the type of the second placeholder will be INTEGER. Thus, the conversion occurs before the actual request is executed.
Perhaps this solution (I did not test it, could contain syntax errors) in order to use something like ( NOTE : see the second example for the correct solution):
CASE WHEN :"SOURCECHAR10" SIMILAR TO '[[:DIGIT:]]*' THEN CAST(:"SOURCECHAR10" AS INTEGER) ELSE 0 END
This does not work, since it is interpreted as a listing of the parameter itself, see the CAST () element "Field input fields"
If this does not work, you can also try adding an explicit cast to VARCHAR around :"SOURCECHAR10" to make sure the parameter is correctly identified as VARCHAR:
CASE WHEN :"SOURCECHAR10" SIMILAR TO '[[:DIGIT:]]*' THEN CAST(CAST(:"SOURCECHAR10" AS VARCHAR(10) AS INTEGER) ELSE 0 END
Here, the internal cast is applied to the parameter itself, the external cast is applied when the CASE expression evaluates to true
source share