| Programs / Program registers | |
STATUS is a predefined variable that contains the execution status of the last instruction.
STATUS
STATUS is a predefined variable that contains the execution status of the last program instruction.
STATUS allows to get diagnostic of procedural, interactive, and SQL instructions.
The data type of STATUS is INTEGER.
STATUS is typically used with WHENEVER ERROR CONTINUE or WHENEVER ERROR CALL, or TRY/CATCH blocks, to identify the type of error that occurred.
STATUS will be set for expression evaluation errors only when WHENEVER ANY ERROR is used.
After an SQL statement execution, STATUS contains the value of SQLCA.SQLCODE.
WHENEVER ERROR CONTINUE DELETE FROM _invalid_table_name_ where col = 1 WHENEVER ERROR STOP DISPLAY "STATUS:", STATUS -- this DISPLAY instruction reset STATUS to zero IF STATUS<0 THEN -- Will never be the case, since STATUS==0 DISPLAY "SQL Error!" EXIT PROGRAM 1 END IF
MAIN
DISPLAY is_number(NULL)
DISPLAY is_number("abc")
DISPLAY is_number("-12.45")
END MAIN
FUNCTION is_number(s)
DEFINE s STRING
DEFINE f FLOAT, l_status INTEGER
IF length(s)==0 THEN
RETURN FALSE
END IF
WHENEVER ANY ERROR CONTINUE
LET STATUS=0 # Needed, as STATUS won't be set if succeeds
LET f = s
LET l_status = STATUS
WHENEVER ANY ERROR CONTINUE
IF l_status == 0 THEN
RETURN TRUE
ELSE
RETURN FALSE
END IF
END FUNCTION