This procedure is used to raise an exception having a user-defined error code and message.
The use of up to 1001 user-defined error codes, specifically the error codes ranging from 990000 to 991000, is supported in ALTIBASE HDB.
Whereas, the error number range used in ORACLE is a negative integer in the range -20000 .. -20999.
That way, you can report errors to your application and avoid returning unhandled exceptions.
Any specific differences between the ALTIBASE HDB and ORACLE are shown in this function.
Example
ORACLE
ALTIBASE HDB
Comments
CREATE OR REPLACE PROCEDURE PROC1
AS
num_tables NUMBER;
BEGIN SELECT COUNT() INTO num_tables FROM user_tables;
IF num_tables < 1000 THEN
/* Issue your own error code (user-defined exception) with your own error message.
Note that you do not need to qualify raise_application_error with
DBMS_STANDARD */
raise_application_error(-20101, 'Expecting at least 1000 tables');
ELSE
NULL; -- Do the rest of the processing (for the non-error case).
END IF;
END;
/
CREATE OR REPLACE PROCEDURE PROC1 -- altibase
AS
num_tables NUMBER;
BEGIN SELECT COUNT() INTO num_tables FROM system_.sys_tables_;
IF num_tables < 1000 THEN
/* Issue your own error code (user-defined exception) with your own error message.
Note that you do not need to qualify raise_application_error with
DBMS_STANDARD */
raise_application_error(990000, 'Expecting at least 1000 tables');
ELSE
NULL; -- Do the rest of the processing (for the non-error case).
END IF;
END;
/
The error number range which ALTIBASE HDB and ORACLE allow is
-20000 .. -20999(ORACLE) and 990000 to 991000(ALTIBASE HDB) respectively.