4GL Boolean Expressions

A 4GL Boolean expression is one that returns either TRUE (defined as 1) or FALSE (defined as 0) or NULL. The syntax of Boolean expressions in 4GL statements is not identical to that of Boolean conditions in SQL statements. Boolean expressions of INFORMIX-4GL have the following syntax:

4GLREF00000204.gif

Any type of expression can be a 4GL Boolean expression. You can use an INT or SMALLINT variable to store the returned value.

Boolean Comparisons

Boolean comparisons use relational operators to test any type of expression for equality or inequality. You can also use the IS NULL operator to test for NULL values, or the MATCHES or LIKE operator to compare character strings.

Boolean expressions in the CASE, IF, or WHILE statements, or in the WHERE clause of a COLOR attribute specification return FALSE if any element of the comparison is NULL, unless it is the operand of the IS NULL operator.

Relational Comparisons

This is the syntax for relational comparisons in 4GL Boolean expressions:

4GLREF00000205.gif

The LIKE and MATCHES Operators

In character string comparisons, you can use the LIKE or MATCHES operators to test whether a character value matches a quoted string that can include wild card characters. If either operand evaluates to NULL, then the entire string comparison evaluates to NULL. Use a NULL test if you want to detect and exclude NULL values.

You can use the following syntax to compare character strings:

4GLREF00000206.gif

char is a single ASCII character, enclosed between a pair of single ( ' ) or double ( " ) quotation marks, to specify an escape symbol.

criterion is a character expression. The string that it returns can include literal characters, wild cards, and other symbols.

The NULL Test

If any operand of a 4GL Boolean comparison or is NULL, then the value of the comparison is FALSE (rather than NULL), unless the IS NULL keywords are also included in the expression. Applying the NOT or IS NOT NULL operator to a NULL operand does not change its FALSE evaluation.

If you need to process NULL values in a different way from other values, you can use the IS NULL operator to test for NULL value. It has the syntax:

4GLREF00000207.gif

BLOB variable is the name of a variable of the BYTE or TEXT data type.

If you omit the NOT operator, the comparison returns TRUE if the left-hand operand has a NULL value.

If you include the NOT operator, this 4GL Boolean expression returns TRUE if the operand is not NULL. Otherwise, it evaluates as FALSE.

NOTE: The NULL test (like the WORDWRAP string operator with TEXT variables) is an exception to the general rule that variables of the BYTE or TEXT data types cannot appear in 4GL expressions.

Set Membership Test

The IN operator cannot appear in any 4GL statements that is not also an SQL statement, but it can appear in the COLOR attribute specification of a 4GL form. This is the syntax of the IN operator to test for set membership.

4GLREF00000208.gif

If you omit the NOT operator, this test returns TRUE if any expression in the comma-separated list at the right matches the expression on the left.

If you include the NOT operator, the test returns FALSE if no expression in the list matches the expression on the left.

The list of members must be in parentheses. (Like a DATETIME or INTERVAL literal, the IN operator requires parentheses but is not a function call.)