Skip to end of metadata
Go to start of metadata

Overview

When an error occurrs in DBMS, An exception handler can handle exception.

The basic procedure for handling exception of ALTIBASE HDB is identical to ORACLE.

It includes declaring, raising exceptions. and so forth.

Exception

Exceptions can be divided into two categories.

For further information on the following exceptions, we recommend you to read the subdivided pages.

  • System-defined exceptions
  • User-defined exceptions

System-defined Exception

This exception is a predefined by the ALTIBASE HDB.

  • General erros which can occur during the execution of the stored procedures.
  • No need to declare name in the DECLARE section.

User-defined Exception

This exception is arbitraily defined by user.

  • This exception can be specified and defined by user.
  • This exception can be specified and defined in the DECLARE section.
  • This exception can be ocurred using a RAISE statement.
  • This exception can be processed in the EXCEPTION Handler.

Example

ORACLE

ALTIBASE HDB

Comments

DECLARE
name employees.e_lastname%TYPE;
v_code NUMBER;
v_errm VARCHAR2(64);
BEGIN
SELECT e_lastname INTO name FROM employees WHERE eno = 1;
EXCEPTION
WHEN OTHERS THEN
v_code := SQLCODE;
v_errm := SUBSTR(SQLERRM, 1 , 64);
DBMS_OUTPUT.PUT_LINE('Error code ' || v_code || ': ' || v_errm);
-- Normally we would call another procedure, declared with PRAGMA
-- AUTONOMOUS_TRANSACTION, to insert information about errors.
INSERT INTO errors VALUES (v_code, v_errm, SYSTIMESTAMP);
END;
/

CREATE OR REPLACE PROCEDURE PROC1
AS
name employees.e_lastname%TYPE;
v_code NUMBER;
v_errm VARCHAR2(64);
BEGIN
SELECT e_lastname INTO name FROM employees WHERE eno = 1;
EXCEPTION
WHEN OTHERS THEN
v_code := SQLCODE;
v_errm := SUBSTR(SQLERRM, 1 , 64);
PRINTLN('Error code ' || v_code || ': ' || v_errm);
-- Normally we would call another procedure, declared with PRAGMA
-- AUTONOMOUS_TRANSACTION, to insert information about errors.
INSERT INTO errors VALUES (v_code, v_errm, SYSTIMESTAMP);
END;
/

Basic usages of exception handling are almost same
between the ALTIBASE HDB and ORACLE.

  • No labels