Conditional Expressions

A conditional expression in a SQL Script is anything that resolves to a boolean value.

Syntax

The syntax for a conditional expression is identical to what you can use as a WHERE clause, except that instead of using column names you use variable names in a conditional expression.

Remarks

Cursor variables can be used in a conditional expression only with the keyword IS NULL or IS NOT NULL. Cursor variables cannot be used in other conditional expressions, although attributes of cursor variables can be used. See DECLARE CURSOR of Type Variable, for information on declaring cursor variables, and Attributes of Cursors, for information on cursor attributes.
A boolean variable or literal can be used as a condition. See Literal Values, for information on declaring literals.
The keyword CURRENT_EXCEPTION cannot be used in a conditional expression by itself, although attributes of it can be used. For details, see Attributes of CURRENT_EXCEPTION.

Errors

The following table describes the errors that can occur while resolving a conditional expression.

Error Message

Cause

Undefined variable

An identifier is encountered that is not defined in the current scope.

Incorrect use of a cursor

A cursor is used in a conditional expression with something other than IS NULL or IS NOT NULL.

Incorrect use of CURRENT_EXCEPTION

The keyword CURRENT_EXCEPTION is used in a conditional expression.