Oracle PL/SQL - PL SQL Statement Error Directives

Introduction

An error directive produces a user-defined error message during compilation.

Syntax

$ERROR varchar2_static_expression $END 

It produces the following compile-time error message, where string is the value of varchar2_static_expression:

PLS-00179: $ERROR: string 

Demo

SQL>
SQL> BEGIN-- from  w w w.  j a  v a  2 s.c o  m
  2   $IF DBMS_DB_VERSION.VER_LE_10_1 $THEN         
  3     $ERROR 'unsupported database release' $END  
  4   $ELSE
  5     DBMS_OUTPUT.PUT_LINE ('Release ' || DBMS_DB_VERSION.VERSION || '.' ||DBMS_DB_VERSION.RELEASE || ' is supported.');
  6   COMMIT WRITE IMMEDIATE NOWAIT;
  7   $END                                        
  8  END;
  9  /
Release 11.2 is supported.

PL/SQL procedure successfully completed.

SQL>
SQL>

Related Topic