Skip to content

The ability to declare exceptions in a package #9133

Description

@AlexBekhtin

Exceptions are part of PSQL code, but they are declared outside the package. Packages allow you to encapsulate code and exceptions without declaring exceptions in the schema. It will also be possible to use private exceptions.
Oracle declares exceptions exclusively in packages.

SET TERM ^;

CREATE PACKAGE P_TEST
AS
BEGIN
    PROCEDURE P1(I INT);
END^

CREATE PACKAGE BODY P_TEST
AS
BEGIN
    -- private exception
    EXCEPTION E_NOT_ZERO 'Parameter not allow zero value';

    PROCEDURE P1(I INT)
    AS
    BEGIN
        IF (I = 0) THEN EXCEPTION E_NOT_ZERO;
    END
END^

SET TERM ;^

CALL P_TEST.P1(0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions