You are on page 1of 197

PL/SQL

| 

Ô  
   
| 
PL/SQL

V Day 1
6 Module 1: Introduction to PL/SQL
6 Module 2: PL/SQL Programming Constructs
6 Module 3: PL/SQL Language Features
6 Module 4: SQL in PL/SQL
6 Module 5: Control Structures
V Day 2
6 Module 6: Stored sub programs (Stored Procedures &
Functions)
6 Module 7: Cursors and Data Types as in 3GL

| 

PL/SQL (Contd.).

V Day 3
6 Module 8: Cursors
6 Module 9: Packages
V Day 4
6 Module 10: Exceptions
6 Module 11: Triggers
6 Module 12: Dependencies among PL/SQL Constructs

|  Ú
Module 1:
Introduction to PL/SQL

Ô  
   
| 
PL/SQL - INTRODUCTION

V §

    
  
 
       

V  

   
 

|  x
— t is PL/SQL Block

V     


6  

 

6 
  
! "#
  

 

!  "


6 $##
 
  
! 
 #  # 
! %& 

! ' 

|  ½
—  PL/SQL?

V " 
(
) &
 
   
(   

 
V      

   *    

 #  
 

| 
PL/SQL Engine

V §
   
+  

  #
 

 

V   (  
6 " 
#
6  (  #

|  ^
— ere PL/SQL stnds?

Front end
application Program

«
«. a 
Invoking
PL/SQL     
PL/SQL
PROCEDURE 
«.
«.

****** **** **

|  u
PL/SQL Block

å  

|     
,  )-.

 

 /

 


å%& 
.
0
%#1
|  à
Îdvntges of PL/SQL
V  

 #
6  

 
   # #  #  
#
#   


  ( 
V §( #   
6 m

      # #
V  
)
6 $ 

 #

  
6 
# 
  # ( 


 

V 

6 —   (  2  —
|  àà
Îdvntges-Contd.

V "

)
6 
 
 #

)  (   
2  
V 
 #  # 
6 $##
  
   
 #  # 
# '   # #
6 
 #  #   (   
  ( 
 #
  3 
 #   #)
 & 

|  à

Nesting of Blocks

V 

 
 
V     #
   
 # 
)
V §  
  )
&
V ' (   #   #
  ( #


  # 


V m

   
#

|  àÚ
Module 2:
PL/SQL Progr Constructs

Ô  
   
| 
PL/SQL Progr Constructs

Anonymous
Block Packages

PL/SQL
BLOCK
Stored
Procedure Triggers
/Programs

Procedures Functions

|  àx
Înonous Block

V   

   # 
 

V §
 
   


  ( *  ) ( )

 
   #
V §
 *
   #  #  
  )  
 )    & 

V 4 
   # ( )
   #


  

 

V 
 
 # & 
  #


 (  #

|  à½
Stored Procedures

V m  #  
V 
 # 
  23 
  '  + | +
§# & +    + ))
V 
 # 
  #)
 & 
 
V "     # ) 
   
V 2 )   


      )

  

|  à
Pckges

V " 
   
# 3 

V '  
    (   +  #  


V " 
( ) # 
  #  
  3 

|  à^
Triggers

V '   


  #


 )   (      # ( 

  
V '    

     #   


 

  #)  
 
& 

V —  ( # )   

 )

|  àu
Module 3:
PL/SQL Lnguge Fetures

Ô  
   
| 
Glise of PL/SQL Block

 
(5#  
 (  6,7-1 | 

 
  
3

 (5#  
  
   |

    8"2''81
 ,(5#  
  89$m$:%;8-
 
#
 
  <7     8"2''81

#
 
  < 7     8"2''81
%#  1
%#1

| 
à
Lexicl Unit

V "  
 

6 $ 
 ,
   #  -
6 m  
6    "  
  =+>+?+
+
V " 

6 ' " 
( )  //    
 
# <0<  
   

V 

6 %( ) 

 
      
#
  ,1-

| 

|riles

V §# 
   
   (   (   
V §# 
    #
 # (  


   #
  
V $
 (    
 #   #  

  # # 
V  
 (    

 

| 
Ú
Rules-Identifier

V §
   #  #   # # 
  
#  #    ,  ( # #-
V §
# 


   

V "   ( @    ##


    

6
 A  $ 
,$/B  /@-
6 )  =  ?  5    #
V  
# # C m  "( 


| 

Dt Tes

V 
(
')
6 m  C m + §

6 "  
 C" +|  6+|  +
6

6  
V "

')
6 ; #+ '  
6 "

| 
x
Declrtion - Exle

)
& 
|   m 
') å %$D' .
å m2' mD . å mD .1
%& 
  ) m ,E+6-1
4;$ m ,E+6- # 
F 1
$ m ,E+6-G6 1

| 
½
Declrtion

V §# 
   
  #   #  
  
V 9 
   ( 
#

) 
V 9 ) # 
 @
   # ( )

 
 & 
#
V 9
  
  
 #

| 

Scoe & |isiilit of |riles
(In nested Blocks)

 
$  G 6 1
%:§m
00
  //§   


$  G 1  
%:§m    !
952D' D' D'5§m%,$-1 // 
$
0
%m 1 // §   #
"à  
952D' D' D'5§m%,$-1

!
%m 1

| 
^
LÎBEL << « >>


HH
 
$  G 6 1
%:§m
00
  //§   


$  G 1 à 
%:§m 

952D' D' D'5§m%,$ II 
$-1
0
%m 1 // §   #
952D' D' D'5§m%,$-1
%m 1

| 
u
Oertors-Îssignent

V G 
   
 
  
V %&  $G 1
6 $  

 (   $1
V
G1
6 $  

 (   J
*
6 ) # 
/
 @ # (    
  #
    
( 
 #

) 

 (  

|  Ú
Oertors

V $

 2 

6 < +  +  + / +#
V "  2 

6 ; 
  2 

! + + H+ H+  # K  H  L
6 § mD+ §%+%'—%%m+§m
V    2 

6 m2'+ $m + 2;

|  Úà
Built-in-Functions

V m 
V "  

V "( 
V

V % ; 

V 2
 

|  Ú

Nuer Functions

V ;2Dm
V ';Dm"
V 92
V 2—%;+;'
V "2+§m+'$m+2:+

|  ÚÚ
C rcter Function

V  + D + §


 
V  #+ ; #
V 
+ ;

V 
+ "

V  

V ;   + ' 

|  Ú
Dte -Function

V )#

V  
5# )
V 9
5
 
V ;#
V '
V $##5

V m 5

V m &
5# )

|  Úx
Conversion Function

V '5 
V '5#

V '5 
V " 
#
V ;#
 
V 4 &
 
V  
 &

|  Ú½
Error Reorting Functions

V %;;9
V "2 %

|  Ú
Ot ers - Functions

V %"2 %
V :;%$'%'
V %$'
V m|
V D%;

|  Ú^
Module 4:
SQL In PL/SQL

Ô  
   
| 
Dt Retrievl Fro PL/SQL

V    


 

 )   #


 ( 
V  
 #
   
 ( # 


     


 

 ## # §m'2
  
V     #  9+'"
 # # 
 M "  #
# 
)

|  
INTO Cluse
(Dt Fro SQL into PL/SQL)

V )
&  %%"' 

 
  
%%"'  å
.
§m'2 (   å
.
;29
 å
.
å—4%;% #
,- .
V  #

 (  C %%"' 

V  #
  / §m'2 

|  à
INTO Cluse - Exle

%"$;%
(5  (  6, -1
(5#  ,6-1
%:§m
%%"'   + # 


§m'2 (5  + (5#


;29 
—4%;% EENN1
#5


5 ,(5  II*  
JII(5#-1
%m 1

|  

Exle ± 2

%"$;%
(5  (  6, -1
 
%%"'  
§m'2 (5 
;29 
—4%;% # 
 1
#1
V —
  

  )O
V —
  )  
   

 )
  # 
  O
V —
  )  
    )  
 # 
  O

|  Ú
Restrictions

V   


 
    
 ( ) 
 #


V %%"' M §m'2   # 

6 %      
# (   

6   ,
 - #

) 
6 2#     
    


 

 #
 
 
(   

|  
DML in PL/SQL

 
(5 GEEN61
(5 5 GEENN
#
 
 (5 5     (5 1
 

 # 
(  ,P +*§m$m"%*+*'%Q$*-1
# 
   (5 1
#1
V 9  #    & 
#
   


) # 
 
 )
&
V 9 "   
 #



|  x
TCL in PL/SQL

%"$;%
(5   ,E+6-1
%:§m
#
 
  <7 1
  
, -

 (5 
 1
 (5  H 
 
 1


1
#  1
%m 1

|  ½
& Sustitution |rile

V 

    #

V %& 
6 #
GM(  1
6   
<     # 
M#1
6 § 

 # 
(   ,M#+ M#  + M-1
V  < D     #
V 


 

  #  #
  J 

 (   #G*

|  
´ost vriles

V ;  #  # (   
V D
6 GH|$; Q mD9%; //#   (  
6 GH%Q%"D'% GQG //#  

6 GH ;§m' Q //  


 
V  /     

|  ^
Bind vriles - Exle

  
 
GG&1 // 
    (  
G&GG&  1 //   6
 (   &
#1

  6
 
#5


5 ,G&-1 //
 6
#1

|  u
Module 5:
Control Structures

Ô  
   
| 
Control Structures

V ) # 

     
     /
%& 

 

 
 

 
 
V "
   
   #    #   # 

    )  
 
 

 
6 "#
  

 

6  "



|  xà
Conditionl Stteents

V   
 & 
 )  

#

V "   #  § 

 

V ')   § 

 
 (   
6 §0'4%m0%m §
6 §0'4%m0%%0%m §
6 §0'4%m0%§0%m §

|  x

IF Stteent -Exle

%&  G
§ ,|5R2J"%;*- '4%m
|52mDG6 1
%m §1
%&  6G
§ ,|5R2J$%9$m*- '4%m
|52mDG6 1
%%
|52mDG 1
%m §1
|  xÚ
IF ±T´EN-ELSE
%&  FG
§ ,|5R2J$%9$m*- '4%m
|52mDG6 1
%%
§ ,|5R2J"%;*- '4%m
|52mDGF 1
%%
|52mDG 1
%m §1
%m §1
|  x
ELSIF -Exle

%&  SG
§ ,|5R2J$%9$m*- '4%m
|52mDGS 1
%§ ,|5R2J"%;*- '4%m
|52mDGF 1
%§ ,|5R2J$m$T'*- '4%m
|52mDG6 1
%%
|52mDG 1
%m §1
|  xx
CÎSE

V '  


 #

V )
& 
"$%
—4%m #
 '4%m


 
1
—4%m #
 '4%m


 
1
%%


 
1
%m "$%1

|  x½
Looing Constructs

V %& 
 
 

 
  
#)
V  "


6 22 0%m 22
6 —4§% 022 0%m 22
6 2;0§m022 0%m 22

|  x
LOOP«END LOOP

22
0
0
%m 22
V 

 
 
  22 # %m 22 
 & 
#  
# #   
)
V D %Q§'



 #  

|  x^
EXIT

22
0
%Q§'1
0
%m 22
0

|  xu
EXIT —´EN - Exle


0
%Q§' —4%m "m'H 1
0
%m 22 1

§ ,"m'H - '4%m
952D' D' D'5§m% ,J%& # # 
 *-1
%Q§'1
%m §1

|  ½
—´ILE LOOP

—4§% ,#
-
22
0
%m 22 1
V 

 
 
  22 # %m 22 
 & 
# 
 #
 

V ' 
 #
   #) /
 (#
 


|  ½à
FOR LOOP

2; 
 §m å;%|%;%.


5(    5( 
22
0
%m 22 1
V §
#  
 C 2;  (  
V   

 

|  ½

FOR LOOP - Exle

2; 
§m  22
#5


5 ,
-1
%m 22 1

2; 
§m ;%|%;%  22
#5


5 ,
-1
%m 22 1

|  ½Ú
NULL - Stteent

V  

 
 #
 # 

V #)
  
 


  &



& 
 )

%& 
 ,  -
 
mD1

#5


5 ,J  
 
  *-1
#  1

|  ½
Module 6:
Stored Su Progrs

Ô  
   
| 
Îdvntges of Surogrs

V 9#   
V §( # 9 
 
V 
 #   & 
 

V 
 # 
  3 
 
  ( 
V  
)
V  
@ #

|  ½½
Tes of Preters

V    

V $
   


|  ½
Module 6.1:
Stored Procedures

Ô  
   
| 
Different Modes of Preters
(IN, OUT, IN OUT)

V §m  

6 '  # 
(  

    
V 2D'  

6 " ) 

(  

  
( 

V §m 2D'  

6 D #  

 # 

  # #  )

  

   

|  ½u
IN Preter

V '   


    
V    

6 § #  
   #

#  §m
  

6 §  #  

,§m   
  *


 # #
    -
V ' 
   

6 "   (   + 
    & 
6 #   
 @ # (  

| 
OUT Preter

V "  
 



   ( 

V    

6 9# 2D'     # &
)
6 2D'   
   # 

 

#

V ' 
   

6 9
 (  
6 #  /
 @ #

|  à
IN OUT Preter

V  # #   ( #

 # 
  
V    

6 9# §m 2D'     # &
)
6 $
  
    

  

V ' 
   

6 9
 (  
6 #  
 @ #

| 

Creting t e Procedure

";%$'% å2; ;% $"%. ;2"% D;%  #  


å,    
 å92 %.

) +
    
6 å92 %.

) +
0-.
§$
å 5(  

) .
 

|  Ú
|  
Procedure - Exle

"
     # 
 ( ,
(5  §m  +
(5  2D' (  6+
(53 2D' (  6-

 
  
  +3

 (5  +(53
 
  (5 1
#1

|  x
Invoking t e Procedure

   #$à%&



'("
)a*+
,àx
)a*+- 
,àx
)a*+. , ^^ * *- 

("%&  /   


)a*+%&& 01
)a*+%&2'

|  ½
Invoking t e Procedure
V '  
  # U
 ( V 
  §m
  
 # 6 2D'   
  
) 
 
(5  (  6,7-1
(53 (  6,7-1
 

 ( ,EENN+(5  +(53-1
%#1

| 
Reoving t e Procedure

V )
& 
;2 ;2"% D;%  # 5  1

V %& 
#  # 
 ( 1

|  ^
Dt Dictionr |iews

V %"  # 5 


V %" D%;52D;"%
V %" D%;52R%"'
V %" D%;5 % %m %m"§%

|  u
Module 6.2:
Stored Functions

Ô  
   
| 
Stored Function

V m  # # 
 #  
V # 

 
 ( 
V D #  
/ 

6 §
      
 # 



V §( #   
 & 
6 m   


 
  # #
 (



|  ^à
Creting t e Functions
)
& 
";%$'% å2; ;% $"%. Dm"'§2m 
5 
å,    
 å92 %.
5
) +
    
6 å92 %.
5
) +
0-.
;%'D;m
5
)
§I$
 1

|  ^

Return Stteent

V ;%'D;m #
5
)
6 2)
)  
     # # @
  
  
 #
6 "      #

) # 
#


) 
6 "  
 )  ( 
6 #  (
 
 
 

 


  
! ;%'D;m (   1

|  ^Ú
Exle

"
    
 
5 &  ,# §m  -
;
  
§
(5   1
 
  
 &, -
§
 (5 
 
—  # 
  #1
;
 (5 1
%#1

|  ^
Invoking t e Function

V GH & 
G  )G
5 & , -

V § 

  , +  + # 
-
(  ,6FS+
5 & , -+7 -1

V   
 
 
   H
5 & ,6 -1

|  ^x
Reoving t e Function

V ;2 Dm"'§2m 
5 

%& 
6 ;2 Dm"'§2m 
5 & 
—  (
 
 # 
 
5 & 
$  (
  
# #
#
 )

  # 



|  ^½
Restrictions on using functions

V    


 # 
 

V # 
 ( 2D' # §m 2D'   

V §  
 
  ( #  
6 ;
 #

) #  
( #


)  mD9%;+ "4$;+ $'%
6 ;
 #

) # 
 

#

)   
# )  

|  ^
Procedures |s Functions

;2"% D;% Dm"'§2m


§( #    
"   ( #   



 
& 

;
 @    ;
  (  
(    2D' ;
 

 

  


|  ^^
Dt Dictionr |iews

V %" 
5 
V %" D%;52D;"%
V %" D%;52R%"'
V %" D%;5 % %m %m"§%
V %" D%;5%;;2;

|  ^u
Module 7:
Cursors nd Dt tes
(s in 3GL)

Ô  
   
| 
'TYPE

DATA DICTIONARY
Declare
DESC EMP
V_SAL EMP.SAL%TYPE;
«..
SAL NUMBER(7,2)
«.

&(01,


|  uà
'Te

V  
(5   >
) 1
0
6 §
#

) ,

 -   

6 ; 
 #
#
 )  %9
 
6 

  
#

)  $ 
6 9  

 (   (5 

|  u

'TYPE - Exle

%&  
%"$;%
(  mD9%;,E+6-1
( 6 (  >'T %1
%&  6
%"$;%
   >'T %1
 mD9%;,S-1

|  uÚ
Exle - 1
V ;
 ( 
    
  )
 
|5   ,S-1
|5  (  6,7-1
|53 (  6, -1
|5   ,S-1
|5 #
#
1
|5   ,E+6-1
|5  ,E+6-1
|5#  ,6-1
 
  
<
§
 (5 +(5   +(53+(5 +(5 #
+(5 +
(5+(5#
00

|  u
'RO—TYPE
 
)  >
) 1
 
  
<

 ) 
0
 ,)   
-
  0
V 

  
    # #  #

(   ) 
V '  
 (     
) (   #
  
   +) 
|  ux
Record Te

V D  #  #+ 
@ # #

)
V  

   "
V " 
  (    
V "



) # #    # (  
  
   #  #  #
)

|  u½
Record Te - Exle

1Ô 1
314"1Ô'
,5631
5631
44
17%&
)11Ô 
%&'4
8'0 
9115 :5  & :;1&'
"4  5 4,45
<<45
1&
|  u
Record Te - Exle

31%)1Ô'
, &(01,

9 &(01,

 &(01,

4 
   
17%&
4 5 *:Ú 
4 5 *:



|  u^
PL/SQL Tle

V " 
   # # 

V 
  #   )
V   #  
V m 
    #
6 "  
   )  #   # #

|  uu
PL/SQL Tles-Exle

|  à
Built-in-Functions

V 
 
  #
   
 

6 "2Dm'
6 %Q§',m-
6 §;' + $'
6 m%Q' + ;§2;
6 %%'%,m-

|  à à
Îdvntges-Coosite Dt tes

V — 
 

   
    
 #
 # )
  
V ; 
  


 # (    
#   # # )
V (#     §#  # 
V >;2—'T %    
 (# #(# 
     

V 4       
 ( #  

|  à

Module 8:
Cursors

Ô  
   
| 
— en nd —  Cursors
V 
 
    #  


  (   
V "   #
  
V " 
  )  
 

V '  )  )   #
 
 #

   # #
6 
  

6 $# 9 

 


|  à 
Ilicit & Exlicit Cursors

V §
"
6 4 # # # 
 # ) 2 
6 )
 #  # 
6 9 )   #
 ) 

# 9  

V %&
"
6  # +m  # #  # )    
6 "
 # )  

|  à x
Cursor Îttriutes-Ilicit

V >;2—"2Dm'
6 m    
# )
 
  



 

V >2Dm
6 ';D% 
 
  
 # ) 
6 

 ';D%  >;2—"2Dm'  H
V >m2'2Dm
6 ';D% 
 
  
 ##*
# ) 
6 


  >;2—"2Dm'   
>#  
V >§2 %m
6 $ ) $%    
  
   #


  
  


|  à ½
Exle

 
#  ,S-1
 
#GM# 1
# 
    # 
#1
 ,> #-
 
#5


5 ,>
-1
#  1
 ,>
#-
 
#5


5 ,8 )   
# 
 JII#-1
#  1
#1

|  à
Stges in Cursors

START

&  


DECLARE CURSOR "
  
 
    




OPEN CURSOR
 
 ""
  " 

NP

|  à ^
Stges in Cursors

NP

FETCH CURSOR INTO VARIABLE


F 
    

IS
NO
EMPT
Y

YES
CLOSE CURSOR
  


STOP

|  à u
Cursor to Record te

V 
  
 (  
6 
 
  
 #  
( 



  (   
6

) 
 (   #  #  



 
6 |      #   #  >
) 
  #(#   
  

   #

|  àà
Cursor to Record te

1.

Ô " 4 "
" " 
 44 6 

5
Fetch my_cur into cur_rec;
1.

5
456
4"5"6

5
84  4 4"

|  ààà
Exlicit Cursor Îttriutes

V >;2—"2Dm'
6 m   
 #   )
 
V >2Dm
6 ';D% 
 
  

  
 #
) 
V >m2'2Dm
6 ';D% 
 
  

 ##*
# )  
 #  * 
( 

6 

 ';D%  >#  $%
V >§2 %m
6 
 

 
 
6 ';D%  
    
 $%

|  àà

Cursor Îttriutes-Exlicit

|  ààÚ
Cursor wit FOR loo

V   #5(   §m 5 


22
0
%m 22 1
V m  #
6 ' #  
  #5(  
6 ' 2 
6 ' 
 
  #5(  
6 ' "     #
#  

6 ' "

|  àà
|  ààx
Exle


 " 4 ""=  :à  "

"4  5 4,>>
"4  5 4,>)5& 5)">
"4  5 4,>>
8'4%&4 
''
"4  5 4,4 6  <<>><<45
<<>>>"""><<45"

1&''
"4  5 4,>>


|  àà½
Su queries in FOR loo

V 2;  #5(    ,  )-


22
0
%m 22 1
V m  #

6 #  
  #  # (  
6 §
 +
+    
)+ 

|  àà
Exle

Begin
FOR dep_rec IN (select * from emp where deptno=10 order by sal)
LOOP
«..
END LOOP;
End;

V §
#  
    # 
 

V m $ 

 %&





|  àà^
Cursor wit Preters


 " 4 ,4 "
" ,=  :4
44 6 

4 ,à  à  "
4  4
"4  5 4,45
 "4 
4 ,
 
 "
4  4
"4  5 4,45
 "4 


|  ààu
Locking

V 
 #

 ( #  #

V m   
  
  # # # #

 

V D U2; D $'%V    %%"'


 

V '     
)
 #  #  U—4%;%
"D;;%m' 2    V

|  à

FOR UPDÎTE

V )
& 
  
0
2; D $'% å2 "2D9m. åm2—$§'.
V 
 ;2—    #  #

V 2
   *   

   #  

  


V        #   

V %& 
6 %%"' < ;29 %9 —4%;% % 'm2
2; D $'%1

|  à
à
—´ERE CURRENT OF

V )
&
—4%;% "D;;%m' 2    1
V D #  D#
M 
 #
V ; 
    
)
 # )
 
V m ##
        # #
  

 # 
V %& 
6 %%'%  —4%;% "D;;%m' 2
)51

|  à

Exle

 
" )5 §
  
<     # 

2; D $'%1
 
5  )5>
) 1
 
0
%'"4 )5 §m'2  
5 1
#
 

—4%;% "D;;%m' 2 )51
00

|  à
Ú
Module 10:
Pckges

Ô  
   
| 
Introduction to Pckges

V :  
#  


  # 
 #
   3 
/ 
V " 
 # 
6 |   
6     C  #   
€ 


€  # 

6 "
6 $#    # "



|  à
x
Îdvntges of Pckges

V 9# 
)
6 ; 
# #    # #  
 
 

V §
 
6 (#    #  
 
   

 

V    3 

6 "     # )  )  


V 9  # §2
6  #
 # 

  )   

  # 
 



|  à
½
Îdvntges

V %&
# # 
 
)
6 $##
  
) (# #  
 
 # 
  
V  
)
6 # 
 
  
  # ( 

 #
  3 

V :  $ 
6   # (       ) 
6
  
 

  
V 2(  #
6 §  # 
   #     # 


 
 #    

|  à

Pckges -Restrictions

V m 
  
 #
6 "
   
 
    

 #
V  

6  
  *
   #    
V " 
  # 
)  

6       # ) ( ) 

 
 # 

   # 
)

|  à
^
Pckges

V " 
 
      #
6 D
       ) # 
  
6 " 
    # # 
  
6   
#  #
 
 J*
V "
    (( 
 

6    
/4 # 
! §#  #
 
—4$' 

  O
6  #)
! §  
#  
   

! "   
 

 

#


 # 

|  à
u
Pckge Secifiction

V )
&
";%$'% å2; ;% $"%. $"$:%   5 
§
|    
1
     #    
1
%m å  5  .1

|  àÚ
Pckge Secifiction

).
Ô1 1?'1 Ô1@ ÔA 71/4
%)
| 
)  " 
1&?/4@

1.
Ô1 1'1 Ô1 ÔA 71  "4/
%)
4  "&(01*: 
'Ô1(14  ",4 &(01
1&  "4/

|  àÚà
Pckge Bod

Ô1 1?'1 Ô1@ ÔA 71'3/4


%)
  
 "   
/"   
1&?/4@
V   (    #      #   #
#  # #
 #)
V ' )   

  #) / (

|  àÚ

Pckge Bod

àÔ1 1'1 Ô1 ÔA 71   "4/



%)
Ú 'Ô1(14  ",4 &(01
 %)
x 4"&(01
½ 17%&
 )11Ô"  
^ %&'4" 4  "
u 8'0
à  911 :4 
àà 4  "*:4"= 5
B4  "
à
 1&4  "
àÚ=1&  "4/
)a+C
/ 5

|  àÚÚ
Referencing Pckge oects

)a*+1D1Ô(1  "4/54  "*:à 


)a*+1D1Ô(1  "4/54  ", ^^

17%&
  "4/54  "*:

"4  5 4,  "4/54  "
5
  "4/54  ", Ú½u
1&

|  àÚ
Pulic nd Privte Meers

V  
      
  
  
6 $ #     
V §   #) 
 #  
  # 
  (   +     (

6 $  ) 



 #) # 

 #  
6 (
  

|  àÚx
Privte Meer -Exle
àÔ1 1'1 Ô1 ÔA 71   "4/

%)
Ú4"&(01
8(&Ô%'&4",4 &(01   
x1(&&(01
½%)
17%&
^)11Ô"
u%&'4"
à 8'0
àà911 :4 
à
1(&4"
àÚ1&
à'Ô1(11%1|14'&(),4 &(01
àx%)
à½17%&
à 4  "*:4",4 = 5

à^1&4  "
àu=1&  "4/
)a+C

/ 5

|  àÚ½
Session stte -Pckge vriles

V D #    (  
6 $   ) 
V §
 @
  #     
6
  
 #
 

  
V  
 (     
  

 
V |    # )     *

  ##
 # ) 
   

|  àÚ
Reoving t e Pckges

V ' #
   #)
6 ;2 $"$:% 2 T   5 
V ' #
    # 
6 ;2 $"$:%   5 
V $
  (
   #) 
 &

 #    #)    
#
V 

 # 
  # 
 #)   
  ( #

|  àÚ^
Overloding

V 2(  # 
  
 
  
 
V 2(  # 
 #      

 #     
   # 
  
·8(&Ô%'&  4",4 &(01
1(&&(01
·8(&Ô%'&  4",4| Ô9 
4 -
 1
1(&&(01
·'Ô1(14,- | Ô9 

·'Ô1(14,4| Ô9 
- 
| Ô9 


|  àÚu
One tie onl Procedures

1.
Ô1 1'1 Ô1 ÔA 714/
%)
44&(01*: 
'Ô1(14"
1&4/

|  à
One tie onl Procedures

Ô1 1'1 Ô1 ÔA 71'34/


%)
'Ô1(14"
%)
17%&
0)4'((5(4%&1,E& 5  "><<44
1&
17%& 7".    
"
)11ÔÔ'(&,=
%&'44
8'01
1&

|  àà
Exle

)a+1D1Ô(14/54"
& 5  "

)a+%&)1%&'1| (1),x >' "> >&3>

)a+)11ÔÔ'(&,=8'01

Ô'(&,=

x

)a+1D1Ô(14/54"
& 5  "

|  à

Coiler directives on functions

V   
   # 
(
V 4 
 

)  (  
   #


V ;$:9$;%';§"'5;%%;%m"%
, 
5  +—m +—m +;m +;m -
6 —m +—m 
  


 #

#
  #   (   
6 ;m +;m 
  


  #
#
  #   (   

|  àÚ
Built in ckges

V 952D' D'
V D'5§%
V 95$%;'
V 952"
V 95R2
V 95%§2m

|  à
Module 10:
Excetions

Ô  
   
| 
Introduction - Excetion

V $)   #




   & 

     %& 

V — )   # ;
 

|  à½
Excetion Block

V )
&
0
%Q"% '§2m
—4%m   5 5 & 
 '4%m
 #  C  

 

—4%m   5 5 & 
6 '4%m
 # 
%m 1

|  à
Excetion

V $)      ( 


  & 


V %& 
  

6 m  
 & 


6 4$m %; & 
 

 
   #    
V %& 
  

 (
  

#


|  à^
Need for Excetion

V —  % 
6 $
) 
 & 

  

6 ;2$"
V § %& 
  4 # #
6 

  
 
6  ( 
   #  
6 '  
 

 & 
  # 
6 
 ' 
   #


#    

|  àu
Deonstrte
V 2 ( # & 

  #
1Ô 1
4 10510&'631
17%&
%&)1%&'1| (1),xx F' "F F&3F
)11Ô
%&'4
8'0
911:EABCF
0)4'((5(4%&1,4 
1&

V —
   # 
77
 
#O
|  àx
Tes of Excetion

Exception

Non-
Pre-defined User-
Predefined
Exception defined
Exception

|  àxà
Pre-defined Excetions

V  #  # & 

V   # #   #

  #
& 
  #  

 )
V D   
 %§m% 
/  # 
V m  #
 %"$;% # §m|2%
·& 44  ·%4  ·Ô " 44 
· 44 " ·  4 · 44 4.

|  àx

Exle
1Ô 1
4 10510&'631
""
17%& "!
%&)1%&'1| (1),xx F' "F F&3F
)11Ô
%&'4
8'0
"!
911:EABCF
0)4'((5(4%&1,4 
1DÔ1%'&
91&&'4  48'(&91&
0)4'((5(4%&1,E   
1&

|  àxÚ
—´EN OT´ERS
V D # # & 
   
  # 

2'4%; 
)
1.
55
1DÔ1%'&
55
91&'91)91&
0)4'(( (4%&1,)aÔ'1
0)4'(( (4%&1,)a10
1&

V —      & 
+  #  
  # §     #   
#
2'4%;  #   & 
#
V D "2 % M %;;9
 

 
# #  
|  àx
User defined Excetion

V   # )    
V #     
6 9  

  H 7  ( #


V D   

6 %"$;%
6 %§m% M
6 §m|2%

|  àxx
User defined Excetion

V §  
  / %"$;%
6 %& 
5  %Q"% '§2m1
V § %& 
  C %§m%
6 —4%m %& 
5  '4%m
4 # 
V § %& 
  C §m|2%
6 ;$§% %& 
5 

|  àx½
Exle
1Ô 1
4 105 631
4- 105- 631
4 "1DÔ1%'&
17%&

%8,4- :E0 & 71F &4 +x 91&
 %)14 "
1&%8
55
1DÔ1%'&
91&4 "91&
5
1&

|  àx
Non-Predefined Excetion

V m   
#  # ) 
V  # 
    & 
   

 #
V D   
      
+   & 

  
 
V D   #

6 %"$;% # %§m% 

6 §
§m|2§m:  #
    
 
6 D   %Q% '§2m5§m§'
 

  #  # & 
   

 
#
|  àx^
Exle

1Ô 1
G 4 "1DÔ1%'&
 70 1DÔ1%'&4%&%, G 4 "  à
17%&
55
%&)1%&'1| (1),à >8> >Ô >
55
1DÔ1%'&
91& G 4 "91&
0)4'((5(4%&1,> . >

1&

V ;$:9$ %Q"% '§2m5§m§'


6 $
   U 
 
V 

 
# / 
V %& 
 
#   #+  # # # 
( #
|  àxu
RÎISE ÎPPLICÎTION ERROR

V D #
 
  #  #   

5
 %)14 %Ô %'&41',
à >Ô/Ô "
|  >


1'à*
' 
à *Ô/Ô "|  

|  à½
Progtion -Excetion

1Ô 1
4 10510&'631
17%&
%&)1%&'1| (1),xx F' "F F&3F
)11Ô
%&'4
8'0
911:EABCF
0)4'((5(4%&1,4 
1DÔ1%'&
91&&'4  48'(&91&
0)4'((5(4%&1,E   
1&

|  à½à
Progtion-Nested Blocks

1Ô 1

17%&
 44 
1. ""
5
17%&% /"
55
1DÔ1%'&1.   /
91&&'4  48'(&91&
55
1& % /"
55
55
1DÔ1%'& 1.    /
5

1&

|  à½

Progtion-Nested Blocks
1Ô 1

17%&
 44 "
1. ""
5
17%&% /"
55
1DÔ1%'&1.   /
91&&'4  48'(&91&
55
1& % /"
55
55
1DÔ1%'& 1.    /
5

1&

|  à½Ú
Progtion-Nested Blocks

1Ô 1
  44 1. 
17%&
"" /
  /"
5
17%&% /"
55
1DÔ1%'&1.   /
91&&'4  48'(&91&
55
1& % /"
55
55
1DÔ1%'& 1.    /
91&&'4  48'(&91&

1&

|  à½
RE-RÎISE

1Ô 1
  44 1. 
17%&
"" /
  /"
5
17%&% /"
55
1DÔ1%'&1.   /
91&&'4  48'(&91&
 %)1
1& % /"
55
55
1DÔ1%'& 1.    /
91&&'4  48'(&91&

1&

|  à½x
Module 11:
Triggers

Ô  
   
| 
— t  trigger is?

V   


  

  
 #

) 
  
( 

V "   
 
     #   ( 
 
    /
  
 
  

V :
  # 

 )
)
V '
  *   
#
  
  

  


|  à½
Need for  Trigger

V 2  
 #
  3 
   # # 

    

   
V $ 

    #   

   

& 
#

|  à½^
Tes of Triggers

%771)

"" )"" %" "

|  à½u
Coonents of Triggers

V ' 

6 — 
 
 

   
  

  
  

V '  ( 

6  
( 


  
   #
6 § 
 
#
# 

V '   
6 m  

  
  

|  à
Coonents of Triggers

V ' 
)
6 ' 
  
  &
C# #  

 
  #
6 

 
 (  C      

6 ;  (  C   # ( )  


#
   & 
#
V —   
6       
#  
  

6 $ # )  ;  ( 
 
V '  #)
6 %&  

  # 

  #

|  à à
Dtse Triggers

";%$'% å2; ;% $"%. ';§::%;


 5 
%2;%$'%;
§m%;' å2; %%'% 2;
D $'% å2 "2D9m. .
2m
 5 
 2"1

|  à

Dtse Triggers-Exle

";%$'% ';§::%;   5 


$'%;
D $'% 2 $
2m %9
%:§m
§m%;' §m'2
2:54§%,4§% $'%+D%;5m$9%-
|$D%,T $'%+D%;-1
%m 1
|  à Ú
Dtse Triggers-Exle

V 4  )
 
  (
 

& 
#  
 S )     
  )  O
V —

    
 
 #
 

  )  + 
6   
       +
6 #   ) #
6
  ( #   )O

|  à 
Stteent level & Row level Trigger

V #   


 
  #
6 

 
 ( 
6     

6 ;  ( 
6   # ( )  

#
 
#)  & 
#

|  à x
Row level Triggers

";%$'% å2; ;% $"%. ';§::%;


%2;%$'%;
§m%;' å2; D $'% 2; %%'%.
2m
 5 
å;%%;%m"§m: 2 $ # I m%— $  .
2; %$"4 ;2—
å—4%m #
.
 1

|  à ½
Row level Triggers

";%$'%';§::%; 5 5 )


$'%;
D $'%
2m%9
2;%$"4;2—
%:§m
§m%;'§m'2
2:54§%5%9 ,%9 m2+ ;%|$+"D;$-
|$D%,G2 %9 m2+G2 $+Gm%—$-1
%m 1

|  à
Row level Triggers

";%$'%2;;% $"%';§::%;';
$'%;
D $'%
2m%9
;%%;%m"§m:2 $ ;%|$m%—$"D;$
2;%$"4;2—
—4%m, ;%|$R28"%;8-
%:§m
§m%;'§m'2
4§5%9 54§';T,%9 m2+ ;%|$+"D;$-
|$D%,G ;%|$%9 m2+G ;%|$$+
G"D;$$-1
%m 1

|  à ^
Requireent - Deo

V —  (    )    #  


 ( # )  >
V —

  (
  O

 "4/4 
   " 
  

" : =à5à :* 5 


|  à u
Muttion Errors in Triggers

V — 
 #
  # 
    )   #
 

  

  
V %& 
§

  

  #
( 
 
)

# 

   # ) #
 #


 

|  à^
Row level Triggers

";%$'%';§::%; 5 5 ( 


%2;% " /  !
D $'%
2m%9
2;%$"4;2—
%:§m
§m%;'§m'2
2:54§%5%9 ,%9 m2+ ;%|$+"D;$-
|$D%,G2 %9 m2+G2 $+Gm%—$-1
Gm%—"299G7 1
%m 1

|  à^à
Insted of Triggers

V '   

  '   # 
 ( 
V §
# 
     )  ( 
# 

 
V :
 #  ) 9  
   
# ( 

 ( 
6 §
#  #
 ( + # 
   
#    
6 "   #  # 

  #)

|  à^

Sntx

";%$'% 2; ;% $"% ';§::%;


 5 
§m'%$ 2 ( 
2m ( 5 
 1
V —  ( 

 9 ( 
 
  
#
 #
 ( 5 

|  à^Ú
Insted of trigger

";%$'% 2; ;% $"% ';§::%; ';:


§m'%$ 2 §m%;' 2m "%;5|§%—
%:§m
§m%;' §m'2 2:,D%;5m$9%+ '%-
|$D%,D%;+T $'%-1
%m 1


|  à^
Sste Triggers

V "#  # #
  ( 

6 
! ";%$'%+ $'%; # ;2
6
  ( 

!  (  


#
!     

|  à^x
Sntx

";%$'% 2; ;% $"% ';§::%; ' 5 


å%2;% I$'%;.
å## ( 

I #
  5 ( 

.
å2mI $'$$%I å  .å"4%9$.
å—4%m "D$%.
å
 5#).

|  à^½
Exle

";%$'% ';§::%; 

5 5

$'%;
2:2m
2m "2''  
—4%m ,
5 ,T $'%+8#)8- 
 ,88+8
8--
 
 

  (  , +)#
-1
#1

|  à^
Exle-DDL triggers

";%$'% ';§::%; 

5##5

$'%;
";%$'% 2m  
 
 

  (   , +)#
-1
#1

|  à^^
Restrictions in Triggers

V '"  #  


 #
6 '
  *   
#
  
  

  

6 


  
     
 


#   
V $(# #
 
 9



|  à^u
Reoving Triggers

V ;2 ';§::%;
 5 
V ;2 ';§::%; 5 
5
 1
V $'%; ';§::%;
 5 
%m$%I §$%
V $'%; '$%
 5  %m$% §$%
$ ';§::%;

|  àu
Dt Dictionries -Triggers

V %" D%;52R%"'
V %" D%;52D;"%
V %" D%;5%;;2;
V %" D%;5';§::%;

|  àuà
Module 12:
Deendencies ong PL/SQL
Constructs

Ô  
   
| 
Deendnt nd Referenced Oects

V —   # #)  


 +
 #  #  # 

 #
 
   # )  #
6  #  #  # 
3 
C
#  # 

6 '      # 3 
C

   #
) 
  3 

V §    # 3 
 #  # #  # 

3 
 
#

|  àuÚ
Deendencies
V $
6 
 # 
Dm(  ;2"
6 ;2"

   #m2—
6 9  Dm
#
# #  



§m|$§
6 $'%;Dm"'§2mDm"29 §%
V  )
6 $'%;Dm"'§2m 
5  "29 §%
6 $'%; ;2"% D;% # 5  "29 §%
6 $'%; $"$:%  5  "29 §% $"$:%
6 $'%; $"$:%  5  "29 §%2 T
6 $'%;';§::%;
 5  
å%m$%I §$%I"29 §%å %D:.

|  àu
Deendencies - ckge

V  #)  #  # 
  # 
V "    #) # *

  

V 
     #  

 #)  #

  

#

|  àux
Direct nd Reote Deendencies

V  
#  #   &
 #  # 
3 

 
    ( 
V §    #  # 
3 
 

 #

#  
 (   
#  #   &


|  àu½
Dt Dictionr views

V %" D%;52R%"'
V %" D%;52D;"%
V %" D%;5%;;2;
V %" D%;5';§::%;
V %" D%;5 % %m %m"§%

|  àu