TRY ... EXCEPT
Syntax
TRY statements EXCEPT exceptionBlock END
where statements is a sequence of statements (delimited by semicolons) and exceptionBlock is another sequence of statements.
Description
A TRY...EXCEPT statement executes the statements in the initial statements list. If no exceptions are raised, the exception block (exceptionBlock) is ignored and the control passes on to the next part of the IBEBlock.
If an exception is raised during execution of the initial statements list, the control passes to the first statement in the exceptionBlock. Here you can handle any exceptions which may occur using the following functions:
- function ibec_err_Message() - returns an exception message.
- function ibec_err_SQLCode() - returns the SQLCode of an exception if there was an SQL error.
- function ibec_err_Name() - returns an exception name (for exceptions raised with
EXCEPTION
statement; see below).
You can also re-raise an exception using the RAISE statement.
Example
execute ibeblock as begin try -- Attempt to insert into non-existent table insert into missing_table (f1) values (1); ibec_ShowMessage('There were no errors...'); except ErrSQLCode = ibec_err_SQLCode(); if (ErrSQLCode = -204) then ibec_ShowMessage(ibec_err_Message()); else raise; end end
See also:
TRY ... FINALLY
EXCEPTION
Exception-handling Functions
back to top of page
<< TRY ... FINALLY | IBEBlock | EXCEPTION >>