ALLBASE/SQL Reference Manual (36216-90216)

474 Chapter11
SQL Statements E - R
RAISE ERROR
RAISE ERROR
The RAISE ERROR statement causes an error to occur and causes the given error number to
be put into the ALLBASE/SQL message buffer, together with the given error text. This
statement is most useful within procedures invoked by rules, to cause the rule to fail and
the statement firing the rule to have no effect. The effect of RAISE ERROR is to return with
an error status; this statement can never "execute successfully."
Scope
ISQL or Application Programs
SQL Syntax
RAISE ERROR [
ErrorNumber
][MESSAGE
ErrorText
]
Parameters
ErrorNumber
specifies the number of the error being raised. This can be any integer
value.
ErrorNumber
has the following syntax:
{
Integer
:HostVariable
?
:LocalVariable
:ProcedureParameter
}
The data type of the parameter, host variable, or local variable must be
INTEGER or SMALLINT. The data type expected for the dynamic
parameter is INTEGER.
If no
ErrorNumber
is given, 2350 is the default error number. The error
range 7000 - 7999 is reserved for the RAISE ERROR statement. No
ALLBASE/SQL errors are in this range.
Parameters and local variables may only be used within procedures. Host
variables may only be used within embedded SQL. Dynamic parameters
may only be used within dynamic SQL.
ErrorText
specifies text to be returned with the error.
ErrorText
has the following
syntax:
{
‘CharacterString’
:HostVariable
?
:LocalVariable
:ProcedureParameter
}
The data type of the parameter, host, or local variable must be CHAR or
VARCHAR. The data type expected for the dynamic parameter is
CHAR(250). The value will be truncated to 250 bytes.
If no
ErrorText
is given, the default is an empty string.