Sei sulla pagina 1di 16

What is a Trigger?

A trigger is a pl/sql block structure which is fired when a DML statements like Insert, Delete, Update is executed on a database table A trigger is triggered automaticall! when an associated DML statement is executed

Syntax of Triggers Syntax for Creating a Trigger


CREATE [OR REPLACE ] TRIGGER {BEFORE | AFTER | INSTEAD OF {INSERT [OR] | UPDATE [OR] | [OF !"_name] ON ta#"e_name [REFERENCING OLD AS ! NE$ AS [FOR EAC% RO$] $%EN & !n'iti!n( BEGIN ))) *+" *tatement* END, trigger_name } DELETE} n]

CREATE [OR REPLACE ] TRIGGER trigger_name " #his clause creates a trigger with the gi$en name or o$erwrites an existing trigger with the same name {BEFORE | AFTER | INSTEAD OF } " #his clause indicates at what time should the trigger get fired i e for example% before or after updating a table I&'#(AD )* is used to create a trigger on a $iew before and after cannot be used to create a trigger on a $iew {INSERT [OR] | UPDATE [OR] | DELETE} " #his clause determines the triggering e$ent More than one triggering e$ents can be used together separated b! )+ ke!word #he trigger gets fired at all the specified triggering e$ent [OF !"_name] " #his clause is used with update triggers #his clause is used when !ou want to trigger an e$ent onl! when a specific column is updated CREATE [OR REPLACE ] TRIGGER trigger_name " #his clause creates a trigger with the gi$en name or o$erwrites an existing trigger with the same name [ON ta#"e_name] " #his clause identifies the name of the table or $iew to which the trigger is associated [REFERENCING OLD AS ! NE$ AS n] " #his clause is used to reference the old and new $alues of the data being changed ,! default, !ou reference the $alues as %old column-name or %new column-name #he reference names can also be changed from old .or new/ to an! other user"defined name 0ou cannot reference old $alues when inserting a record, or new $alues when deleting a record, because the! do not exist

[FOR EAC% RO$] " #his clause is used to determine whether a trigger must fire when each row gets affected . i e a +ow Le$el #rigger/ or 1ust once when the entire sql statement is executed.i e statement le$el #rigger/ $%EN & !n'iti!n( " #his clause is $alid onl! for row le$el triggers #he trigger is fired onl! for rows that satisf! the condition specified

For Example: #he price of a product changes constantl! It is important to maintain the histor! of the prices of the products 2e can create a trigger to update the 3product-price-histor!3 table when the price of the product is updated in the 3product3 table 1) 4reate the 3product3 table and 3product-price-histor!3 table
CREATE TABLE -r!'. t_-ri e_/i*t!r0 &-r!'. t_i' n.m#er&1(2 -r!'. t_name 3ar /ar4&54(2 *.--"ier_name 3ar /ar4&54(2 .nit_-ri e n.m#er&624( (, CREATE TABLE -r!'. t &-r!'. t_i' n.m#er&1(2 -r!'. t_name 3ar /ar4&54(2 *.--"ier_name 3ar /ar4&54(2 .nit_-ri e n.m#er&624( (,

2) 4reate the price-histor!-trigger and execute it


CREATE !r REPLACE TRIGGER -ri e_/i*t!r0_trigger BEFORE UPDATE OF .nit_-ri e ON -r!'. t FOR EAC% RO$ BEGIN INSERT INTO -r!'. t_-ri e_/i*t!r0 7ALUES &8!"'9-r!'. t_i'2 8!"'9-r!'. t_name2 8!"'9*.--"ier_name2 8!"'9.nit_-ri e(, END, :

3) Lets update the price of a product


UPDATE PRODUCT SET .nit_-ri e ; <== $%ERE -r!'. t_i' ; >==

)nce the abo$e update quer! is executed, the trigger fires and updates the 3product-price-histor!3 table

4)If !ou +)LL,A45 the transaction before committing to the database, the data inserted to the table is also rolled back

Types of P !S" Triggers


#here are two t!pes of triggers based on the which le$el it is triggered 1) #o$ le%el trigger " An e$ent is triggered for each row upated, inserted or deleted 2) Statement le%el trigger " An e$ent is triggered for each sql statement executed

P !S" Trigger Exe&'tion (ierar&hy


#he following hierarch! is followed when a trigger is fired 1) ,(*)+( statement trigger fires first 2) &ext ,(*)+( row le$el trigger fires, once for each row affected 3) #hen A*#(+ row le$el trigger fires once for each affected row #his e$ents will alternates between ,(*)+( and A*#(+ row le$el triggers 4) *inall! the A*#(+ statement le$el trigger fires For Example: Let3s create a table 3product-check3 which we can use to store messages when triggers are fired
CREATE TABLE -r!'. t &?e**age 3ar /ar4&1=(2 C.rrent_Date n.m#er&54( (,

Let3s create a ,(*)+( and A*#(+ statement and row le$el triggers for the product table 1) )EF*#E +P,-TE. Statement e%el: #his trigger will insert a record into the table 3product-check3 before a sql update statement is executed, at the statement le$el
CREATE !r REPLACE TRIGGER Be@!re_U-'ate_Stat_-r!'. t BEFORE UPDATE ON -r!'. t Begin INSERT INTO -r!'. t_ /e A 7a".e*&BBe@!re .-'ate2 *tatement "e3e"B2*0*'ate(, END, :

2) )EF*#E +P,-TE. #o$ e%el: #his trigger will insert a record into the table 3product-check3 before each row is updated
CREATE !r REPLACE TRIGGER Be@!re_U-''ate_R!C_-r!'. t BEFORE UPDATE ON -r!'. t FOR EAC% RO$ BEGIN

INSERT INTO -r!'. t_ /e A 7a".e*&BBe@!re .-'ate r!C "e3e"B2*0*'ate(, END, :

3) -FTE# +P,-TE. Statement e%el: #his trigger will insert a record into the table 3product-check3 after a sql update statement is executed, at the statement le$el
CREATE !r REPLACE TRIGGER A@ter_U-'ate_Stat_-r!'. t AFTER UPDATE ON -r!'. t BEGIN INSERT INTO -r!'. t_ /e A 7a".e*&BA@ter .-'ate2 *tatement "e3e"B2 *0*'ate(, En', :

4) -FTE# +P,-TE. #o$ e%el: #his trigger will insert a record into the table 3product-check3 after each row is updated
CREATE !r REPLACE TRIGGER A@ter_U-'ate_R!C_-r!'. t AFTER in*ert On -r!'. t FOR EAC% RO$ BEGIN INSERT INTO -r!'. t_ /e A 7a".e*&BA@ter .-'ate2 R!C "e3e"B2*0*'ate(, END, :

&ow lets execute a update statement on table product


UPDATE PRODUCT SET .nit_-ri e ; <== $%ERE -r!'. t_i' in &>==2>=>(,

Lets check the data in 3product-check3 table to see the order in which the trigger is fired
SELECT D FRO? -r!'. t_ /e A,

*'tp't: Mesage 4urrent-Date

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ,efore update, statement le$el ,efore update, row le$el After update, +ow le$el ,efore update, row le$el After update, +ow le$el After update, statement le$el 67"&o$"6889 67"&o$"6889 67"&o$"6889 67"&o$"6889 67"&o$"6889 67"&o$"6889

#he abo$e result shows 3before update3 and 3after update3 row le$el e$ents ha$e occured twice, since two records were updated ,ut 3before update3 and 3after update3 statement le$el e$ents are fired onl! once per sql statement #he abo$e rules appl! similarl! for I&'(+# and D(L(#( statements

(o$ To /no$ 0nformation a1o't Triggers2


2e can use the data dictionar! $iew 3U'(+-#+I::(+'3 to obtain information about an! trigger #he below statement shows the structure of the $iew 3U'(+-#+I::(+'3
DESC USER_TRIGGERS,

&AM(

#!pe

"""""""""""""""""""""""""""""""""""""""""""""""""""""""" #+I::(+-&AM( ;A+4<A+6.=8/ #+I::(+-#0>( ;A+4<A+6.?7/ #+I::(+-(;(&# ;A+4<A+6.@A/ #A,L(-)2&(+ ;A+4<A+6.=8/ ,A'(-),B(4#-#0>( ;A+4<A+6.?7/ #A,L(-&AM( ;A+4<A+6.=8/ 4)LUM&-&AM( ;A+4<A+6.C888/ +(*(+(&4I&:-&AM(' ;A+4<A+6.?69/ 2<(&-4LAU'( ;A+4<A+6.C888/ '#A#U' ;A+4<A+6.9/ D('4+I>#I)& ;A+4<A+6.C888/ A4#I)&-#0>( ;A+4<A+6.??/ #+I::(+-,)D0 L)&: #his $iew stores information about header and bod! of the trigger
SELECT D FRO? .*er_trigger* $%ERE trigger_name ; BBe@!re_U-'ate_Stat_-r!'. tB,

#he abo$e sql quer! pro$ides the header and bod! of the trigger 3,efore-Update-'tat-product3 0ou can drop a trigger using the following command
DROP TRIGGER trigger_name,

C3C 0C C-SC-,045 in a T#055E#

#his is an undesirable situation where more than one trigger enter into an infinite loop while creating a trigger we should ensure the such a situtation does not exist #he below example shows how #rigger3s can enter into c!clic cascading Let3s consider we ha$e two tables 3abc3 and 3x!D3 #wo triggers are created 1) #he I&'(+# #rigger, triggerA on table 3abc3 issues an U>DA#( on table 3x!D3 2) #he U>DA#( #rigger, trigger, on table 3x!D3 issues an I&'(+# on table 3abc3 In such a situation, when there is a row inserted in table 3abc3, triggerA fires and will update table 3x!D3 2hen the table 3x!D3 is updated, trigger, fires and will insert a row in table 3abc3 #his c!clic situation continues and will enter into a infinite loop, which will crash the database

What are C'rsors?


A cursor is a temporar! work area created in the s!stem memor! when a 'EL statement is executed A cursor contains information on a select statement and the rows of data accessed b! it #his temporar! work area is used to store the data retrie$ed from the database, and manipulate this data A cursor can hold more than one row, but can process onl! one row at a time #he set of rows the cursor holds is called the a ti)e set #here are two t!pes of cursors in >L/'EL%

Implicit cursors
#hese are created b! default when DML statements like, I&'(+#, U>DA#(, and D(L(#( statements are executed #he! are also created when a '(L(4# statement that returns 1ust one row is executed

Explicit cursors
#he! must be created when !ou are executing a '(L(4# statement that returns more than one row ($en though the cursor stores multiple records, onl! one record can be processed at a time, which is called as current row 2hen !ou fetch a row the current row position mo$es to next row ,oth implicit and explicit cursors ha$e the same functionalit!, but the! differ in the wa! the! are accessed

0mpli&it C'rsors: -ppli&ation

2hen !ou execute DML statements like D(L(#(, I&'(+#, U>DA#( and '(L(4# statements, implicit statements are created to process these statements )racle pro$ides few attributes called as implicit cursor attributes to check the status of DML operations #he cursor attributes a$ailable are F*)U&D, F&)#*)U&D, F+)24)U&#, and FI')>(& *or example, 2hen !ou execute I&'(+#, U>DA#(, or D(L(#( statements the cursor attributes tell us whether an! rows are affected and how man! ha$e been affected 2hen a '(L(4# I&#) statement is executed in a >L/'EL ,lock, implicit cursor attributes can be used to find out whether an! row has been returned b! the '(L(4# statement >L/'EL returns an error when no data is selected #he status of the cursor for each of these attributes are defined in the below table -ttri1'tes F*)U&D #et'rn 6al'e Example #he return $alue is #+U(, if the DML 'ELF*)U&D statements like I&'(+#, D(L(#( and U>DA#( affect at least one row and if '(L(4# G I&#) statement return at least one row #he return $alue is *AL'(, if DML statements like I&'(+#, D(L(#( and U>DA#( do not affect row and if '(L(4#G I&#) statement do not return a row F&)#*)U&D #he return $alue is *AL'(, if DML statements 'ELF&)#*)U&D like I&'(+#, D(L(#( and U>DA#( at least one row and if '(L(4# G I&#) statement return at least one row #he return $alue is #+U(, if a DML statement like I&'(+#, D(L(#( and U>DA#( do not affect e$en one row and if '(L(4# G I&#) statement does not return a row F+)24)U&# +eturn the number of rows affected b! the DML 'ELF+)24)U&# operations I&'(+#, D(L(#(, U>DA#(, '(L(4#

*or (xample% 4onsider the >L/'EL ,lock that uses implicit cursor attributes as shown below%
DECLARE 3ar_r!C* n.m#er&1(, BEGIN UPDATE em-"!0ee SET *a"ar0 ; *a"ar0 E >===, IF SFLGNOTFOUND T%EN '#m*_!.t-.t9-.t_"ine&BN!ne !@ t/e *a"arie* C/ere .-'ate'B(, ELSIF SFLGFOUND T%EN

3ar_r!C* 8; SFLGRO$COUNT, '#m*_!.t-.t9-.t_"ine&BSa"arie* @!r B || 3ar_r!C* || Bem-"!0ee* are .-'ate'B(, END IF, END,

In the abo$e >L/'EL ,lock, the salaries of all the emplo!ees in the Hemplo!eeI table are updated If none of the emplo!eeIs salar! are updated we get a message 3&one of the salaries where updated3 (lse we get a message like for example, 3'alaries for ?888 emplo!ees are updated3 if there are ?888 rows in Hemplo!eeI table

Expli&it &'rsor Example:


D(4LA+( i I&#(:(+J 1 iF#0>(J name? ;A+4<A+6.=6/J name6 students last-nameF#0>(J student-rec studentsF+)2#0>(J "" sort of like struct in 4 4U+')+ s? I' '(L(4# first-name, last-name *+)M studentsJ student-name s?F+)2#0>(J ,(:I& )>(& s?J L))> *(#4< s? I&#) student-nameJ (KI# 2<(& s?F&)#*)U&DJ D,M'-)U#>U# >U#-LI&(.student-name first-name LL 3 3 LL student-name last-name/J (&D L))>J

4L)'( s?J (&DJ Exmple:

DECLARE CURSOR *a"_ .r*!r IS SELECT *a" FRO? em$%ERE 'e-tn! ; 5= FOR UPDATE NO$AIT, BEGIN FOR em-_re !r' IN *a"_ .r*!r LOOP UPDATE emSET *a" ; em-_re !r'9*a" D >9>= $%ERE CURRENT OF *a"_ .r*!r, END LOOP, CO??IT, END,

Ex&eption (an7ling
In this section we will discuss about the following, ?/ 2hat is (xception <andling 6/ 'tructure of (xception <andling =/ #!pes of (xception <andling

1) What is Ex&eption (an7ling?

>L/'EL pro$ides a feature to handle the (xceptions which occur in a >L/'EL ,lock known as exception <andling Using (xception <andling we can test the code and a$oid it from exiting abruptl! 2hen an exception occurs a messages which explains its cause is recie$ed >L/'EL (xception message consists of three parts 1) Type of Ex&eption 2) -n Error Co7e 3) - message ,! <andling the exceptions we can ensure a >L/'EL block does not exit abruptl!

2) Str'&t're of Ex&eption (an7ling2


General Syntax for coding the exception section
DECLARE De "arati!n *e ti!n BEGIN EH e-ti!n *e ti!n EICEPTION $%EN eH_name> T%EN )Err!r /an'"ing *tatement* $%EN eH_name4 T%EN )Err!r /an'"ing *tatement* $%EN Ot/er* T%EN )Err!r /an'"ing *tatement* END,

General PL/SQL statments can be used in the Exception Block.

2hen an exception is raised, )racle searches for an appropriate exception handler in the exception section *or example in the abo$e example, if the error raised is 3ex-name? 3, then the error is handled according to the statements under it 'ince, it is not possible to determine all the possible runtime errors during testing fo the code, the 32<(& )thers3 exception is used to manage the exceptions that are not explicitl! handled )nl! one exception can be raised in a ,lock and the control does not return to the (xecution 'ection after the error is handled If there are nested >L/'EL blocks like this
DELCARE De "arati!n *e ti!n BEGIN DECLARE De "arati!n *e ti!n BEGIN EHe .ti!n *e ti!n EICEPTION EH e-ti!n *e ti!n END,

EICEPTION EH e-ti!n *e ti!n END,

In the abo$e case, if the exception is raised in the inner block it should be handled in the exception block of the inner >L/'EL block else the control mo$es to the (xception block of the next upper >L/'EL ,lock If none of the blocks handle the exception the program ends abruptl! with an error

3) Types of Ex&eption2
#here are = t!pes of (xceptions a/ &amed '!stem (xceptions b/ Unnamed '!stem (xceptions c/ User"defined (xceptions

a) 4ame7 System Ex&eptions


'!stem exceptions are automaticall! raised b! )racle, when a program $iolates a +D,M' rule #here are some s!stem exceptions which are raised frequentl!, so the! are pre"defined and gi$en a name in )racle which are known as &amed '!stem (xceptions For example: &)-DA#A-*)U&D and M(+)-DI;ID( are called &amed '!stem exceptions &amed s!stem exceptions are% ?/ &ot Declared explicitl!, 6/ +aised implicitl! when a predefined )racle error occurs, =/ caught b! referencing the standard name within an exception"handling routine
Exception Name Reason Error Numbe r

4U+')+-AL+(AD0-)>(& 2hen !ou open a cursor that is alread! open

)+A" 87A??

I&;ALID-4U+')+

2hen !ou perform an in$alid operation on a cursor )+A" like closing a cursor, fetch data from a cursor that is 8?88? not opened 2hen a '(L(4# I&#) clause does not return an! )+A" row from a table 8?C8= 2hen !ou '(L(4# or fetch more than one row into )+A"

&)-DA#A-*)U&D

#))-MA&0-+)2'

a record or $ariable M(+)-DI;ID( 2hen !ou attempt to di$ide a number b! Dero

8?C66 )+A" 8?C@7

For Example: 'uppose a &)-DA#A-*)U&D exception is raised in a proc, we can write a code to handle the exception as gi$en below
BEGIN EHe .ti!n *e ti!n EICEPTION $%EN NO_DATA_FOUND T%EN '#m*_!.t-.t9-.t_"ine &BA SELECT999INTO 'i' n!t ret.rn an0 r!C9B(, END,

1) +nname7 System Ex&eptions


#hose s!stem exception for which oracle does not pro$ide a name is known as unamed s!stem exception #hese exception do not occur frequentl! #hese (xceptions ha$e a code and an associated message #here are two wa!s to handle unnamed s!s!em exceptions% ? ,! using the 2<(& )#<(+' exception handler, or 6 ,! associating the exception code to a name and using it as a named exception 2e can assign a name to unnamed s!stem exceptions using a Pragma called E8CEPT0*49040T2 E8CEPT0*49040T will associate a predefined )racle error number to a programmer-defined exception name 'teps to be followed to use unnamed s!stem exceptions are N #he! are raised implicitl! N If the! are not handled in 2<(& )thers the! must be handled explicit! N #o handle the exception explicit!, the! must be declared using >ragma (K4(>#I)&-I&I# as gi$en abo$e and handled referecing the user"defined exception name in the exception section #he general s!ntax to declare unnamed s!stem exception using (K4(>#I)&-I&I# is%
DECLARE eH e-ti!n_name EICEPTION, PRAG?A EICEPTION_INIT &eH e-ti!n_name2 Err_ !'e(, BEGIN EHe .ti!n *e ti!n EICEPTION $%EN eH e-ti!n_name T%EN /an'"e t/e eH e-ti!n

END,

For Example: Lets consider the product table and order-items table from sql 1oins <ere product-id is a primar! ke! in product table and a foreign ke! in order-items table If we tr! to delete a product-id from the product table when it has child records in order-id table an exception will be thrown with oracle code number "66O6 2e can pro$ide a name to this exception and handle it in the exception section as gi$en below
DECLARE C/i"'_re _eH e-ti!n EICEPTION, PRAG?A EICEPTION_INIT &C/i"'_re _eH e-ti!n2 )44J4(, BEGIN De"ete FRO? -r!'. t C/ere -r!'. t_i'; >=K, EICEPTION $%EN C/i"'_re _eH e-ti!n T%EN D#m*_!.t-.t9-.t_"ine&BC/i"' re !r'* are -re*ent @!r t/i* -r!'. t_i'9B(, END, :

For Example: Let us write some simple code to illustrate the concept. We will be using the CUSTOMERS
table we had created : DECLARE _i' .*t!mer*9i'Gt0-e 8; <, _name .*t!mer*9nameGt0-e, _a''r .*t!mer*9a''re**Gt0-e, BEGIN SELECT name2 a''re** INTO _name2 FRO? .*t!mer* $%ERE i' ; _i',

_a''r

DB?S_OUTPUT9PUT_LINE &BName8 B|| _name(, DB?S_OUTPUT9PUT_LINE &BA''re**8 B || _a''r(, EICEPTION $%EN n!_'ata_@!.n' T%EN '#m*_!.t-.t9-.t_"ine&BN! *. / .*t!merLB(, $%EN !t/er* T%EN '#m*_!.t-.t9-.t_"ine&BErr!rLB(, END, : When the above code is executed at SQL prompt, it produces the following result: N! *. / .*t!merL e**@.""0 !m-"ete'9

PL:SFL -r! e'.re *.

The above program displays the name and address of a customer whose ID is given. Since there is no customer with ID value 8 in our database, the program raises the run-time exception NO_DATA_FOUND , which is captured in EXCEPTIONblock.

Raising Exceptions

Exceptions are raised by the database server automatically whenever there is any internal database error, but exceptions can be raised explicitly by the programmer by using the command RAISE . Following is the simple syntax of raising an exception: DECLARE eH e-ti!n_name EICEPTION, BEGIN IF !n'iti!n T%EN RAISE eH e-ti!n_name, END IF, EICEPTION $%EN eH e-ti!n_name T%EN *tatement, END, You can use above syntax in raising Oracle standard exception or any user-defined exception. Next section will give you an example on raising user-defined exception, similar way you can raise Oracle standard exceptions as well.

User-defined Exceptions
PL/SQL allows you to define your own exceptions according to the need of your program. A user-defined exception must be declared and then raised explicitly, using either a RAISE statement or the procedure DBMS_STANDARD.RAISE_APPLICATION_ERROR. The syntax for declaring an exception is: DECLARE m0)eH e-ti!n EICEPTION,

Example:
The following example illustrates the concept. This program asks for a customer ID, when the user enters an invalid ID, the exception invalid_id is raised. DECLARE _i' .*t!mer*9i'Gt0-e 8; M _i', _name .*t!mer*9nameGt0-e, _a''r .*t!mer*9a''re**Gt0-e, )) .*er 'e@ine' eH e-ti!n eH_in3a"i'_i' EICEPTION, BEGIN IF _i' N; = T%EN RAISE eH_in3a"i'_i', ELSE SELECT name2 a''re** INTO FRO? .*t!mer* $%ERE i' ; _i',

_name2

_a''r

DB?S_OUTPUT9PUT_LINE &BName8 B|| _name(, DB?S_OUTPUT9PUT_LINE &BA''re**8 B || _a''r(, END IF, EICEPTION $%EN eH_in3a"i'_i' T%EN '#m*_!.t-.t9-.t_"ine&BID m.*t #e greater t/an Oer!LB(, $%EN n!_'ata_@!.n' T%EN '#m*_!.t-.t9-.t_"ine&BN! *. / .*t!merLB(, $%EN !t/er* T%EN

'#m*_!.t-.t9-.t_"ine&BErr!rLB(, END, : When the above code is executed at SQL prompt, it produces the following result: Enter 3a".e @!r _i'8 )P &"etB* enter a 3a".e )P( !"' 48 _i' .*t!mer*9i'Gt0-e 8; M _i', neC 48 _i' .*t!mer*9i'Gt0-e 8; )P, ID m.*t #e greater t/an Oer!L PL:SFL -r! e'.re *. e**@.""0 !m-"ete'9

Pre-defined Exceptions
PL/SQL provides many pre-defined exceptions, which are executed when any database rule is violated by a program. For example, the predefined exception NO_DATA_FOUND is raised when a SELECT INTO statement returns no rows. The following table lists few of the important pre-defined exceptions: Oracle Error 06530

Exception

SQLCODE

Description It is raised when a null object is automatically assigned a value. It is raised when none of the choices in the WHEN clauses of a CASE statement is selected, and there is no ELSE clause. It is raised when a program attempts to apply collection methods other than EXISTS to an uninitialized nested table or varray, or the program attempts to assign values to the elements of an uninitialized nested table or varray. It is raised when duplicate values are attempted to be stored in a column with unique index. It is raised when attempts are made to make a cursor operation that is not allowed, such as closing an unopened cursor. It is raised when the conversion of a character string into a number fails because the string does not represent a valid number. It is raised when s program attempts to log on to the database with an invalid username or password. It is raised when a SELECT INTO statement returns no rows. It is raised when a database call is issued without being connected to the database. It is raised when PL/SQL has an internal problem. It is raised when a cursor fetches value in a variable having incompatible data type.

ACCESS_INTO_NULL

-6530

CASE_NOT_FOUND

06592

-6592

COLLECTION_IS_NULL 06531

-6531

DUP_VAL_ON_INDEX

00001

-1

INVALID_CURSOR

01001

-1001

INVALID_NUMBER

01722

-1722

LOGIN_DENIED NO_DATA_FOUND NOT_LOGGED_ON PROGRAM_ERROR

01017 01403 01012 06501

-1017 +100 -1012 -6501 -6504

ROWTYPE_MISMATCH 06504

SELF_IS_NULL STORAGE_ERROR TOO_MANY_ROWS VALUE_ERROR ZERO_DIVIDE

30625 06500 01422 06502 01476

-30625 -6500 -1422 -6502 1476

It is raised when a member method is invoked, but the instance of the object type was not initialized. It is raised when PL/SQL ran out of memory or memory was corrupted. It is raised when s SELECT INTO statement returns more than one row. It is raised when an arithmetic, conversion, truncation, or size-constraint error occurs. It is raised when an attempt is made to divide a number by zero.

Potrebbero piacerti anche