Name

asboolean — Provides a type hint to the containing element that it is expecting a boolean value.

Syntax

asboolean(expr)
              

The ASBOOLEAN function has the following arguments:

expr

The child expression that is expected to return a boolean data type value.

Description

This function provides a type hint to the child expression that a boolean data type value is expected. If the expression does not provide a boolean valued result then an error will be raised.

This function is required in situations where the data type of the enclosed expression can not determined by the parser at compile time. This is typically due to an expression that is evaluated at runtime to determine a column from a data table, such as with the column, eval, tablelist, tablemap or tablerange functions. The type hint provided by the ASBOOLEAN function is then used for the semantic analysis required to complete the expression compilation.

No conversion of the data value returned by the child expression is attempted, and if the child data type does not match the hint an error will be generated. For type hinting with data conversion see the boolean function.

Examples

See the example Table range lookup with a non-literal value in the tablerange function for details about how type hints are used.