SQL Guide : solidDB® SQL statements : CREATE PROCEDURE : control_statement
  
control_statement
control_statement ::=
   SET variable_name = value | variable_name ::= value |
      WHILE expression
       LOOP procedure_statement... END LOOP |
       LEAVE |
     IF expression THEN procedure_statement ...
        [ ELSEIF procedure_statement ... THEN] ...
          ELSE procedure_statement ... END IF |
   RETURN | RETURN SQLERROR OF cursor_name | RETURN ROW |
RETURN NOROW
The following control statements are available in the procedures:
Control Statement
Description
set variable = expression
Assigns a value to a variable. The value can be either a literal value (for example, 10 or 'text') or another variable. Parameters are considered as normal variables.
variable ::= expression
Alternate syntax for assigning values to variables.
while
   expr
loop

   statement-list
end loop
Loops while expression is true.
leave
Leaves the innermost while loop and continues executing the procedure from the next statement after the keyword end loop.
if
   expr
then
   statement-list1
else
   statement-list2
end if
Executes statements-list1 if expression expr is true; otherwise, executes statement-list2.
if
   expr1
then
   statement-list1
elseif
   expr2
then

   statement-list2
end if
If expr1 is true, executes statement-list1. If expr2 is true, executes statement-list2. The statement can optionally contain multiple elseif statements and also an else statement.
return
Returns the current values of output parameters and exits the procedure. If a procedure has a return row statement, return behaves like return norow.
return sqlerror of cursor-name
Returns the sqlerror associated with the cursor and exits the procedure.
return row
Returns the current values of output parameters and continues execution of the procedure. Return row does not exit the procedure and return control to the caller.
return norow
Returns the end of the set and exits the procedure.
Note A procedure defined with the RETURNS clause returns always at least one row. This happens even if the row is NULL-filled.
To not return empty rows, use RETURN NOROW in the procedure body. It returns immediately without a result set (SQL_NO_DATA). The statement RETURN NOROW can be used after a sequence of RETURN ROW statements whereby the procedure returns the rows generated with RETURN ROW.
See also
CREATE PROCEDURE