Product Documentation

FairCom ISQL

Previous Topic

Next Topic

Work Flow Control

ISQL provides support for controlling the flow of execution in ISQL by means of the IF_EXISTS / IF_NOT_EXISTS keyword.

IF_EXISTS / IF_NOT_EXISTS imposes conditions on the execution of a single SQL statement or ISQL command or a block of SQL statements and ISQL commands. The SQL statement/statement block following an IF_EXISTS keyword and its condition is executed if the condition is satisfied, i.e., if the SELECT query returns at least one record.

The optional ELSE keyword introduces an alternate SQL statement or a block of SQL statements that is executed when the IF_EXISTS condition is not satisfied i.e., if the SELECT query returns no record. IF_NOT_EXISTS is just the reverse of IF_EXISTS, i.e., the SQL statement/statement block following an IF_NOT_EXISTS keyword and its condition is executed if the condition is not satisfied, i.e., if the SELECT query returns no record.

IF_EXISTS / IF_NOT_EXISTS controls can be nested. There is no limit to the number of nested levels.

If the select query in the condition returns an error due to any reason, the error is returned and none of the conditional blocks is executed.

TOCIndex