Oracle Plsql
-
Upload
peter-makram -
Category
Documents
-
view
49 -
download
2
description
Transcript of Oracle Plsql
-
5/17/2018 Oracle Plsql
1/232
ORACLE PLSQL
Procedural Language Structure Query Language
Part 1 : PLSQL CoursePart 2 : PLSQL practices and problems
Prepared By : Ashraf Omar Hussein
mail : ashraf!oh"hotmail#com
$obile %o : &2'1'1((2)1*
Oracle Complete PLSQL +eference '
-
5/17/2018 Oracle Plsql
2/232
Part 1 : PLSQL Course
1# ,hy do you need PLSQL-2# PLSQL Bloc. Structure
)# /ariables 0ypes
# Anonymous Bloc.(# Stored Procedure
# Parameter
3# Control Structure3#1 45 Condition
3#2 Case 6pression
3#) Loop
7# Cursor *# Handle 6ception
1'# 8ataBase 0ri99er
11# 5unction12# Pac.a9e
Oracle Complete PLSQL +eference 1
-
5/17/2018 Oracle Plsql
3/232
1)#
Q: ,hat is PLSQL -
A:4t is a procedural an9ua9e Structure Query lan9ua9e
Q: ,hy do you %eed PLSQL Lan9ua9e -
1 Bad peformance for the heay net;or. traffic
2 Cann
-
5/17/2018 Oracle Plsql
4/232
Q: Ho; does PLSQL sole the problems of the SQL commands-
1 By creatin9 a database Bloc.
Q: ,hat is a databloc. Bloc. -
1 4t is a dataase structure that contain one or more SQL commands
2 Bloc. re?uire that all SQL Commands to be correct for the e6ecution # if there is one SQL command is
not Correct then the ;hole bloc. ;ith all SQL Commands ;ill not be e6eucted
) 4f you ;rite more than one SQL statement you must separate them by usin9 semi comma =>
Q: ;hat are the bloc. types-
1 Anonymus Boc. 2 Subpro9ram Pro9ram nit
%ot stored or saed in the 8B serer Stored or saed in the 8B serer
%ot shared for all users Shared for all users
6ecuted only once 6ecuted many times as user re?uestsCreated and e6ecuted durin9 run time Created before the e6ecution time
Cann
-
5/17/2018 Oracle Plsql
5/232
Q: ,hat is a /ariable-
1# 4s a space located in the memory can be used 5or 4mpermanent stora9e of One an O%LD One /alue
2# /ariable can store alue identified by the user himself O+ alue retrieed form the data base table
Q: ,hy do you use a ariable-
1E 0emporary stora9e of data:
1#1 8ata can be temporarily stored in one or more ariables for use ;hen alidatin9 data input andfor processin9 later in the data flo; process such as Lo9in ,indo; ;e store the user name and
pass;ord 5or user to chec. for these t;o alues if they are stored in the data base the user ;ill be
lo9ined successfully and if they are not stored in the data base the user ;ill not be able to lo9in#
2# $anipulation of stored alues:
2#1 /ariables can be used for calculations and other data manipulations ;ithout accessin9 database#2#2 store alues for calculation and the result of these calculations ;ill be displayed in the report
)E +eusability:
)#1 After they are declaredF ariables can be used repeatedly in an application simply by referencin9
them in other statementsF includin9 other declaratie statements such as local ariables and 9lobalariables#
E ase of maintenance:
#1 declare ne; ariable has the same data type of other ariable
#2 declare ne; ariable has the same data type of data base column and ;hen chan9in9 the alue in
the database this alue ;ill chan9ed automatically in the ariable such as create ariable storin9 the
ma6 alue in empno column to create application tri99er to increment this alue for the ne6t record
Q: Ho; do you declare a ariable-
1# Dou must declare a ariable in the declaration part of the bloc.2# Dou can decalre more than one ariable in the same bloc. B0 you must
2#1 define each aribale in a separate line2#2 end each aribale ;ith a semi comma =>
)# ach ariable $ust has GnameF data type mandatoryF Gnull abilityF default alue optional
Q: ;hat are the rules of the /ariable name -
1# /ariable names are uni?ue ;ithin the same bloc. but ariable name may be duplicated in other bloc.
2# Len9th bet;een 1E)' charater len9th
)# $ust start ;ith character %O0 ;ith number or special character B0 it may include numbers and specialcharacter inside the name or at the end
# /ariable name mustn
-
5/17/2018 Oracle Plsql
6/232
Q: ;hat are the rules ;hen you Assi9n a alue for the /ariabe -
1# 4t is 9ood code to assi9n alue for the ariable because if you did not assi9n alue then null ;ill be inserted
2# 0o assi9n alue for the ariable you can use :Jor use 85AL0as .ey;ord
)# /ariable alue can be constant alue or default alue or e6pression
# Assi9nin9 strin9 alue must be enclosed bet;een sin9le ?uotes But numeric alue does not re?uire sin9le
?uotes
(# 4f you assi9n alue for the ariable in the declaration section and assi9n ne; alue for the ariable in the
e6ecution section the ne; alue ;ill replace the old alue in the declaration part
Q: ,hat are the data types for the ariables
1# Char=n>
2# /arcahr2=n>
)# %umber=n># %umber=mFn>
(# 8ate
# Binary!inte9er3# Boolean
7# Lon9
*# Lon9 ra;
Oracle Complete PLSQL +eference (
-
5/17/2018 Oracle Plsql
7/232
6amples for decalrin9 ariables
1# se user defined datatype
8eclare!Kob archar2=2'> null
!location archar2=('> null :J IcairoI
!deptno number=(> not null :J1'
!total!sal number=*F2> :J'
!m9r number=> 85AL01''c!comm CO%S0A%0number=(> null 85AL0 1''
!hire!date date :J0O!CHA+=I1**7'71IF IyyyymmddI>!orderdate date :JSDS8A0 & )
c!ta6!rate CO%S0A%0numebr=(F2> :J '#1(
!alid BOOLA% not null :J0+
2# se 0abe%ame#Column%ameMtype
8eclare
!Kob emp#KobMtype
!location dept#dnameMtype :J IcairoI !deptno dept#deptnoMtype not null :J1'
!total!sal emp#salMtype :J'
!m9r emp#m9rMtype 85AL01''c!comm CO%S0A%0emp#commMtype :J 1''
!hire!date emp#hiredateMtype :J0O!CHA+=I1**7'71IF IyyyymmddI>
)# se /ariableMtype
8eclare
!Kob emp#KobMtype
!location !KobMtype :J IcairoI
!deptno dept#deptnoMtype not null :J1'!total!sal !deptnoMtype :J'
!m9r !deptnoMtype 85AL01''c!comm CO%S0A%0emp#commMtype :J 1''
!hire!date emp#hiredateMtype :J0O!CHA+=I1**7'71IF IyyyymmddI>
# se 0able%ameMro;type
#1 8ecalre only one ariable that store the alue for all ro; in the table
#2 you can print the ;hole ro; alue or print a specific alues only
8eclare
mp!+o; mpM+o;0ype
be9in8B$S!O0P0#P0!L4% =mp!+o;#mpno>
8B$S!O0P0#P0!L4% =mp!+o;#name>
8B$S!O0P0#P0!L4% =mp!+o;#Salary>
nd
Oracle Complete PLSQL +eference
-
5/17/2018 Oracle Plsql
8/232
(# se recod data type
(#1 create an obKect of record data type
(#2 create a ariable based on that obKect type
8eclare
0DPemp!record!type 4S+CO+8
=employee!id %$B+=> %O0 %LL :J 1''F
last!name employees#last!nameM0DPF
Kob!id employees#Kob!idM0DP>
emp!record emp!record!type
# use table data type
8eclare
0ype mp!0able is 0able of $PM+o;0ype
4nde6 by binary inte9er/!mp mp!table
8B$S!O0P0#P0!L4%:
1# P+4%0 command# is 8B$S!O0P0#P0!L4%# 8B$S!O0P0 is OracleEsupplied pac.a9eF andP0!L4% is a procedure ;ithin that pac.a9e#
2# ,ithin a PLSQL bloc.F reference 8B$S!O0P0#P0!L4% andF in parenthesesF specify the strin9
that you ;ant to print to the screen# 0he pac.a9e must first be enabled in your SQLNPlus session# 0o do
thisF e6ecute the SQLNPlus
SQL S0 S+/+O0P0 O% command#
Oracle Complete PLSQL +eference 3
-
5/17/2018 Oracle Plsql
9/232
Anonymus Bloc. Best Practices
1# Ho; to ;rite 4nsert Statement ;ithout /ariables
2# Ho; to ;rite 4nsert Statement ;ith /ariables
Oracle Complete PLSQL +eference 7
-
5/17/2018 Oracle Plsql
10/232
)# Ho; to ;rite pdate Statement ;ithout /ariables
# Ho; to ;rite pdate Statement ;ith /ariables
Oracle Complete PLSQL +eference *
-
5/17/2018 Oracle Plsql
11/232
(# Ho; to ;rite 8elete Statement ;ithout /ariables
4t is not possible to ;rite the select statement ;ithout ariables because araibles are $A%8A0O+D in this ca
Because the synta6 for the SLC0 statement is differe from the normal SLC0 stamtent ;ritten by SQL
Oracle Complete PLSQL +eference 1'
SLC0usin9 SQLSyntac SLC0usin9 PLSQLsynta6
Select
5rom table name
,hereroup by
Hain9
Order by
Select
4%0O ariabls EEEEEEE %e;
5rom table name
,hereroup by
Hain9
Order by
/ariables are decalred imlicitly by oracle /ariables are decalred 6plicitly by 8eeloper
/alues are printed implicitly by oralce /alues are printed 6plicitly by 8eeloper
-
5/17/2018 Oracle Plsql
12/232
# Ho; to ;rite pdate Statement ;ith /ariables
Dou must declare ariables ;ith the same number of the columns that you retriee in your select statement
1# 8ecalre ariables for each column you retrie in select statement
2# Select column into ariable)# Print alue for the ariable by usin9 8B$S!O0P0#P0!L4%
# you must enable 8B$S!O0P0#P0!L4% first by runnin9 command
(# SQL set sereroutput on # 8B$S!O0P0#P0!L4% is used to prin9 alue for one ariable only #
3# 4f you print alues for more that one ariable then you can use Concat function or ;rite
8B$S!O0P0#P0!L4% more than one time for each araible you ;ant to prin9
Oracle Complete PLSQL +eference 11
-
5/17/2018 Oracle Plsql
13/232
Oracle Complete PLSQL +eference 12
-
5/17/2018 Oracle Plsql
14/232
3# Ho; to ;rite more that 8$L transactions ;ithin the anonymus bloc.
Oracle Complete PLSQL +eference 1)
-
5/17/2018 Oracle Plsql
15/232
7# Ho; to ;rite more that 8$L transactions ;ithin the anonymus bloc.
Oracle Complete PLSQL +eference 1
-
5/17/2018 Oracle Plsql
16/232
*# sin9 Subsutitution /ariable By usin9 ;ild card &
Oracle Complete PLSQL +eference 1(
-
5/17/2018 Oracle Plsql
17/232
*#1 sin9 Subsutitution /ariable By usin9 ;ild card &
*#2 sin9 Subsutitution /ariable By usin9 ;ild card &
Oracle Complete PLSQL +eference 1
-
5/17/2018 Oracle Plsql
18/232
*#) sin9 Subsutitution /ariable By usin9 ;ild card &
Oracle Complete PLSQL +eference 13
-
5/17/2018 Oracle Plsql
19/232
1' # sin9 +O,M0DP as a datatype
1# it can be used ;hen you retriee all cloumns from the table
2# you can print all the alues or Kust a specific alues only
Oracle Complete PLSQL +eference 17
-
5/17/2018 Oracle Plsql
20/232
11 # sin9 +CO+8M0DP as a datatype
Oracle Complete PLSQL +eference 1*
-
5/17/2018 Oracle Plsql
21/232
Subpro9ram J Pro9ram nit
1# Stored Procedure
Parameters are optional not mandatory
8eclaration Part Optional
Body$andatory
8eclaration Part Optional
1# all Stored procedures created are stored in user!obKects
2# source code is stored in user!source
Oracle Complete PLSQL +eference 2'
-
5/17/2018 Oracle Plsql
22/232
1#1 procedure ;ithout parameters
Oracle Complete PLSQL +eference 21
-
5/17/2018 Oracle Plsql
23/232
1#1 procedure ;ithout parameters
1#1 procedure ;ithout parameters
Oracle Complete PLSQL +eference 22
-
5/17/2018 Oracle Plsql
24/232
1#1 procedure ;ithout parameters
Oracle Complete PLSQL +eference 2)
-
5/17/2018 Oracle Plsql
25/232
1#1 procedure ;ithout parameters usin9 0ABL%A$M+O,0DP as a datatype
sin9 +O,M0DP as a datatype
1# it can be used ;hen you retriee all cloumns from the table
2# you can print all the alues or Kust a specific alues only
Oracle Complete PLSQL +eference 2
-
5/17/2018 Oracle Plsql
26/232
1#1 procedure ;ithout parameters usin9 0ABL%A$M+O,0DP as a datatype
sin9 +O,M0DP as a datatype
Oracle Complete PLSQL +eference 2(
-
5/17/2018 Oracle Plsql
27/232
1#1 procedure ;ithout parameters usin9 +CO+8 8A0A0DP as a datatype
sin9 +CO+8 8A0A0DP as a datatype
Oracle Complete PLSQL +eference 2
-
5/17/2018 Oracle Plsql
28/232
1#2 procedure ;ith parameters
Parameter type are
1# 4% Parameter EEEE 8efault type
2# O0 Parameter)# 4% O0 Parameter
Dou can define more that one parameters in the same procedure
All parameters are defined after the procedure name
Oracle Complete PLSQL +eference 23
-
5/17/2018 Oracle Plsql
29/232
1#2 procedure ;ith parameters EE 4% parameter
Oracle Complete PLSQL +eference 27
-
5/17/2018 Oracle Plsql
30/232
1#2 procedure ;ith parameters EE 4% parameter
Oracle Complete PLSQL +eference 2*
-
5/17/2018 Oracle Plsql
31/232
1#2 procedure ;ith parameters EE 4% parameter
Oracle Complete PLSQL +eference )'
-
5/17/2018 Oracle Plsql
32/232
1#2 procedure ;ith parameters EE 4% parameter
Oracle Complete PLSQL +eference )1
-
5/17/2018 Oracle Plsql
33/232
1#2 procedure ;ith parameters EE 4% parameter
Oracle Complete PLSQL +eference )2
-
5/17/2018 Oracle Plsql
34/232
1#2 procedure ;ith parameters EE 4% parameter
Oracle Complete PLSQL +eference ))
-
5/17/2018 Oracle Plsql
35/232
1#2 procedure ;ith parameters EE 4% parameter
1#2 procedure ;ith parameters EE 4% parameter
Oracle Complete PLSQL +eference )
-
5/17/2018 Oracle Plsql
36/232
1#2 procedure ;ith parameters EE 4% parameter
Oracle Complete PLSQL +eference )(
-
5/17/2018 Oracle Plsql
37/232
1#2 procedure ;ith parameters EE 4% Parameter usin9 0ABL%A$M+O,0DP as a datatype
Oracle Complete PLSQL +eference )
-
5/17/2018 Oracle Plsql
38/232
1#2 procedure ;ith parameters EE 4% Parameter usin9 0ABL%A$M+O,0DP as a datatype
1#2 procedure ;ith parameters EE 4% Parameter usin9 +CO+8 8A0A0DP as a datatype
Oracle Complete PLSQL +eference )3
-
5/17/2018 Oracle Plsql
39/232
Part 1 : PLSQL Course
Control Structure0here are three 0ype of Control Structure
1 45 Condition
2 Case 6pression
) Loop
Oracle Complete PLSQL +eference )7
-
5/17/2018 Oracle Plsql
40/232
45 Condition
Oracle Complete PLSQL +eference )*
-
5/17/2018 Oracle Plsql
41/232
45 Condition
0here Are 0hree 0ypes of 45 Statement
1 45 Stamtement ;ith O%LD one Conditon
Synta6 45 Condition1 then Action1 %8 45
2 45 Stamtement ;ith O%LD t;o Conditons
Synta6 45 Condition1 then Action1 LS Action2
%8 45
) 45 Stamtement ;ith $O+ than t;o Conditons
Synta6 45 Condition1 then Action1
LS45 Condition2 then Action2
LS45 Condition) then Action) LS45 Condition then Action
LS action (
%8 45
All conditions in 45 statements are Boolean e6pressions that ealuate to true or false#
All Actions in 45 Statements are PLSQL statementsDou can e6ecute many actions as you li.e ;hen the actions is 0+
45 Stamtement ;ith O%LD one Conditon
Oracle Complete PLSQL +eference '
-
5/17/2018 Oracle Plsql
42/232
45 Stamtement ;ith O%LD one Conditon
Oracle Complete PLSQL +eference 1
-
5/17/2018 Oracle Plsql
43/232
45 Stamtement ;ith O%LD t;o Conditons
Oracle Complete PLSQL +eference 2
-
5/17/2018 Oracle Plsql
44/232
45 Stamtement ;ith $O+ than t;o Conditons
Oracle Complete PLSQL +eference )
-
5/17/2018 Oracle Plsql
45/232
45 Stamtement ;ith $O+ than t;o Conditons
Oracle Complete PLSQL +eference
-
5/17/2018 Oracle Plsql
46/232
create or replace procedure rep1=p1 number>
is
sal number=(>2 archar2=2'>
be9in
select salinto sal
from emp
;here empno J p1if L%0H=sal> then
2 :J to!char=salFI''''''I>
dbms!output#put!line=2>
end ifend
Oracle Complete PLSQL +eference (
-
5/17/2018 Oracle Plsql
47/232
CAS 6pression
Oracle Complete PLSQL +eference
-
5/17/2018 Oracle Plsql
48/232
CAS 6pression
Create or replace procedure rep1(p1 number)
Is
V_sal number(5);
Begin
Select sal
Into v_sal
From scott.EmpWhere empno = p1;
v_sal := CASE v_sal When null then 50 ;
When
-
5/17/2018 Oracle Plsql
49/232
Loop
Oracle Complete PLSQL +eference 7
-
5/17/2018 Oracle Plsql
50/232
Loop
,hat is Loop -
4t is a techni?ue that can be used to run spefic code more that one time ;ithin the bloc.
,hy do you use Loop-
Dou may use a loop to run one or more statements multiple times
,hat are Loop types -1# Basic Loop Simple Loop2# 5or loop
)# ,hile Loop
4n loop you must ;rite a condition to e6ist the loop # 4f you didn
Basic Loop Simple Loop
A simple loop runs until you explicitly end the loop.
To end the loop, you use either an EXIT or EXIT WHEN statement.
The EXIT statement ends a loop immediately.
EXIT WHEN statement ends a loop when a specified condition occurs.
Basic oop !yntax
Oracle Complete PLSQL +eference *
-
5/17/2018 Oracle Plsql
51/232
Basic Loop
Oracle Complete PLSQL +eference ('
-
5/17/2018 Oracle Plsql
52/232
Basic Loop
Oracle Complete PLSQL +eference (1
-
5/17/2018 Oracle Plsql
53/232
Basic Loop
Basic Loop ;ith 45 condition
Oracle Complete PLSQL +eference (2
-
5/17/2018 Oracle Plsql
54/232
Basic Loop LABL Loop
Basic Loop
Oracle Complete PLSQL +eference ()
-
5/17/2018 Oracle Plsql
55/232
Oracle Complete PLSQL +eference (
-
5/17/2018 Oracle Plsql
56/232
Basic Loop
Oracle Complete PLSQL +eference ((
-
5/17/2018 Oracle Plsql
57/232
5or Loop
A "#$ loop runs a predetermined num%er of times.
&ou can use a 'aria%le directory in the %ody without declarin( it in the declaration
Basic oop !yntax
Where )
*. oop+'aria%le specifies the loop 'aria%le2# +/+S specifies that the loop ariable alue is to be decremented each time throu9h the loop#
. lower+%ound specifies the loop-s lower %ound
. upper+%ound specifies the loop-s upper %ound
/. If $E0E$!E is used, the loop 'aria%le is initiali1ed to this upper %ound
2. The upper or lower %ounds of the "#$ loop can %e defined as 'aria%lesor functions.
Oracle Complete PLSQL +eference (
-
5/17/2018 Oracle Plsql
58/232
5or Loop
Oracle Complete PLSQL +eference (3
-
5/17/2018 Oracle Plsql
59/232
Oracle Complete PLSQL +eference (7
-
5/17/2018 Oracle Plsql
60/232
5or Loop
Oracle Complete PLSQL +eference (*
-
5/17/2018 Oracle Plsql
61/232
Oracle Complete PLSQL +eference '
-
5/17/2018 Oracle Plsql
62/232
5or Loop
Oracle Complete PLSQL +eference 1
-
5/17/2018 Oracle Plsql
63/232
5or Loop
Oracle Complete PLSQL +eference 2
-
5/17/2018 Oracle Plsql
64/232
5or Loop
Oracle Complete PLSQL +eference )
-
5/17/2018 Oracle Plsql
65/232
5or Loop
Oracle Complete PLSQL +eference
-
5/17/2018 Oracle Plsql
66/232
Oracle Complete PLSQL +eference (
-
5/17/2018 Oracle Plsql
67/232
+eersed 5or Loop ;ith +/+S Rey ,ord
Oracle Complete PLSQL +eference
-
5/17/2018 Oracle Plsql
68/232
Oracle Complete PLSQL +eference 3
-
5/17/2018 Oracle Plsql
69/232
5or Loop
Oracle Complete PLSQL +eference 7
-
5/17/2018 Oracle Plsql
70/232
5or Loop
Oracle Complete PLSQL +eference *
-
5/17/2018 Oracle Plsql
71/232
,hile Loop
Oracle Complete PLSQL +eference 3'
-
5/17/2018 Oracle Plsql
72/232
,hile Loop
Oracle Complete PLSQL +eference 31
-
5/17/2018 Oracle Plsql
73/232
,hile Loop ;ith Parameters
Oracle Complete PLSQL +eference 32
-
5/17/2018 Oracle Plsql
74/232
,hile Loop
Oracle Complete PLSQL +eference 3)
-
5/17/2018 Oracle Plsql
75/232
,hile Loop
Oracle Complete PLSQL +eference 3
-
5/17/2018 Oracle Plsql
76/232
,hile Loop
Oracle Complete PLSQL +eference 3(
-
5/17/2018 Oracle Plsql
77/232
Cursor
6plicit Cursor
4mplicit Cursor
+eference Cursor
Cursor
Oracle Complete PLSQL +eference 3
-
5/17/2018 Oracle Plsql
78/232
0opics
Cursor1# 4ntroduction= 1) >
2# Cursor 8eclaration= 1 >
)# Cursor Open= ) ># 5etch= 13 >
(# LOOP= 1' >
# Close Cursor= >
3# Cursor Status= >7# 4mplicit Cursor= 17 >
*# 6plicit Cursor= 2 >
1'# Cursor for pdate= ( >11# Cursor Parameter= >
12# ref cursor= >
1)# +5C+SO+= * >1# Cursor Attributes= * >
1(# refcursor= ) >
1# Cursor function= ( >
Q: ,hat is Cursor-
1# Cursor is a space in the memory that can be used to store more than O% record
2# cursor is basically a set of ro;s that you can access one at a time#)# Cursor can accept parameters
Q: ;hen do you use a Cursor-
Dou use a cursor ;hen you hae a SLC0 statement that returns more than one ro; from the database#
Q: Ho; do you use a Cursor-
1# 8eclare ariables to store the column alues from the SLC0 statement#
2# 8eclare the cursor F specifyin9 your SLC0 statement#)# Open the cursor#
# 5etch the ro;s from the cursor#(#Close the cursor#
8eclaration part
8eclaration partBody part
Body partBody part
Q: ;hat is the synta6 for the cursor -
Oracle Complete PLSQL +eference 33
http://www.java2s.com/Tutorial/Oracle/0500__Cursor/Catalog0500__Cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0020__Introduction.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0040__Cursor-Declaration.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0050__Cursor-Open.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0060__Fetch.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0080__LOOP.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0100__Close-Cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0120__Cursor-Status.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0140__Implicit-Cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0141__Explicit-Cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0160__Cursor-for-Update.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0180__Cursor-Parameter.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0200__ref-cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0220__REFCURSOR.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0240__Cursor-Attributes.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0260__refcursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0280__Cursor-function.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Catalog0500__Cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0020__Introduction.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0040__Cursor-Declaration.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0050__Cursor-Open.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0060__Fetch.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0080__LOOP.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0100__Close-Cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0120__Cursor-Status.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0140__Implicit-Cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0141__Explicit-Cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0160__Cursor-for-Update.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0180__Cursor-Parameter.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0200__ref-cursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0220__REFCURSOR.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0240__Cursor-Attributes.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0260__refcursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/0280__Cursor-function.htm -
5/17/2018 Oracle Plsql
79/232
Cursor
Q: Ho; do you use a Cursor-
Open 6ecute the SLC0 statement
5etch 1# +ead column alues into the ariables that you specify
2# you must use LOOP to 5etch more than one record)# 4f you did
-
5/17/2018 Oracle Plsql
80/232
Cursor ;ith %O Loop
4f you didn
-
5/17/2018 Oracle Plsql
81/232
Cursor ;ith Basic Loop to 5etch cursor till cursor%ameM%O05O%8
Oracle Complete PLSQL +eference 7'
-
5/17/2018 Oracle Plsql
82/232
Cursor ;ith Basic Loop to 5etch cursor till cursor%ameM%O05O%8
Oracle Complete PLSQL +eference 71
-
5/17/2018 Oracle Plsql
83/232
Cursor ;ith 5or Loop
Cursor ;ith ,hile Loop
Oracle Complete PLSQL +eference 72
-
5/17/2018 Oracle Plsql
84/232
Cursor with While Loop to Fetch cursor till cursorName%NOTFOUND
Cursor for count
Oracle Complete PLSQL +eference 7)
-
5/17/2018 Oracle Plsql
85/232
Cursor to reference whole table
Cursor%ameM4SOP%
Cursor%ameM5O%8 or Cursor%ameM%O05O%8
Oracle Complete PLSQL +eference 7
-
5/17/2018 Oracle Plsql
86/232
Cursor%ameM+O,CO%0
Oracle Complete PLSQL +eference 7(
-
5/17/2018 Oracle Plsql
87/232
Cursor ;ith Parameters
Oracle Complete PLSQL +eference 7
-
5/17/2018 Oracle Plsql
88/232
Cursor ;ith Parameters
Oracle Complete PLSQL +eference 73
-
5/17/2018 Oracle Plsql
89/232
Cursor ;ith Parameters
Cursor ;ith Parameters
Oracle Complete PLSQL +eference 77
-
5/17/2018 Oracle Plsql
90/232
4mplicit Cursor
4mplicit cursor openF fetch and close
Open ,hen you be9in the body by ;ritin9 B4% .ey;ord
5etch ,hen you start the Loop statement by ;ritin9 =basic loop F for loop F ;hile Loop>
Close ,hen you end the Loop statement by ;ritin9 =end loop> .ey ;ord
Oracle Complete PLSQL +eference 7*
6 licit Cursor 8eclaraion
-
5/17/2018 Oracle Plsql
91/232
4mplicit Cursor
Oracle Complete PLSQL +eference *'
4mplicit Cursor 8eclaration
-
5/17/2018 Oracle Plsql
92/232
4mplicit Cursor
4mplicit cursors: SQLM+O,CO%0 returns number of ro;s affected by SQL statement
Oracle Complete PLSQL +eference *1
http://www.java2s.com/Code/Oracle/PL-SQL/ImplicitcursorsSQLROWCOUNTreturnsnumberofrowsaffectedbySQLstatement.htmhttp://www.java2s.com/Code/Oracle/PL-SQL/ImplicitcursorsSQLROWCOUNTreturnsnumberofrowsaffectedbySQLstatement.htm -
5/17/2018 Oracle Plsql
93/232
4mplicit Cursor
Oracle Complete PLSQL +eference *2
-
5/17/2018 Oracle Plsql
94/232
+eference Cursor
0he +5 C+SO+ datatype cannot be used outside a PLSQL enironment#
0here are t;o .inds of +5 C+SO+ types:1# ;ea.
2# stron9#
,ea. +eference Cursor can point to any data setF as sho;n here:Stron9 +eference Cursor 6plicitly declares the type of data that can be referenced#
,ea. +ef Cursor
1#
SQL 8eclaretype ;ea.!rcty is ref cursor
c!;ea. rcty ;ea.!rcty
2#
declarec!;ea. sys!refcursor
Stron9 +ef Cursor
declare
type stron9!rcty is ref cursor return employeeM+O,0DP
c!stron9!rcty stron9!rcty
Oracle Complete PLSQL +eference *)
-
5/17/2018 Oracle Plsql
95/232
,ea. +eference Cursor
,ea. +eference Cursor
Oracle Complete PLSQL +eference *
-
5/17/2018 Oracle Plsql
96/232
Weak Reference Cursor
Oracle Complete PLSQL +eference *(
-
5/17/2018 Oracle Plsql
97/232
Oracle Complete PLSQL +eference *
-
5/17/2018 Oracle Plsql
98/232
,ea. +eference Cursor
Oracle Complete PLSQL +eference *3
-
5/17/2018 Oracle Plsql
99/232
6ception Handlin9
6ception Handlin9 Handlin9 PLSQL rrors
Q: ,hat is 6ception-
4n PLSQLF the user can catch certain runtime errors#6ceptions can be internally defined by Oracle or the user#
Q: ,hat is 6ception Handlin9-
1# 6ceptions are used to handle errors that occur in your PLSQL code#
2# you can use more than one TCP04O% in the same Bloc.)# Dou could al;ays code a %LL statement if no action is to be ta.en#
# you can declare ariables in the 6ception handler
Oracle Complete PLSQL +eference *7
-
5/17/2018 Oracle Plsql
100/232
Q: ,hat are the oracle rror 0ypes-
0here are three types of e6ceptions:1# Predefined Oracle errors
2# ndefined Oracle errors
)# serEdefined errors4dentifyin9 6ception 0ypes
Q: ;hat are the 6ception 0ypes -
1# PreEdefined 6ception2# Custom 6ception
Q: ;hat are the different parts of the e6ception-
0he different parts of the e6ception# 1# 8eclare the e6ception#
2# +aise an e6ception#
)# Handle the e6ception#
An e6ception has four attributes:
1# %ame proides a short description of the problem# 2# 0ype identifies the area of the error#
)# 6ception Code 9ies a numeric representation of the e6ception#
# rror messa9e proides additional information about the e6ception#0he predefined diideEbyE@ero e6ception has the follo;in9 alues for the attributes:
1# %ame J U+O!84/48
2# 0ype J O+A =from the Oracle en9ine> )# 6ception Code J C'13
# rror messa9e J diisor is e?ual to @ero
Ho; do you ;rite TCP04O% in the PLSQL BLOCR-
PreE8efined 6ceptions
6ception Oracle rror SQLCO8 /alue
%O!8A0A!5O%8 O+AE'1') Sin9le SLC0 statement returned no data
0OO!$A%D!+O,S O+AE'122 Sin9le SLC0 statement returned more than one ro;
data#
U+O!84/48 O+AE'13 A pro9ram attempts to diide a number by @ero#
/AL!++O+ O+AE'('2 An arithmeticF conersionF truncationF or
si@eEconstraint error occurs#5or e6ampleF ;hen your pro9ram selects a column a
Oracle Complete PLSQL +eference **
Error Code Prefix Indicates This Exception Type of Error
O+A Core +8B$S errors
PLS PLSQL errors5+$ Oracle 5orms errors
+P Oracle +eports errors
-
5/17/2018 Oracle Plsql
101/232
into a character ariableF
if the alue is lon9er than the declared len9th
of the ariableFPLSQL aborts the assi9nment and raises
/AL!++O+# 4n procedural statementsF
/AL!++O+ is raised if the conersion of acharacter strin9 into a number fails# =4n SQL statemen
4%/AL48!%$B+ is raised#>
8P!/AL!O%!4%8T O+AE''''1 A pro9ram attempts to store duplicate alues in adatabase column that is constrained by a uni?ue inde6
4%/AL48!%$B+ O+AE'1322 4n a SQL statementF the conersion of a character strininto a number fails because the strin9 does not
represent a alid number# =4n procedural statementsF
/AL!++O+ is raised#> 0his e6ception is also rai;hen the L4$40Eclause e6pression in a bul. 50CH
statement does not ealuate to a positie number#
ACCSS!4%0O!%LL O+AE'()' A pro9ram attempts to assi9n alues to the attributes o
an uninitiali@ed obKect#
CAS!%O0!5O%8 O+AE'(*2 %one of the choices in the ,H% clauses of a CAS
statement is selectedF and there is no LS clause#COLLC04O%!4S!%LL O+AE'()1 A pro9ram attempts to apply collection methods otherthan T4S0S to an uninitiali@ed nested table or array
or the pro9ram attempts to assi9n alues to the
elements of an uninitiali@ed nested table or array#
4%/AL48!C+SO+ O+AE'1''1 A pro9ram attempts a cursor operation that is not
allo;edF such as closin9 an unopened cursor#
LO4%!8%48 O+AE'1'13 A pro9ram attempts to lo9 on to Oracle ;ith an inali
username or pass;ord#
%O0!LO8!O% O+AE'1'12 A pro9ram issues a database call ;ithout bein9
connected to Oracle#
P+O+A$!++O+ O+AE'('1 PLSQL has an internal problemSBSC+4P0!O0S48!L4$40 O+AE'()2 A pro9ram references a nested table or array element
usin9 an inde6 number =E1 for e6ample> that is outside
the le9al ran9e#
SDS!4%/AL48!+O,48 O+AE'11' 0he conersion of a character strin9 into a uniersal
ro;id fails because the character strin9 does not
represent a alid ro;id#
04$O0!O%!+SO+C O+AE'''(1 A timeEout occurs ;hile Oracle is ;aitin9 for a resour
PreE8efined 6ceptions
6ception Oracle rror SQLCO8 /alue
SBSC+4P0!BDO%8!CO%0 O+AE'()) A pro9ram references a nested table or array elemen
usin9 an inde6 number lar9er than the number of
elements in the collection#
+O,0DP!$4S$A0CH O+AE'(' 0he host cursor ariable and PLSQL cursor ariable
inoled in an assi9nment hae incompatible return
types# 5or e6ampleF ;hen an open host cursor ariabl
Oracle Complete PLSQL +eference 1''
-
5/17/2018 Oracle Plsql
102/232
is passed to a stored subpro9ramF the return types of
the actual and formal parameters must be compatible#
SL5!4S!%LL O+AE)'2( A pro9ram attempts to call a $$B+ methodF but t
4nstance of the obKect type has not been initiali@ed# 0h
builtEin parameter SL5 points to the obKectF and isAl;ays the first parameter passed to a $$B+
method#
S0O+A!++O+ O+AE'('' PLSQL runs out of memory or memory has been
Corrupted#C+SO+!AL+A8D!OP% O+AE'(11 A pro9ram attempts to open an already open cursor# ACursor must be closed before it can be reopened# A
cursor 5O+ loop automatically opens the cursor to
;hich it refersF so your pro9ram cannot open thatcursor inside the loop#
O0H+S 1# Any other error occurred#2# Dou can use the O0H+S e6ception to handle all
e6ceptions
)# Because O0H+S handles all e6ceptionsF you muslist it after any specific e6ceptions in your TCP04O
bloc.#
Create the follo;in9 mployee and 8epartment tables to be used in the follo;in9 e6ercises
;hen %O!8A0A!5O%8 then
+aised ;hen Sin9le SLC0 statement returned no data
Oracle Complete PLSQL +eference 1'1
-
5/17/2018 Oracle Plsql
103/232
,hen 0OO!$A%D!+O,S then
+aised ;hen Sin9le SLC0 statement returned more than one ro; of data#
Oracle Complete PLSQL +eference 1'2
System rrorser 6ception
System rror
ser 6ception
-
5/17/2018 Oracle Plsql
104/232
;hen %O!8A0A!5O%8 0OO!$A%D!+O,S then
Oracle Complete PLSQL +eference 1')
-
5/17/2018 Oracle Plsql
105/232
;hen U+O!8/48 then+aised ;hen an attempt is made to diide a number by @ero#
;hen 8P!/AL!O%!4%8T then
+aised ;hen an attempt is made to store duplicate alues in a column that is constrained by a uni?ue inde6
Oracle Complete PLSQL +eference 1'
$ore than one 6ception
System rror
ser 6ceptionSystem rror
ser 6ception
System rror
ser 6ception
-
5/17/2018 Oracle Plsql
106/232
;hen 4%/AL48!%$B+ then
+aised ;hen an attempt is made to conert an inalid character strin9 into a number#
Oracle Complete PLSQL +eference 1'(
System rrorser 6ception
-
5/17/2018 Oracle Plsql
107/232
;hen O0H+S then
Dou can use the O0H+S e6ception to handle all e6ceptions
;hen O0H+S then
Oracle Complete PLSQL +eference 1'
System rror
ser 6ception
O0H+S 6ception is not
the last one
-
5/17/2018 Oracle Plsql
108/232
;hen O0H+S then
8eclare /ariables in the 6ception Handler
Oracle Complete PLSQL +eference 1'3
ser 6ception
-
5/17/2018 Oracle Plsql
109/232
se more than one nested bloc. in the main bloc.
se SQLCO8 and SQL++$ 5unctions ;ith 6ceptions
SQLCO8 +eturn rror code ot rror number for any rror
SQL++$ +eturn rror $essa9e for any rror
Oracle Complete PLSQL +eference 1'7
-
5/17/2018 Oracle Plsql
110/232
ser 8efined 6ception
1# 4s a user defined e6ception that can be used instead of the preEdefined e6ception
2# userEdefined e6ceptions must be declared and must be raised e6plicitly by +A4S statements#
)# 6ceptions can be declared only in the declaratie part of a PLSQL bloc.F
# Dou declare an e6ception by introducin9 its nameF follo;ed by the .ey;ord TCP04O%
(# Dou cannot declare an e6ception t;ice in the same bloc.
Oracle Complete PLSQL +eference 1'*
-
5/17/2018 Oracle Plsql
111/232
# 6ceptions declared in a bloc. are considered local to that bloc. and 9lobal to all its subEbloc.s# Because a
bloc. can reference only local or 9lobal e6ceptionsF enclosin9bloc.s cannot reference e6ceptions declared in a
subEbloc.
ser 8efined 6ception
Oracle Complete PLSQL +eference 11'
-
5/17/2018 Oracle Plsql
112/232
8efinin9 Dour O;n rror $essa9es by usin9 Procedure: +A4S!APPL4CA04O%!++O+
1#0he procedure +A4S!APPL4CA04O%!++O+ lets you issue userEdefined O+AE error messa9es from stor
subpro9rams# 0hat ;ayF you can report errors to your application and aoid returnin9 unhandled e6ceptions#
2# error!number is a ne9atie inte9er in the ran9e E2'''' ## E2'*** and messa9e is a character strin9 up to
2'7bytes lon9
O0 Parameter
Oracle Complete PLSQL +eference 111
-
5/17/2018 Oracle Plsql
113/232
1 OUTparameter acts li.e a ariable# Dou can chan9e its alueF and reference the alue after assi9nin9 it:
2# can be bused ;hen pass parameter alues from one procedure to another procedure
2#1 OUTparameter returns a alue to the caller of a subpro9ram#
)# Dou must pass a ariableF not a constant or an e6pressionF to an OUTparameter#
! OUTformal parameters are initiali@ed to NULL
O0 Parameter
Oracle Complete PLSQL +eference 112
-
5/17/2018 Oracle Plsql
114/232
4% O0 Parameter
Oracle Complete PLSQL +eference 11)
-
5/17/2018 Oracle Plsql
115/232
Call proce"ure from another proce"ure
Oracle Complete PLSQL +eference 11
Call 6ternal Procedure named +ep1
Call 6ternal Proceure named +ep1
-
5/17/2018 Oracle Plsql
116/232
Call proce"ure from another proce"ure
0able 0ype
Oracle Complete PLSQL +eference 11(
-
5/17/2018 Oracle Plsql
117/232
#$L D&CL'R& ( T)*& emp+table+struct ,# T'-L& OF empfname%T)*& ,ND&. -) -,N'R)+,NT&/&R0 emp+table emp+table+struct0 ! CUR#OR emp+cursor ,# SELECT fname FROM emp ORD&R -) i"0 2 3+row NU4-&R 56 10 7 BEGIN 8 O*&N emp+cursor0
9 LOO* : F&TC; emp+cursor ,NTO emp+table &.,T W;&N emp+cursor%NOTFOUND011 D-4#+OUT*UT*UT+L,N&
-
5/17/2018 Oracle Plsql
118/232
A statement9le'el tri((er cannot 7uery or modify a mutatin( ta%le if the tri((er is fired as the result
4s it better to put code in tri99ers or procedures- ,hat is the difference-In earlier releases of #racle it was %etter to put as much code as possi%le in procedures rather than tri((ers. At that staprocedures executed faster than tri((ers as tri((ers had to %e re9compiled e'ery time %efore executed 5unless cached6more recent releases %oth tri((ers and procedures are compiled when created 5stored p9code6 and one can add as mucode as one li8es in either procedures or tri((ers.
5unctions
Q: ,hat is 5incation-
A function is similar to a procedure e6cept that a function must return a alue#
5unction can accept parameters or not
0he simplified synta6 for the C+A0 5%C04O% statement is as follo;s:
CREATE GO+ +PLAC 5%C04O% function!name G=parameter!name G4% V O0 V 4% O0 type GF ###>
+0+% type
W4S V ASX
E!I"
function!body
E"# function!name
Oracle Complete PLSQL +eference 113
-
5/17/2018 Oracle Plsql
119/232
5unction ;ith no parameters
5unction ;ith parameters
Oracle Complete PLSQL +eference 117
-
5/17/2018 Oracle Plsql
120/232
5unction ;ith parameters
5unction to calculate raise as 1'M of the salary
Oracle Complete PLSQL +eference 11*
-
5/17/2018 Oracle Plsql
121/232
5unction to calculate raise as M of the salary
Oracle Complete PLSQL +eference 12'
-
5/17/2018 Oracle Plsql
122/232
5unction to calculate total as sal & comm
Oracle Complete PLSQL +eference 121
-
5/17/2018 Oracle Plsql
123/232
5unction returns ;ee. %o of the $onth
Oracle Complete PLSQL +eference 122
-
5/17/2018 Oracle Plsql
124/232
5unctions return name of a $onth
Oracle Complete PLSQL +eference 12)
-
5/17/2018 Oracle Plsql
125/232
5unctions return Quartner %o of the year
Oracle Complete PLSQL +eference 12
-
5/17/2018 Oracle Plsql
126/232
5unctions return Yulian 8ate
Yulian date must be bet;een 1 and ()3)7
5unctions return name of a specific date
Oracle Complete PLSQL +eference 12(
-
5/17/2018 Oracle Plsql
127/232
5unctions return username
5unctions return sysdate
5unctions return default nationality
Oracle Complete PLSQL +eference 12
-
5/17/2018 Oracle Plsql
128/232
5unctions return $a6 salary
Position%otation calls for the parameters
Oracle Complete PLSQL +eference 123
-
5/17/2018 Oracle Plsql
129/232
"a$e%otation calls for the parameters
%ixed "a$eand position %otation calls for the parameters
Oracle Complete PLSQL +eference 127
-
5/17/2018 Oracle Plsql
130/232
8atabase 0ri99er
Oracle Complete PLSQL +eference 12*
-
5/17/2018 Oracle Plsql
131/232
8ataBase 0ri99er
Q: ;hat is a 0ri99er -
4t is a PLSQL Bloc. that is associated ;ith specific tableF ie;F schemaF 8atabase and fire implecitly ;hena specific eent occure
Q: ;hat are the tri99er
2# Application 0ri99er 5ire ,hen specific ent Occurs ,ith Particular Application =5ormsF repo
Q: ;hat are the obKects that the 8B tri99er associate ;ith -
1# 0able 2# /ie; )# schema # 8atabase
Q: ;hat is the structur of the 0ri99er Code-
Part 1
$andatory
0ri99er 0imin9 After Before =0ables> 4nstead of=/ie;>
Part 2
$andatory
0ri99er ent 1# 8B ent 1# 8$L 0ri99er
4nsert F update F update of column F delete
2# System ent Create F alter F drop F Lo9on F lo9off F
shutdo;nFstartupFserererror
Part )
Optinal
0ri99er 0ype 5or each ro; 1# 0he tri99er body e6ecutes once for each ro; affecte
the tri99er eent#
2# use :%, F :OL8 functions
5or ach Statement
G8efault
1# 0he tri99er body e6ecuted for each bul. of ro;s affe
by the tri99er eent #
2# %O0 use :%, F :OL8 functions
Part
Optional
0ri99er
Condition
,hen Condition 4f you ;ant to restirct a specific condition
Part (
$andatory
0ri99er Action 0he actions that the tri99er ;ill e6ecute ;hen the een
occur
0ri99er Synta6
Oracle Complete PLSQL +eference 1)'
-
5/17/2018 Oracle Plsql
132/232
Oracle Complete PLSQL +eference 1)1
-
5/17/2018 Oracle Plsql
133/232
Oracle Complete PLSQL +eference 1)2
-
5/17/2018 Oracle Plsql
134/232
Oracle Complete PLSQL +eference 1))
-
5/17/2018 Oracle Plsql
135/232
88L 0ri99ers ents Aaliable 5unctions
BEFORE / AFTER ALTER 1. ora_sysevent
Oracle Complete PLSQL +eference 1)
-
5/17/2018 Oracle Plsql
136/232
BEFORE / AFTER CREATE
BEFORE / AFTER DROP
BEFORE / AFTER RENAME
BEFORE / AFTER ANALYZE
BEFORE / AFTER ASSOCIATE
STATISTICS
BEFORE / AFTER DISASSOCIATE
STATISTICS
BEFORE / AFTER ADIT
BEFORE / AFTER NOADIT
BEFORE / AFTER COMMENT
BEFORE / AFTER DDL
BEFORE / AFTER !RANT
BEFORE / AFTER RE"O#E
BEFORE / AFTER TRNCATE
AFTER SSPEND
$. ora_%&'ent_'(_a))ress*. Ora_)ata+ase_na,e-. ora_)es_en%ry(te)_(assor). ora_)'%t_o+0_na,e. ora_)'%t_o+0_na,e_&'st2. ora_)'%t_o+0_oner3. ora_)'%t_o+0_ty(e4. ora_5rantee16. ora_'nstan%e_n7,11. ora_'s_a&ter_%o&7,n1$. ora_'s_%reat'n5_neste)_ta+1*. ora_'s_)ro(_%o&7,n1-. ora_'s_servererror1. ora_&o5'n_7ser1. ora_(art't'on_(os12. ora_(r'v'&e5e_&'st13. ora_revo8ee14. ora_server_error$6. ora_server_error_)e(t9$1. ora_server_error_,s5$$. ora_server_error_n7,_(ara,$*. ora_server_error_(ara,$-. ora_s:&_t;t$. ora_'t9_5rant_o(t'on$. s(a%e_error_'n
-
5/17/2018 Oracle Plsql
137/232
,hat is a mutatin9 and constrainin9 table-3M7tat'n5= ,eans =%9an5'n5=. A ,7tat'n5 ta+&e 's a ta+&e t9
's %7rrent&y +e'n5 ,o)'
-
5/17/2018 Oracle Plsql
138/232
create table compan
-
5/17/2018 Oracle Plsql
139/232
6amples
SQL> create table emplpyee
(empno number(5), name char(10), sal number(5), comm number(5),total number(5))
SQL> Create or replace trigger Tri1
After update of sal , comm on emp
For each row
Begin
Update emp
Set total = sal+comm
Where sal =:new.sal or comm =:new.comm;
End;
SQL> insert into e values(1,'ali',100,200,null);
SQL> insert into e values(2,'mona',200,300,null);
SQL> commit;
SQL> update e set sal = 300 where id=1;
ERROR at line 1:
ORA-04091: table SCOTT.E is mutating, trigger/function may not see it
ORA-06512: at "SCOTT.TRI1", line 2
ORA-04088: error during execution of trigger 'SCOTT.TRI1'
Error Calrification
IN Oracle you cannt insrt into table X and run trigger to update the same table
But you can run the trigger to update another table b because it is related to internal
constraint that violate this issue
Oracle Complete PLSQL +eference 1)7
-
5/17/2018 Oracle Plsql
140/232
Instead OF Trigger
Use instead of trigger when you want to insert or update ordelete on unupdatable View (Read Only View) because the instea
of trigger works invisibly on the underlying tablea!e ull" Type
######################################### ######## #########################$%&TO OT U'' U%R(*) &ri!ary +ey
$,% -.,R(/0)'O- -.,R(/0)
a!e ull" Type######################################### ######## #########################
%&O OT U'' U%R(*)%,% -.,R(/0)1,' U%R(*)
$%&TO U%R(*) References d2deptno
Oracle Complete PLSQL +eference 1)*
-
5/17/2018 Oracle Plsql
141/232
-reate or replace view v,s select e3e!pno 4 e3ena!e 4 e3sal 4 e3deptno4 d3deptno asdeptat!entI$ 4 d3dna!e 4 d3locFro! e e4 d d?9ere e.)e(tno ).)e(tno
Create or re(&a%e tr'55er Tr'1
Instea) o< 'nsert on v
For ea%9 ro
Be5'n
Insert 'nto ) "a&7es@ne.)e(tno > ne.)na,e >ne.&o%
Insert 'nto E "a&[email protected],(no > ne.ena,e >ne.sa& >ne.)e(tno
En)
Insert 'nto v
"a&7es@1>a9,e)>166>1>1>sa&es>%a'ro
Yo7 ,7st 'nsert )ata 'nto v'e 'n t9e sa,e se:7en%e
-
5/17/2018 Oracle Plsql
142/232
Syste, Tr'55ers
1. DDL Tr'5ers
9tt(//.(so75.or5/re
-
5/17/2018 Oracle Plsql
143/232
E;a,(&e No16
Create Ta+&e tets_DDL
@server_Event var%9ar$@6>
o+0e%t_oner var%9ar$@6>
o+0e%t_na,e var%9ar$@6>
7ser_na,e var%9ar$@6>
syste,_)ate )ate
CREATE OR REPLACE TRI!!ER test_DDL
BEFORE CREATE or ALTER or DROP ON SCHEMA
BE!IN
INSERT INTO tets_))&
SELECT ora_sysevent> ora_)'%t_o+0_oner> ora_)'%t_o+0_na,e> SER> SYSDATE
FROM )7a&
END
E;a,(&e No11
Conn sys/(assor)Jserv'%e_na,e as sys)+a
Create ta+&e ))&_&o5
@server_event %9ar@-6>
oner %9ar@$6>
o+0e%tna,e %9ar@$6>
te;t var%9ar@$66>
7serna,e %9ar@$6>
transa%t'on_)ate )ate
CREATE OR REPLACE TRI!!ER ))&_tr'55er
BEFORE CREATE OR ALTER OR DROPON SCHEMA
DECLARE
o(er var%9ar$@6
BE!IN
SELECT ora_sysevent
INTO o(er
FROM )7a&
IF o(erIN @CREATE> DROP THEN
INSERT INTO ))&_&o5
SELECT ora_sysevent> ora_)'%t_o+0_oner> ora_)'%t_o+0_na,e> NLL> SER> SYSDATE
FROM )7a&
ELSIF o(er ALTER THEN
INSERT INTO ))&_&o5
SELECT ora_sysevent> ora_)'%t_o+0_oner>ora_)'%t_o+0_na,e> s:&_te;t> SER> SYSDATE
FROM sys.5vo(en_%7rsor
?HERE PPER@s:&_te;t LI#E ALTER
END IF
END
Oracle Complete PLSQL +eference 12
mailto:sys/password@%3Cservice_namemailto:sys/password@%3Cservice_name -
5/17/2018 Oracle Plsql
144/232
CREATE OR REPLACE TRI!!ER save_o7r_)+
BEFORE DROP OR TRNCATE ON SCHEMA
DECLARE
o(er var%9a$@$6
BE!IN
SELECT ora_sysevent
INTO o(er
FROM )7a&
IF o(er DROP THEN
RAISE_APPLICATION_ERROR@$6443> Atte,(t To Dro( In Pro)7%t'on Has Been Lo55e)
ELSIF o(er TRNCATE THEN
RAISE_APPLICATION_ERROR@$6444> Atte,(t To Tr7n%ate A Pro)7%t'on Ta+&e Has Been Lo55e)
END IF
END
DDL Tr'55er To Prevent Creat'n5 O+0e%ts T9at ?9ose Na,es
Be5'n ?'t9 T9e Letter CREATE OR REPLACE TRI!!ER no_;ta+s
BEFORE CREATE ON SCHEMA
DECLARE
; 7ser_ta+&es.ta+&e_na,eTYPE
BE!IN
SELECT ora_)'%t_o+0_na,e
INTO ;
FROM )7a&
IF SBSTR@;> 1> 1 THEN
RAISE_APPLICATION_ERROR@$6644> Ta+&e Na,es Can Not Start ?'t9 T9e Letter
END IF
END
/
Oracle Complete PLSQL +eference 1)
-
5/17/2018 Oracle Plsql
145/232
$. Syste, Tr'55ers
9tt(//.(so75.or5/re 7serna,e"ALES @SYSDATE> SER
END
Oracle Complete PLSQL +eference
CREATE TABLE &o5_&o5ons @s:&te;t "ARCHAR$@$ NOT NLL
CREATE OR REPLACE PROCEDRE &o5(ro%
IsBe5'n
INSERT INTO &o5_&o5ons@s:&te;t
"ALES@7ser KK KK TO_CHAR@SYSDATEKK KKLo55e) On
En)
CREATE OR REPLACE TRI!!ER &o5'ntr'5
AFTER LO!ON ON DATABASE
CALL &o5(ro%
1
http://www.psoug.org/reference/system_trigger.htmlhttp://www.psoug.org/reference/system_trigger.html -
5/17/2018 Oracle Plsql
146/232
Oracle Complete PLSQL +eference
Create ta+&e '(
@'(_a)) %9ar@$6>
7ser_na,e %9ar@$6>
&o5on_7ser %9ar@$6>
)+_na,e %9ar@$6>
'nstan%e_no n7,+er@>
&o5on_)ate )ate
CREATE OR REPLACE TRI!!ER '(_tra%e
AFTER LO!ON ON DATABASE
BE!IN
IF @ora_syseventLO!ON THEN
INSERT INTO IP
"ALES@ora_%&'ent_'(_a))ress>7ser>ora_&o5'n_7ser>Ora_)ata+ase_na,e>ora_'nstan%e_n7,>sys)ate
END IF
END
I want to display all ob5ect na!es that has been altered
%reate ta+&e
@7serna,e %9ar@$6>
o+0e%t_na,e var%9ar$@$
CREATE OR REPLACE TRI!!ER sysevent_tr'5
AFTER ALTER ON SCHEMA
BE!IN
INSERT INTO "ALES@7ser>ora_)'%t_o+0_na,e
END
1(
-
5/17/2018 Oracle Plsql
147/232
a&ter ta+&e )e(t
a)) %onstra'nt a %9e%8 @)na,e 's not n7&&
a&ter 7ser s%ott ')ent'
-
5/17/2018 Oracle Plsql
148/232
1erver %rror Trigger
SGL %reate ta+&e%a759t_errors
@)t )ate>
7serna,e var%9ar$@ *6>
,s5 var%9ar$@1$>
st,t var%9ar$@1$
%reate or re(&a%e tr'55er%at%9_errors
A,s5_>st,t_
en)
Tr'55er Pr've&a5es
Syste, Pr'v'&e5es
%reate tr'55er
%reate any tr'55er
a),'n'ster )ata+ase tr'55er re:7're)
-
5/17/2018 Oracle Plsql
149/232
Tr'55ers Data D'%t'onary
)+a_tr'55ers a&&_tr'55ers 7ser_tr'55ers
Yo7 Can Ena+&e An) D'sa+&e Any Tr'55er A%%or)'n5 To t9e
-
5/17/2018 Oracle Plsql
150/232
5unction
Oracle Complete PLSQL +eference 1*
-
5/17/2018 Oracle Plsql
151/232
create or replace function emp!count
return number
iscnt number=2> :J '
be9in
select count=N> into cntfrom emp
return =cnt>
end
2#
create or replace function emp!count =p!deptno in number>return number
is
cnt number=2> :J 'be9in
select count=N> into cnt
from emp;here deptno J p!deptno
return =cnt>
end
)#
update emp set comm J sal ;here deptno J 1'
commit
create or replace function fun1 =p1 number F p2 number>
return number
isbe9in
if p1 J p2 then
return ='>
elsereturn =1>
end if
end
#select ename F sal F salN'#1' as raise
from emp
Create or replace function raise1'=p!sal number>
+eturn number
4sBe9in
+eturn =p!sal N '#1'>Oracle Complete PLSQL +eference 1('
-
5/17/2018 Oracle Plsql
152/232
nd
Create or replace function raise=p!sal number Fp!percenta9e number >
+eturn number4s
Be9in
+eturn =p!sal N p!percenta9e>nd
(#
select ename F sal F commF nl=salF'>&nl=commF'> as total
from emp
Create or replace function total =p!sal number F p!comm number>
return number
isBe9in
return =nl=p!salF'>&nl=p!commF'>>
nd
#
select ename F hiredate F 0O!CHA+=hiredateFI,I>
from emp
Create or replace function ;ee.!month=p!date 4% date>
+0+% %$B+4S
B4%
+0+% = 0O!%$B+= 0O!CHA+= p!dateF I,I > > >%8
3#
select enameF hiredate F 0O!CHA+=hiredateF Ifm$onthI> as $onth!name
from emp
Create or replace function $onth!%ame = p!date 4% 8A0 >
+0+% /A+CHA+2
4SB4%
+0+% = 0O!CHA+= p!dateF Ifm$onthI > >
%8 $onth!%ame
7#
select ename F hiredate F 0O!CHA+= hiredateF IQI >
from emp;here deptno J 1'
Oracle Complete PLSQL +eference 1(1
-
5/17/2018 Oracle Plsql
153/232
Create or replace function ?uarter= p!date 4% 8A0 >+0+% %$B+
4S
B4%+0+% = 0O!%$B+= 0O!CHA+= p!dateF IQI > > >
%8
*E 5unction that return Kulian date from date
select hiredate F 0O!CHA+=hiredateF IYI >from emp
;here deptno J 1'
Create or replace function Kulianfromdate=p!date 4% date>+0+% %$B+
4S
B4%+0+% =0O!%$B+=0O!CHA+= p!dateF IYI > > >
%8
1'E function that return date form Kulian
Create or replace function datefromKulian=p!num 4% %$B+ >
+0+% 8A04S
B4%
45 p!num B0,% 1 and ()3)7 0H%+0+% =0O!8A0=0+%C=p!num >FIYI>>
LS
+A4S!APPL4CA04O%!++O+ =E'17(F IYulian date must be bet;een 1 and ()3)7I>%8 45
%8
11E 5unction that return dayname
select ename Fhiredate F 0O!CHA+= hiredateF Ifm8ayI>from emp
;here deptno J 1'
Create or replace function dayname = p!date 4% 8A0 >
+0+% /A+CHA+2
4SB4%
+0+% = 0O!CHA+= p!dateF Ifm8ayI > >
%8
12#
Create Or +eplace 5unction username
+0+% /A+CHA+24S
B4%Oracle Complete PLSQL +eference 1(2
-
5/17/2018 Oracle Plsql
154/232
+0+% user%8
1)# 5unction that return current date J sysdateselect sysdate from dual
Create Or +eplace 5unction current!date+0+% date
4S
B4%+0+% sysdate
%8
1E 5unction that default alue for nationality column
create table employee =name char=>Fnationality archar2=2'>>
Create Or +eplace 5unction default!nationality
+0+% archar2
4SB4%
+0+% Ze9yptian
1(E 5unction that return ma6!sal!emp
select ma6=sal> from emp
Create Or +eplace 5unction ma6!sal!emp
+0+% number
4S!ma6!sal number=(>
B4%
Select ma6=sal>
4nto !ma6!sal5rom emp
+0+% !ma6!sal
%8
1E 5unction that return statistic
select ma6=sal> F min=sal> F a9=sal> F sum=sal>
from emp
Create Or +eplace 5unction $a6!$in!A9!Sum
+0+% archar2
4S!ma6!sal number=(>
!min!sal number=(>Oracle Complete PLSQL +eference 1()
-
5/17/2018 Oracle Plsql
155/232
!a9!sal number=(>!sum!sal number=(>
B4%
Select ma6=sal> F min=sal>F a9=sal> F sum=sal>4nto !ma6!sal F !min!sal F !a9!sal F !sum!sal
5rom emp
+0+% =to!char=!ma6!sal> VV IEI VV to!char=!min!sal> VV IEI VV to!char=!a9!sal> VV IEI VV to!char=!sum!sal>>%8
13#C+A0 O+ +PLAC 5%C04O% add!three!numbers= a %$B+ :J 'F b %$B+ :J 'F c %$B+
>
+0+% %$B+
4SB4%
+0+% a & b & c
%8
B4%
dbms!output#put!line=add!three!numbers=)FF(>>%8
17#C+A0 O+ +PLAC 5%C04O% add!three!numbers= a %$B+ :J 'F b %$B+ :J 'F c %$B+
>
+0+% %$B+4S
B4%
+0+% a & b & c%8
B4%
dbms!output#put!line=add!three!numbers=a J Fb J (Fc J )>>
%8
1*#
C+A0 O+ +PLAC 5%C04O% add!three!numbers= a %$B+ :J 'F b %$B+ :J 'F c %$B+>
+0+% %$B+
4SB4%
+0+% a & b & c
%8
B4%
dbms!output#put!line=add!three!numbers=a J Fb J (Fc J )>>%8
Oracle Complete PLSQL +eference 1(
-
5/17/2018 Oracle Plsql
156/232
Pac.a9e
Oracle Complete PLSQL +eference 1((
-
5/17/2018 Oracle Plsql
157/232
create table dd
(deptno number(5),deptname varchar2(30),deptloc varchar2(5));
create sequence sqdept
start with 1
increment by 1;
CREATE or replace package over_packIS / AS
Procedure add_dept(dno number,dname varchar2,dloc varchar2);
Procedure add_dept(dname varchar2,dloc varchar2);
End;
/
CREATE or replace package BODYover_pack
Is
Procedure add_dept(dno number,dname varchar2,dloc varchar2)
Is
Begin
Insert into dd values(dno , dname ,dloc);
End;
Procedure add_dept(dname varchar2,dloc varchar2)
Is
BeginInsert into dd values(sqdept.nextval , dname ,dloc);
End;
End;
/
exec over_pack.add_dept(design,cairo);
exec over_pack.add_dept(1,sales,alex);
Oracle Complete PLSQL +eference 1(
-
5/17/2018 Oracle Plsql
158/232
CREATE or replace package over_pack
Is
function total (v_sal number , v_comm number)return number;
function max_sal_emp return number;
End;
CREATE or replace package body over_pack
Is
function total(v_sal number , v_comm number)return number
is
Begin
return (nvl(v_sal,0)+nvl(v_comm,0));
End;
Function max_sal_emp
RETURN number
IS
v_max_sal number(5);
BEGIN
Select max(sal)Into v_max_sal
From emp;
RETURN (v_max_sal);
END;
End;
/
select sal , comm, over_pack.total(sal,comm)
from emp ;
select over_pack.max_sal_emp
from dual;
Oracle Complete PLSQL +eference 1(3
-
5/17/2018 Oracle Plsql
159/232
Oracle Complete PLSQL +eference 1(7
-
5/17/2018 Oracle Plsql
160/232
Oracle Complete PLSQL +eference 1(*
-
5/17/2018 Oracle Plsql
161/232
System Pac.a9e
Oracle Complete PLSQL +eference 1'
-
5/17/2018 Oracle Plsql
162/232
Oracle Complete PLSQL +eference 11
-
5/17/2018 Oracle Plsql
163/232
8B$S!AL+0= > dbms!application!info= > 8B$S!AQA8$= ) > dbms!crypto= 7 > 8B$S!8B= 1 > dbms!ddl=1 >
8B$S!8B= 1 > 8B$S!5A= 1 > 8B$S!54L!0+A%S5+= 1 > dbms!flashbac.= ) > dbms!Kob= 7 > dbms!lob=13 >
dbms!loc.= 1 > 8B$S!$0A8A0A=2 > 8B$S!OB5SCA04O%!0OOLR40= > dbms!output= 1 > 8B$S!P4P=1) > 8B$S!+A%8
8B$S!+854%404O%= 1 > 8B$S!+PA4+= > dbms!ro;id= 3 > dbms!scheduler= 1 > 8B$S!SSS4O%=1 > dbms!space= 1
dbms!s?l=23 > dbms!stats= 12 > 8B$S!0+AC= 2 > dbms!utility=1( > 8B$S!,A+%4%=2 > dbms!6ml?uer
dbms!6mlschema=2 > htp=1 > O+A rror=1) > O+A= 17 > outln!p.9=1 > 0T0!4O= 1 >
0L!CO$P+SS= 1 > 0L!54L=* > 0L!H00P= 1 > utl!i17n=1 > 0L!4%A88+= 1 > 0L!$A4L= 1
utl!ra;= 23 > 0L!S$0P=1 > 0L!0CP=1 >
Oracle Complete PLSQL +eference 12
http://www.java2s.com/Code/Oracle/System-Packages/DBMS_ALERT.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_ALERT.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_application_info.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_AQADM.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_crypto.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_DB.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_ddl.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_ddl.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_DEBUG.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_FGA.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_FILE_TRANSFER.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_flashback.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_job.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_lob.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_lob.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_lock.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_METADATA.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_METADATA.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_OBFUSCATION_TOOLKIT.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_OBFUSCATION_TOOLKIT.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_output.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_PIPE.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_PIPE.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_RANDOM.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_REDEFINITION.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_REPAIR.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_REPAIR.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_rowid.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_scheduler.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_SESSION.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_SESSION.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_space.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_sql.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_sql.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_stats.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_TRACE.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_utility.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_utility.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_WARNING.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_WARNING.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_xmlquery.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_xmlschema.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_xmlschema.htmhttp://www.java2s.com/Code/Oracle/System-Packages/htp.htmhttp://www.java2s.com/Code/Oracle/System-Packages/htp.htmhttp://www.java2s.com/Code/Oracle/System-Packages/ORA-Error.htmhttp://www.java2s.com/Code/Oracle/System-Packages/ORA-Error.htmhttp://www.java2s.com/Code/Oracle/System-Packages/ORA.htmhttp://www.java2s.com/Code/Oracle/System-Packages/outln_pkg.htmhttp://www.java2s.com/Code/Oracle/System-Packages/outln_pkg.htmhttp://www.java2s.com/Code/Oracle/System-Packages/TEXT_IO.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_COMPRESS.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_FILE.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_FILE.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_HTTP.htmhttp://www.java2s.com/Code/Oracle/System-Packages/utl_i18n.htmhttp://www.java2s.com/Code/Oracle/System-Packages/utl_i18n.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_INADDR.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_MAIL.htmhttp://www.java2s.com/Code/Oracle/System-Packages/utl_raw.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_SMTP.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_SMTP.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_TCP.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_TCP.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_ALERT.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_application_info.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_AQADM.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_crypto.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_DB.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_ddl.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_DEBUG.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_FGA.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_FILE_TRANSFER.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_flashback.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_job.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_lob.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_lock.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_METADATA.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_OBFUSCATION_TOOLKIT.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_output.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_PIPE.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_RANDOM.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_REDEFINITION.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_REPAIR.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_rowid.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_scheduler.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_SESSION.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_space.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_sql.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_stats.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_TRACE.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_utility.htmhttp://www.java2s.com/Code/Oracle/System-Packages/DBMS_WARNING.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_xmlquery.htmhttp://www.java2s.com/Code/Oracle/System-Packages/dbms_xmlschema.htmhttp://www.java2s.com/Code/Oracle/System-Packages/htp.htmhttp://www.java2s.com/Code/Oracle/System-Packages/ORA-Error.htmhttp://www.java2s.com/Code/Oracle/System-Packages/ORA.htmhttp://www.java2s.com/Code/Oracle/System-Packages/outln_pkg.htmhttp://www.java2s.com/Code/Oracle/System-Packages/TEXT_IO.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_COMPRESS.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_FILE.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_HTTP.htmhttp://www.java2s.com/Code/Oracle/System-Packages/utl_i18n.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_INADDR.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_MAIL.htmhttp://www.java2s.com/Code/Oracle/System-Packages/utl_raw.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_SMTP.htmhttp://www.java2s.com/Code/Oracle/System-Packages/UTL_TCP.htm -
5/17/2018 Oracle Plsql
164/232
,mplicit Cursorhttp5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBsHlnotfoun"htm
http5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBUsinE#&L&CTinaCursorhtmhttp5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBCursorforobGecttablehtmhttp5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBCursorwithor"erbhtm
http5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBCursorforaEEreEatefunctionhtmhttp5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBFetchinE'crossCommits&Iample(htmhttp5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBCursorFORLoophtmhttp5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBClosecursorineIcpetionhan"lerhtmSQL > Create or replace procedure a
Is
Cursor Emp_Rec_Cur is select ename , deptno from emp;
Begin
for i in emp_rec_cur loop -- implicit open and implicit Fetch
if i.deptno= 20 then
dbms_output.put_line(i.ename || ' ' || i.deptno);
end if;
end loop; -- implicit close and implicit loop Exit
end;
the prvious example is equal to next example
SQL > Create or replace procedure a
Is
Begin
for i in (select ename , deptno from emp) loop -- implicit open and implicit Fet
if i.deptno= 20 then
dbms_output.put_line(i.ename || ' ' || i.deptno);
end if;
end loop; -
implicit close and implicit loop Exit
end;
!;NT and !;?+$#W=#>NThttp:;;;#Kaa2s#com0utorialOracle'(''!!Cursorusin9SQLBLR+O,CO%0andSQL+O,CO%0#
Use cursor subHuerhttp5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBUsethecursorsubHuerhtm
Neste" Cursorhttp5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBNeste"cursorhtm
/A++AD of Cursorhttp5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorB'RR')ofCursorhtm
Assi(nin( different 7ueries to the same cursor 'aria%leRef Cursor
http:;;;#Kaa2s#com0utorialOracle'(''!!CursorAssi9nin9different?ueriestothesamecursorariable#htm
Oracle Complete PLSQL +eference 1)
http://www.java2s.com/Tutorial/Oracle/0500__Cursor/sqlnotfound.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/UsingSELECTinaCursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Cursorforobjecttable.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Cursorwithorderby.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Cursorforaggregatefunction.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/FetchingAcrossCommitsExample2.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/CursorFORLoop.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Closecursorinexcpetionhandler.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/usingSQLBULKROWCOUNTandSQLROWCOUNT.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Usethecursorsubquery.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Nestedcursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/VARRAYofCursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Assigningdifferentqueriestothesamecursorvariable.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/sqlnotfound.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/UsingSELECTinaCursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Cursorforobjecttable.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Cursorwithorderby.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Cursorforaggregatefunction.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/FetchingAcrossCommitsExample2.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/CursorFORLoop.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Closecursorinexcpetionhandler.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/usingSQLBULKROWCOUNTandSQLROWCOUNT.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Usethecursorsubquery.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Nestedcursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/VARRAYofCursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Assigningdifferentqueriestothesamecursorvariable.htm -
5/17/2018 Oracle Plsql
165/232
6ecute immediate statementBEGIN
FOR i IN (SELECT tale!na"eFROM user!talesWHERE tale!na"e # $DEPT%$ & LOOP
'EECUTE IMMEDIATE $DROP TABLE )u""*+$,
-END LOOP+.
1' &ND0http5BBwwwGa3a(scomBTutorialBOracleB>2>>++CursorBReturninformationusinEcursorstatus3ariableshtm
Can one use dynamic SQL statements from PLSQL-!tartin( from #racle@i one can use the 3EXE=>TE I44E:IATE3 statement to execute dynamic !; and !;statements 5statements created at run9time6. oo8 at these examples. Note that statements are N#T terminated %ysemicolons)
EECTE IMMEDIATE CREATE TABLE ; @a NMBER s'n5 +'n) var'a+&es...s:&_st,t INSERT INTO )e(t "ALES @1> $> *
EECTE IMMEDIATE s:&_st,t SIN! )e(t_')> )e(t_na,e> &o%at'on Ret7rn'n5 a %7rsor...
s:&_st,t SELECT Q FROM e,( ?HERE e,(no ')EECTE IMMEDIATE s:&_st,t INTO e,(_re% SIN! e,(_')
#ne can also use the older :B4!+!; pac8a(e 50C.* and a%o'e6 to execute dynamic statements. oo8 at theseexamples)CREATE OR REPLACE PROCEDRE DYNSGLAS%7r 'nte5err% 'nte5erBE!IN%7r DBMS_SGL.OPEN_CRSORDBMS_SGL.PARSE@%7r> CREATE TABLE @Y DATE> DBMS_SGL.NATI"E
r% DBMS_SGL.EECTE@%7rDBMS_SGL.CLOSE_CRSOR@%7rEND/
4ore complex :B4!+!; example usin( %ind 'aria%les)CREATE OR REPLACE PROCEDRE DEPARTMENTS@NO IN DEPT.DEPTNOTYPE AS v_%7rsor 'nte5er v_)na,e %9ar@$6 v_ros 'nte5erBE!IN v_%7rsor DBMS_SGL.OPEN_CRSOR DBMS_SGL.PARSE@v_%7rsor> se&e%t )na,e
DBMS_SGL."2 DBMS_SGL.BIND_"ARIABLE@v_%7rsor> ;> no DBMS_SGL.DEFINE_COLMN_CHAR@v_%7rsor> 1> v_)na,e> $6 v_ros DBMS_SGL.EECTE@v_%7rsor &oo( '< DBMS_SGL.FETCH_RO?S@v_%7rsor 6 t9en e;'t en) '
-
5/17/2018 Oracle Plsql
166/232
DBMS_SGL.CLOSE_CRSOR@v_%7rsor ra'se_a((&'%at'on_error@$6666> n8non E;%e(t'on Ra'se) KKs:&%o)eKK
s:&err,END/
Bac. to top of file
6ecute procedure
1# e6ec rep1
2# e6ec rep1=>p1Fp2Fp)F[[)# call rep1=>
# call rep1=p1Fp2Fp)F[[#>
0ri99ers
Oracle Complete PLSQL +eference 1(
http://www.orafaq.com/#TopOfFilehttp://www.orafaq.com/#TopOfFile -
5/17/2018 Oracle Plsql
167/232
0able data type
http:;;;#Kaa2s#com0utorialOracle'(''!!CursorCreateandusereferencecursor#htm
http:;;;#Kaa2s#com0utorialOracle'(''!!Cursor+eferencealueinacursorbycursorariable#htm
5unction
http:;;;#Kaa2s#com0utorialOracle'7'!!PLESQLE
Pro9rammin9Code;ithConditionalControltoAoidan6ception#htm
http:;;;#Kaa2s#com0utorialOracle'7'!!PLESQLEPro9rammin9Code;ith6plicitHandlerforPredefined6ception#htm
http:;;;#Kaa2s#com0utorialOracle'7'!!PLESQLEPro9rammin9Handlin9e6ceptions;ithouthaltin9thepro9ram#htm
4% O0 PA+A$0+
http:;;;#Kaa2s#com0utorialOracle'(''!!Cursor0heuseof+5C+SO+#htm
http:;;;#Kaa2s#com0utorialOracle'(''!!CursorOpenSDS+5C+SO+forselectfrom#htm
http:;;;#Kaa2s#com0utorialOracle'(''!!CursorSDS+5C+SO+typeparameter#htm
Oracle Complete PLSQL +eference 1
http://www.java2s.com/Tutorial/Oracle/0500__Cursor/Createandusereferencecursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Referencevalueinacursorbycursorvariable.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/CodewithConditionalControltoAvoidanException.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/CodewithConditionalControltoAvoidanException.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/CodewithExplicitHandlerforPredefinedException.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/CodewithExplicitHandlerforPredefinedException.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/Handlingexceptionswithouthaltingtheprogram.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/Handlingexceptionswithouthaltingtheprogram.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/TheuseofREFCURSOR.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/OpenSYSREFCURSORforselectfrom.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/SYSREFCURSORtypeparameter.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Createandusereferencecursor.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/Referencevalueinacursorbycursorvariable.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/CodewithConditionalControltoAvoidanException.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/CodewithConditionalControltoAvoidanException.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/CodewithExplicitHandlerforPredefinedException.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/CodewithExplicitHandlerforPredefinedException.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/Handlingexceptionswithouthaltingtheprogram.htmhttp://www.java2s.com/Tutorial/Oracle/0480__PL-SQL-Programming/Handlingexceptionswithouthaltingtheprogram.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/TheuseofREFCURSOR.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/OpenSYSREFCURSORforselectfrom.htmhttp://www.java2s.com/Tutorial/Oracle/0500__Cursor/SYSREFCURSORtypeparameter.htm -
5/17/2018 Oracle Plsql
168/232
,hile Loop
/tt012233345a6a%s4c7"2Tut7rial2Oracle28998!!PL:S;L:State"ents2Re6erse)FORLOOP4/tt01223334a)0:aces2secure2sr"2sr2SR;ueue45s0?@"c#
/tt0s122l7
-
5/17/2018 Oracle Plsql
169/232
part 2
REATE OR REPLACE PROCEDRE (%a&&e)@Tab6 $1718'3V,R-.,R/1 IS
BE!IN
)o so,et9'n5 't9 Ta+
-
5/17/2018 Oracle Plsql
170/232
Oracle Supplied Packages
Thes packages are got from the following URL
http://www.ss64.com/orap/
Packages marked *are new in 9.2
Package Description
DBMS_ALERT Notify a database event (asynchronous)
DBMS_APPLICATION_INFO
Register an application name with the database
for auditing or performance tracking.
Application info can be pushed into
V$SESSION/V$SESSION_LONGOPS
DBMS_AQ Add a message (of a predefined object type) onto a queue
or dequeue a message.
DBMS_AQADM Administer a queue or queue table
for messages of a predefined object type.
DBMS_AQELM Configure Advanced Queuing
asynchronous notification by e-mail and HTTP. *
DBMS_BACKUP_RESTORE
Normalize filenames on Windows NT platforms.
DBMS_DDL Access SQL DDL statements from a stored procedure, provides special administration operations
not available as DDLs.
DBMS_DEBUG Implement server-side debuggers and provide a way to
debug server-side PL/SQL program units.
DBMS_DEFER User interface to a replicated transactional deferred
RPC facility. Requires the Distributed Option.
Oracle Complete PLSQL +eference 1*
http://www.ss64.com/orap/http://www.ss64.com/orap/DBMS_ALERT.htmlhttp://www.ss64.com/orap/DBMS_APPLICATION_INFO.htmlhttp://www.ss64.com/orav/V$SESSION.htmlhttp://www.ss64.com/orav/V$SESSION_LONGOPS.htmlhttp://www.ss64.com/orap/DBMS_AQ.htmlhttp://www.ss64.com/orap/DBMS_AQADM.htmlhttp://www.ss64.com/orap/DBMS_AQELM.htmlhttp://www.ss64.com/orap/DBMS_BACKUP_RESTORE.htmlhttp://www.ss64.com/orap/DBMS_DDL.htmlhttp://www.ss64.com/orap/DBMS_DEBUG.htmlhttp://www.ss64.com/orap/DBMS_DEFER.htmlhttp://www.ss64.com/orap/http://www.ss64.com/orap/DBMS_ALERT.htmlhttp://www.ss64.com/orap/DBMS_APPLICATION_INFO.htmlhttp://www.ss64.com/orav/V$SESSION.htmlhttp://www.ss64.com/orav/V$SESSION_LONGOPS.htmlhttp://www.ss64.com/orap/DBMS_AQ.htmlhttp://www.ss64.com/orap/DBMS_AQADM.htmlhttp://www.ss64.com/orap/DBMS_AQELM.htmlhttp://www.ss64.com/orap/DBMS_BACKUP_RESTORE.htmlhttp://www.ss64.com/orap/DBMS_DDL.htmlhttp://www.ss64.com/orap/DBMS_DEBUG.htmlhttp://www.ss64.com/orap/DBMS_DEFER.html -
5/17/2018 Oracle Plsql
171/232
DBMS_DEFER_QUERY
Permit querying the deferred remote procedure calls (RPC)
queue data that is not exposed through views.
Requires the Distributed Option.
DMBS_DEFER_SYS
The system administrator interface to a replicated
transactional deferred RPC facility.
Requires the Distributed Option.
DBMS_DESCRIBE
Describe the arguments of a stored procedure
with full name translation and security checking.
DBMS_DISTRIBUTED_TRUST_ADMIN
Maintain the Trusted Database List, which is used to
determine if a privileged database link from a particular
server can be accepted.
DBMS_ENCODE Encode???
DBMS_FGA Fine-grained security functions. *
DMBS_FLASHBACK
Flash back to a version of the database at a specified
wall-clock time or a specified system change
number (SCN).*
DBMS_HS_PASSTHROUGH
Send pass-through SQL statements to non-Oracle systems. (via Heterogeneous Services)
DBMS_IOT Create a table into which references to the chained rows
for an Index Organized Table can be placed using the
ANALYZE command.
DBMS_JOB Schedule PL/SQL procedures that you want performed at
periodic intervals; also the job queue interface.
DBMS_LDAP Functions and procedures to access data from
LDAP servers. *
DBMS_LIBCACHE
Prepares the library cache on an Oracle instance by
extracting SQL and PL/SQL from a remote instance and
compiling this SQL locally without execution. *
DBMS_LOB General purpose routines for operations on Oracle Large
Object (LOBs) datatypes - BLOB, CLOB (read-write),
Oracle Complete PLSQL +eference 13'
http://www.ss64.com/orap/DBMS_DEFER_QUERY.htmlhttp://www.ss64.com/orap/DBMS_DEFER_SYS.htmlhttp://www.ss64.com/orap/DBMS_DESCRIBE.htmlhttp://www.ss64.com/orap/DBMS_DISTRIBUTED_TRUST_ADMIN.htmlhttp://www.google.com/search?q=DBMS_ENCODEhttp://www.ss64.com/orap/DBMS_FGA.htmlhttp://www.ss64.com/orap/DBMS_FLASHBACK.htmlhttp://www.ss64.com/orap/DBMS_HS_PASSTHROUGH.htmlhttp://www.ss64.com/orap/DBMS_IOT.htmlhttp://www.ss64.com/orap/DBMS_JOB.htmlhttp://www.ss64.com/orap/DBMS_LDAP.htmlhttp://www.ss64.com/orap/DBMS_LIBCACHE.htmlhttp://www.ss64.com/orap/DBMS_LOB.htmlhttp://www.ss64.com/orap/DBMS_DEFER_QUERY.htmlhttp://www.ss64.com/orap/DBMS_DEFER_SYS.htmlhttp://www.ss64.com/orap/DBMS_DESCRIBE.htmlhttp://www.ss64.com/orap/DBMS_DISTRIBUTED_TRUST_ADMIN.htmlhttp://www.google.com/search?q=DBMS_ENCODEhttp://www.ss64.com/orap/DBMS_FGA.htmlhttp://www.ss64.com/orap/DBMS_FLASHBACK.htmlhttp://www.ss64.com/orap/DBMS_HS_PASSTHROUGH.htmlhttp://www.ss64.com/orap/DBMS_IOT.htmlhttp://www.ss64.com/orap/DBMS_JOB.htmlhttp://www.ss64.com/orap/DBMS_LDAP.htmlhttp://www.ss64.com/orap/DBMS_LIBCACHE.htmlhttp://www.ss64.com/orap/DBMS_LOB.html -
5/17/2018 Oracle Plsql
172/232
and BFILEs (read-only).
DBMS_LOCK Request, convert and release locks through Oracle Lock
Management services.
DBMS_LOGMNR Functions to initialize and run the log reader.
DBMS_LOGMNR_CDC_PUBLISH
Identify new data that has been added to, modified, orremoved from, relational tables and publish the changed
data in a form that is usable by an application. *
DBMS_LOGMNR_CDC_SUBSCRIBE
View and query the change data that was captured
and published with the DBMS_LOGMNR_CDC_PUBLISH package. *
DBMS_LOGMNR_D
Query the dictionary tables of the current database, and
create a text based file containing their contents.
DBMS_METADATA
Retrieve complete database object definitions (metadata)
from the dictionary. *
DBMS_MVIEW Refresh snapshots that are not part of the same
refresh group and purge logs. DBMS_SNAPSHOT is a synonym.
DBMS_OBFUSCATION_TOOLKIT
Procedures for Data Encryption Standards.
DBMS_ODCI Get the CPU cost of a user function based on the
elapsed time of the function. *
DBMS_OFFLINE_OG
Public APIs for offline instantiation of master groups.
DBMS_OFFLINE_SNAPSHOT
Public APIs for offline instantiation of snapshots.
DBMS_OLAP Procedures for summaries, dimensions, and query rewrites.
DBMS_ORACLE_TRACE_AGENT
Client callable interfaces to the Oracle TRACE
instrumentation within the Oracle7 Server.
DBMS_ORACLE_TRACE_USER
Public access to the Oracle release 7 Server
Oracle TRACE instrumentation for the calling user.
Oracle Complete PLSQL +eference 131
http://www.ss64.com/orap/DBMS_LOCK.htmlhttp://www.ss64.com/orap/DBMS_LOGMNR.htmlhttp://www.ss64.com/orap/DBMS_LOGMNR_CDC_PUBLISH.htmlhttp://www.ss64.com/orap/DBMS_LOGMNR_CDC_SUBSCRIBE.htmlhttp://www.ss64.com/orap/DBMS_LOGMNR_D.htmlhttp://www.ss64.com/orap/DBMS_METADATA.htmlhttp://www.ss64.com/orap/DBMS_MVIEW.htmlhttp://www.ss64.com/orap/DBMS_OBFUSCATION_TOOLKIT.htmlhttp://www.ss64.com/orap/DBMS_ODCI.htmlhttp://www.ss64.com/orap/DBMS_OFFLINE_OG.htmlhttp://www.ss64.com/orap/DBMS_OFFLINE_SNAPSHOT.htmlhttp://www.ss64.com/orap/DBMS_OLAP.htmlhttp://www.ss64.com/orap/DBMS_ORACLE_TRACE_AGENT.htmlhttp://www.ss64.com/orap/DBMS_ORACLE_TRACE_USER.htmlhttp://www.ss64.com/orap/DBMS_LOCK.htmlhttp://www.ss64.com/orap/DBMS_LOGMNR.htmlhttp://www.ss64.com/orap/DBMS_LOGMNR_CDC_PUBLISH.htmlhttp://www.ss64.com/orap/DBMS_LOGMNR_CDC_SUBSCRIBE.htmlhttp://www.ss64.com/orap/DBMS_LOGMNR_D.htmlhttp://www.ss64.com/orap/DBMS_METADATA.htmlhttp://www.ss64.com/orap/DBMS_MVIEW.htmlhttp://www.ss64.com/orap/DBMS_OBFUSCATION_TOOLKIT.htmlhttp://www.ss64.com/orap/DBMS_ODCI.htmlhttp://www.ss64.com/orap/DBMS_OFFLINE_OG.htmlhttp://www.ss64.com/orap/DBMS_OFFLINE_SNAPSHOT.htmlhttp://www.ss64.com/orap/DBMS_OLAP.htmlhttp://www.ss64.com/orap/DBMS_ORACLE_TRACE_AGENT.htmlhttp://www.ss64.com/orap/DBMS_ORACLE_TRACE_USER.html -
5/17/2018 Oracle Plsql
173/232
DBMS_OUTLN Interface for procedures and functions associated with
management of stored outlines. Synonymous with OUTLN_PKG
DBMS_OUTLN_EDIT
Edit an invoker's rights package. *
DBMS_OUTPUT Accumulate information in a buffer so that it can be
retrieved out later.
DBMS_PCLXUTILIntra-partition parallelism for creating partition-wise
local indexes.
DBMS_PIPE A DBMS pipe service which enables messages to be sent
between sessions.
DBMS_PROFILERA Probe Profiler API to profile PL/SQL applications
and identify performance bottlenecks.
To install this run profload.sql(as SYS) and proftab.sql(as
user)
DBMS_RANDOM A built-in random number generator.
Options to generate random numbers within a range or
distribution.
DBMS_RECTIFIER_DIFF
APIs used to detect and resolve data inconsistencies
between two replicated sites.
DBMS_REDEFINITION
Reorganise a table (change it's structure) while it's still online and in use. *
DBMS_REFRESH Create groups of snapshots that can be refreshed together
to a transactionally consistent point in time.
Requires the Distributed Option.
DBMS_REPAIR Repair data corruption.
DBMS_REPCAT Administer and update the replication catalog and environme
Requires the Replication Option.
DBMS_REPCAT_ADMIN
Create users with the privileges needed by the symmetric
replication facility. Requires the Replication Option.
DBMS_REPCAT_INSTATIATE
Instantiates deployment templates.
Requires the Replication Option.
Oracle Complete PLSQL +eference 132
http://www.ss64.com/orap/DBMS_O