SQL/MX Remote Conversational Interface (RMXCI) Guide for SQL/MX Release 3.1 (H06.23+, J06.12+)

operator
is one of:
MeaningOperator
equal to== | =
not equal to<> | != | ~= | ^=
greater than>
greater than or equal to>=
less than<
less than or equal to<=
Action Parameter
The action parameter (action) is any RMXCI command or SQL/MX statement mentioned in this
manual.
SQL Terminator
The SQL terminator (SQL-terminator) is the default terminator (;) or a string value defined for
the statement terminator by the “SET SQLTERMINATOR command” (page 96). See “Setting and
showing the SQL terminator” (page 36).
Considerations
IF...THEN is itself an action. Thus, nested IF...THEN statements are allowed.
An action must end with the SQL terminator, even if the action is an interface command.
Examples
The following examples show different usage for IF...THEN statements:
SQL> INVOKE Employees;
SQL> -- ERROR 4082 means the table does not exist
SQL> IF ERRORCODE != 4082 THEN GOTO BeginPrepare;
SQL> CREATE TABLE Employees(SSN INT PRIMARY KEY NOT NULL NOT DROPPABLE, FName VARCHAR(50),
LName VARCHAR(50), HireDate DATE DEFAULT CURRENT_DATE);
SQL> LABEL BeginPrepare
SQL> PREPARE empSelect FROM
+> SELECT * FROM
+> Employees
+> WHERE SSN=?empSSN;
SQL> IF USER == alice THEN SET PARAM ?empSSN 987654321;
SQL> IF %USER == bob THEN SET PARAM ?empSSN 123456789;
SQL> execute empSelect;
SQL> IF USER == alice THEN
+> IF ACTIVITYCOUNT == 0 THEN GOTO insertAlice;
SQL> IF USER == bob THEN IF ACTIVITYCOUNT == 0 THEN GOTO insertBob;
SQL> EXIT
SQL> LABEL insertAlice
SQL> INSERT INTO Employees(SSN, FName, LName) VALUES(987654321, 'Alice', 'Smith');
SQL> EXIT
70 RMXCI commands