---
title: "Oracle PRAGMA EXCEPTION_INIT"
author: "reymont"
date: "2010-08-31T09:53:00Z"
tags: ["Oracle", "SQL"]
categories: ["数据库"]
slug: "oracle-pragma-exception-init"
draft: false
lastmod: "2010-08-31T09:53:00Z"
id: 751397
url: "https://reymont.iteye.com/blog/751397"
---

看书看到pragma exception_init(e_integrity, -2291);
感到很难以理解

翻了一下oracle PLSQL_User_Guide_and_Reference


> http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/07_errs.htm#917


原来有些oracle error是没有名字的，这些error可以通过pragma来在编译的时候将名字和具体错误链接

在PL/SQL中 pragma exception_init告诉编译器e_integrity是和oracle error 2291联系在一起的。

语法是


```java
PRAGMA EXCEPTION_INIT(错误名, -错误号);
```


exception_name is the name of a previously declared exception and the number is a negative value corresponding to an ORA- error number.