The PRAGMA Keyword

The PRAGMA Keyword

A programming notion that is truly derived from Greek is pragma, which means “deed”
or, by implication, an “action.” In various programming languages, a pragma is gen-
erally a line of source code prescribing an action you want the compiler to take. It’s like
an option that you give the compiler; it can result in different runtime behavior. for the
program, but it doesn’t get translated directly into bytecode.

PL/SQL has a PRAGMA keyword with the following syntax:

PRAGMA instruction_to_compiler;

The PL/SQL compiler will accept such directives anywhere in the declaration section,
but most of them have certain additional requirements regarding placement.
PL/SQL offers several pragmas:

AUTONOMOUS_TRANSACTION
Tells the PL/SQL runtime engine to commit or roll back any changes made to the
database inside the current block without affecting the main or outer transaction.

EXCEPTION_INIT
Tells the compiler to associate a particular error number with an identifier you have
declared  as  an  exception  in  your  program. Must  follow  the  declaration  of  the
exception. 

RESTRICT_REFERENCES
Tells the compiler the purity level (freedom from side effects) of a packaged pro-
gram. 

SERIALLY_REUSABLE
Tells  the PL/SQL runtime engine  that package-level data should not persist be-
tween references to that data. See Chapter 18 for more information.

The following block demonstrates the use of the EXCEPTION_INIT pragma to name
a built-in exception that would otherwise have only a number:

DECLARE
   no_such_sequence EXCEPTION;
   PRAGMA EXCEPTION_INIT (no_such_sequence, −2289);
BEGIN
   ...
EXCEPTION
   WHEN no_such_sequence
   THEN
      q$error_manager.raise_error ('Sequence not defined');
END;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17309626/viewspace-625615/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/17309626/viewspace-625615/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值