Syntax for the IF-THEN-ELSE Command Construct

This section provides the syntax for the IF-THEN-ELSE construct. For more details on using the IF-THEN-ELSE command construct, see Using the IF-THEN-ELSE Command Construct Within ttIsql in the Oracle TimesTen In-Memory Database Operations Guide.

IF [NOT] 
   { Literal1 | :BindVariable1 } 
   { =  | IN } 
   { Literal2 | :BindVariable2 | SelectStatement } 
 THEN "ThenCommands" 
 [ ELSE "ElseCommands" ] ;

The ttIsql IF-THEN-ELSE command has the parameters:

Parameter Description

IF

The IF command must end in a semicolon (;).

The IF command fails if improper syntax is given, the BindVariables do not exist or the SELECT statement fails to run or does not return just a single column.

NOT

Using NOT reverses the desired result of the condition.

Literal1, Literal2

A value that can be part of a comparison.

BindVariable1, BindVariable2

A bind variable is equivalent to a parameter. You can use the :BindVariable1 notation for passing bind variables into this construct. The variable can be created and set using the variable or setvariable ttIsql commands.

= | IN

You can use the IN operator only with the SelectStatement. You can use the IN operator with zero or more returned rows. You can use the equal (=) operator only with a single returned row.

SelectStatement

A provided SELECT statement must start with SELECT. The SELECT statement can return only one column. In addition, it can return only one row when the equal (=) operator is provided.

The SelectStatement is not available if you are not connected to the database.

ThenCommands, ElseCommands

All commands in the THEN or ELSE clauses must be delimited by a semicolon and cannot contain embedded double quotes. These clauses can conditionally run ttIsql commands, such as host or run, which cannot be run through PL/SQL. You can use the CALL statement within the THEN or ELSE clauses. You cannot use PL/SQL blocks.

Restrictions for the IF-THEN-ELSE construct are as follows:

  • You cannot compare variables of the LOB data type.

  • The values are compared case-sensitive with strcmp. A character padded value might not match a VARCHAR2 because of the padding.