Code Listing 1: The assert procedure

1  CREATE OR REPLACE PROCEDURE assert (
 2     condition_in IN BOOLEAN,
 3     message_in IN VARCHAR2,
 4     raise_exception_in IN BOOLEAN := TRUE,
 5     exception_in IN VARCHAR2

 6           := 'VALUE_ERROR'
 7  )
 8  IS
 9  BEGIN
10     IF    NOT condition_in
11        OR condition_in IS NULL

12     THEN
13        DBMS_OUTPUT.PUT_LINE ('Assertion Failure!');
14        DBMS_OUTPUT.PUT_LINE (message_in);
15
16        IF raise_exception_in
17        THEN
18           EXECUTE IMMEDIATE

19             'BEGIN RAISE ' || exception_in || '; END;';
20        END IF;
21     END IF;
22* END assert;