Neoview Command Interface (NCI) Guide (R2.4)

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 130). See “Setting
and Showing the SQL Terminator” (page 62).
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
These commands show multiple examples of 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
SQL> LABEL insertBob
SQL> INSERT INTO Employees(SSN, FName, LName) VALUES(123456789, 'Bob', 'Smith');
SQL> EXIT
LABEL Command
The LABEL command marks a point in the command history that you can jump to by using the
GOTO command. For more information, see the “GOTO Command” (page 100).
Syntax
LABEL {label}
label
is a string of characters without quotes and spaces, or a quoted string.
LABEL Command 103