(转)oracle中关键字pragma解释

原文:http://blog.163.com/yuxiangtong0524@126/blog/static/800861632010420113611190/

PRAGMA是一个编译指示(或命令)。
======
编译指示在编译时被处理,它们不在运行时执行
=====
编译指示是对编译程序发出的特殊指令。
=====
它也称为伪指令(pseudoinstruction),不会改变程序的含义。
=====
它只是向编译程序传递信息 ,实际上它是非常类似于嵌在 SQL 语句的注释中的性能调整提示。
==========
EXCEPTION_INIT
将一个特定的错误号与程序中所声明的异常标示符关联起来。
==========
"向EMP表插入数据时,因为DEPT与EMP之间存在主从关系,如果部门号在部门表中不存在就会触发ORA-2291错误。"
Create or replace procedure add_emp(.....)
is
e_2291 EXCEPTION;--异常标示符
PRAGMA EXCEpTION_INIT(e_2291,-2291);--
BEGIN
.....
END;
=========

另:
=======
RESTRICT_REFERENCES
告诉编译程序打包程序的纯度。
======
SERIALLY_REUSABLE
告诉PL/SQL 的运行时引擎,在数据引用之时不要保持包级数据。
======

DECLARE
e_products_invalid EXCEPTION;
PRAGMA EXCEPTION_INIT (e_products_invalid, -2292);
v_message VARCHAR2(50);
BEGIN
. . .
EXCEPTION
WHEN e_products_invalid THEN
v_message := 'Product code specified is not valid.';
. . .
END;
========
PRAGMA是单词pragmatics的简写。
============
A pragma is a compiler directive, which can be thought of as a parenthetical remark to the compiler.
============
Pragmas (also called pseudoinstructions) are processed at compile time, not at run time.
============
For example, In PL/SQL,
the pragma EXCEPTION_INIT tells the compiler to associate an exception name with an Oracle error number. ============
That allows you to refer to any internal exception by name and to write a specific handler for it.:

DECLARE
deadlock_detected EXCEPTION;
PRAGMA EXCEPTION_INIT(deadlock_detected, -60);

BEGIN
...
EXCEPTION
WHEN deadlock_detected THEN
-- handle the error
===================

你可能感兴趣的:(Oracle)