TO_BOOLEAN()

Scalar. Converts a given string to a Boolean value

Syntax

TO_BOOLEAN( value )
Parameter

value

The value to convert. The strings "True" and "Yes", regardless of case, or the numeral "1" returns True. NULL returns NULL. Any other string returns False.

Data Types

Return

value

Boolean

String

Boolean

Examples

The following examples return a Boolean based on the input string:

INSERT INTO OutStream
SELECT TO_BOOLEAN('FALSE') --returns FALSE
FROM InStream;
INSERT INTO OutStream
SELECT TO_BOOLEAN('TRUE') --returns TRUE
FROM InStream;
INSERT INTO OutStream
SELECT TO_BOOLEAN( LEFT( LTRIM(' false status'), 5 ) ); 
   --returns FALSE
FROM InStream;