Вы находитесь на странице: 1из 653

:

. ! .

.
,

.

.
.

.

.
.

,
, , e-mail -
.
ProgBook.net - .

.

.
ORACLE8. PL/SQL

1 PL/SQL
PL/SQL?
/

PL/SQL



,
PL/SQL Oracle
Oracle
-


student_sequence
students
major_stats
rooms
classes
registered_students
RS_audit
log_table
temp_table
debug_table

2 PL/SQL
PL/SQL

1
2
3
4
4
4
4
5
6
7
7
7
9
9
9
9
10
10
11
11
12
13
15
15
15
15
16
17
18
20
22
22
23
23
24
25
25
25
26
26
26





PL/SQL





ROWID

Trusted


LOB
%TYPE
,






PL/SQL
IF-THEN-ELSE
NULL-


WHILE
FOR
GOTO
GOTO

GOTO
NULL

PL/SQL

27
27
27
28
29
29
29
31
32
33
33
33
33
33
34
34
34
35
35
36
36
37
38
38
39
39
40
41
41
43
44
44
45
46
47
48
49
49
49
50
50
51
51
51

3
PL/SQL

%ROWTYPE



COUNT
DELETE
EXISTS
FIRST LAST
NEXT PRIOR
PL/SQL

4 SQL PL/SQL
SQL-
SQL PL/SQL
DML PL/SQL
SELECT
INSERT
UPDATE
DELETE
WHERE



CURRVAL NEXTVAL
LEVEL
ROWID
ROWNUM
GRANT, REVOKE

GRANT REVOKE
GRANT
REVOKE


COMMIT ROLLBACK

52
52
52
53
54
55
56
56
57
59
59
59
60
61
61
62
62
63
64
64
65
66
68
69
70
70
71
71
73
73
74
74
74
75
75
75
76
76
77
77
77
77
78
79

5 SQL-

,
CHR
CONCAT
INITCAP
LOWER
LPAD
LTRIM
NLS INITCAP
NLS LOWER
NLS UPPER
REPLACE
RPAD
RTRIM
SOUNDEX
SUBSTR
SUBSTRB
TRANSLATE
UPPER
,
ASCII
INSTR
INSTRB
LENGTH
LENGTHB
NLSSORT

ABS
ACOS
ASIN
ATAN
ATAN2
CEIL
COS
COSH
EXP
FLOOR
LN
LOG
MOD

80
80
81
83
84
84
84
85
85
85
86
86
87
87
88
88
89
89
90
90
91
91
92
92
92
93
93
94
94
94
95
95
95
95
96
96
96
97
97
97
98
98
98
98

POWER
ROUND
SIGN
SIN
SINH
SQRT
TAN
TANH
TRUNC

ADD_MONTHS
I.AST_DAY
MONTHS BETWEEN
NEW_TIME
NEXT_DAY
ROUND
SYSDATE
TRUNC


CHARTOROWID
CONVERT
HEXTORAW
RAWTOHEX
ROWIDTOCHAR
TO_CHAR ()
_CHAR ()
_CHAR ()
_DATE
_LABEL
_MULTI BYTE
_NUMBER
TO_SINGLE_BYTE

AVG
COUNT
GLB
LUB

MIN
STDDEV
SUM
VARIANCE

99
99
99
100
100
100
101
101
101
101
102
102
102
103
103
104
104
105
105
106
106
106
107
107

108

110
112
112
112
112
113
113
113
114
114
114
115
115
115
116
116
116

BFILENAME
DECODE
DUMP
EMPTY_GLOB/EMPTY_BLOB
GREATEST
GREATEST_LB
LEAST
LEAST_UB
NVL
UID
USER
USERENV
VSIZE
PL/SQL :

6











WHILE
FOR
NO DATA FOUND %NOTFOUND
SELECT FOR UPDATE
FOR UPDATE
WHERE CURRENT OF
COMMIT




EXEC SQL ALLOCATE



1
2

116
117
117
119
119
119
119
120
120
120
121
121
122
122
130
131
132
132
133
133
134
135
135
138
138
140
140
142
143
144
144
144
145
146
147
147
148
149
149
149
149
150
150
152

7 :









RETURN

,











EXECUTE







SQL-

RESTRICT_REFERENCES

PL/SQL : PL/SQL

153
154
155
156
157
157
159
160
161
163
164
166
166
167
167
168
169
169
170
172
173
173
175
175
176
177
177
177
180
181
182
182
183
185
185
187
189
191
191
193
195
195
204
205





INSTEAD OF
,



P-

:old :new
WHEN
INSERTING, UPDATING
DELETING


,
PL/SQL :

uc.sql
demobld.sql
unindex.sql
generate.sql

10


,



OTHERS
EXCEPTION_INIT
RAISE_APPLICATION_ERROR

,

1
2
3
,
4

206
207
207
208
208
209
209
209
210
210
210
212
214
214
216
217
218
220
221
222
222
223
224
224
228
229
230
231
231
232
234
234
236
239
240
242
242
243
244
244
245
245

5
,

6
7
8




PL/SQL :

11


-




NULL- NULL-


SELF
%TYPE


ALTER TYPE ... COMPILE
ALTER TYPE ... REPLACE AS OBLECT
DROP TYPE





DML
INSERT
UPDATE
DELETE
- SELECT
- SELECT

245
245
245
246
247
248
248
249
249
250
258
259
260
260
261
261
261
262
262
264
264
264
265
265
267
268
268
269
270
270
270
271
272
273
273
273
275
275
275
275
276
276
277

RETURNING
MAP ORDER
MAP
ORDER
MAP ORDER

12
















EXISTS
COUNT
LIMIT
FIRST LAST
NEXT PRIOR
EXTEND
TRIM
DELETE

13 PL/SQL
PL/SQL
PL/SQL
PL/SQL
SQL*Plus
SQL*Plus

SQL*Plus
EXECUTE

SHOW ERRORS
Oracle

279
279
279
280
281
281
283
284
284
284
286
286
288
290
290
290
291
291
291
292
292
294
294
294
295
296
296
296
297
299
300
302
303
304
306
306
306
306
307
308
309
309
310
311



-

,
OCI
PL/SQL OCI
OCI
SQL-Station


SQL-
PL/SQL

Oracle Forms
PL/SQL Editor
Object Navigator
Procedure Builder


PL/SQL
PL/SQL



14






Debug

1
1: Debug
1: Debug
1:
DBMS_OUTPUT
DBMS_OUTPUT
DBMS_OUTPUT
DBMS_OUTPUT

311
312
312
313
314
314
315
315
317
318
319
320
321
321
322
322
323
323
323
323
324
325
325
325
326
326
326
327
328
328
328
328
328
328
329
329
329
331
332
336
336
336
337
338

2
2: Debug
2: Debug
2:
PL/SQL
Procedure Builder
3
3: Procedure Builder
3:
SQL-Station
4
4: SQL-Station
4:
Procedure Builder SQL-Station



15 PL/SQL

SQL
DBMS_SQL
DML, ,
DDL




DDL




PL/SQL

PL/SQL

out_value_size
PL/SQL :

339
340
341
344
344
345
345
346
349
349
350
351
352
353
353
353
354
355
355
357
358
358
359
362
362
362
363
365
365
365
366
367
368
368
370
370
372
374
374
375
376
377
378

DBMS_SQL PL/SQL 8.0


SQL
DBMS SQL
BIND ARRAY
DEFINE_ARRAY



LONG
DEFINE_COLUMN_LONG
COLUMN_VALUE_LONG

LAST_ERROR_POSITION
LAST_ROW_COUNT
LAST_ROW_ID
LAST_SQL_FUNCTION_CODE
IS_OPEN
PL/SQL : LONG
DBMS_SQL
, DBMS_SQL
DBMS_SQL
DBMS_SQL


LONG


DDL

16
DBMS.PIPE

PACK_MESSAGE
SEND_MESSAGE

RECEIVE_MESSAGE
NEXT_ITEM_TYPE
UNPACK_MESSAGE



PURGE

385
385
:386
336
387
.388
390
393
393
393
.393
394
394
394
394
394
395
395
397
397
397
398
398
398
398
399
399
399
399
399
399
401
402
405
405
406
406
407
407
408
408
408
408
409

Debug.pc
Debug

DBMS_ALERT







DBMS_PIPE DBMS_ALERT

17 Oracle

Advanced Queuing
ENQUEUE
DEQUEUE


Advanced Queuing


SYS.AQ$_AGENT
AQ$_RECIPIENT_LIST_
MESSAGE_PROPERTIES_
ENQUEUE_OPTIONS_
DEQUEUE_OPTIONS_T

ENQUEUE
DEQUEUE

DBMS_AQADM
CREATE_QUEUE_TABLE

409
410
410
411
411
411
411
414
416
417
417
417
417
418
418
419
419
419
419
420
422
423
424
424
424
425
425
425
425
425
426
426
426
426
427
427
428
429
430
430
431
432
432
432

DROP_QUEUE_TABLE
CREATE_QUEUE
DROP_QUEUE
ALTER_QUEUE
START_QUEUE
STOP_QUEUE
ADD_SUBSCRIBER
REMOVE_SUBSCRIBER
QUEUE_SUBSCRIBERS
GRANT_TYPE_ACCESS
START_TIME_MANAGER
STOP_TIME_MANAGER

AO_ADMINISTRATOR_ROLE
AQ_USER_ROLE
Oracle Advanced Queuing


DBA_QUEUE_TABLES/USER_QUEUE_TABLES
DBA_QUEUES/USER_QUEUES









18 /



SUBMIT
RUN





/

433
434
435
435
436
436
436
436
436
437
437
437
437
437
437
437
437
437
438
439
439
439
441
442
443
445
447
449
451
452
453
454
454
455
455
457
458
458
458
459
459
459
459



, UTL_FILE

FOPEN
FCLOSE
IS_OPEN
FCLOSE_ALL

PUT
NEW_LINE
PUT_LINE
PUTF
FFLUSH

Debug

19 Oracle Webserver
Webserver
PL/SQL

CGI WRB

Web- PL/SQL
HTF

OWA_UTIL
HTML
SQL

OWA_IMAGE
OWA_COOKIE

459
460
461
461
461
462
462
462
463
463
463
463
464
465
465
465
465
467
469
472
473
474
475
475
476
476
478
478
479
480
480
480
482
484
485
485
488
490
490
491
494
496
498
498

SEND
GET
GET_ALL
REMOVE

OWA
OWA_UTIL.SHOWPAGE
SQL-Station Coder

20



SQL*Net

-

PL/SQL C



,

RESTRICT_REFERENCES


OCIExtProcRaiseExcp
OCIExtProcRaiseExcpWithMsg
OCIExtProcAllocCallMemory
SQL-
OCIExtProcGetEnv

,


extproc

21
LOB
LOB
LOB DML
LOB

499
499
499
499
500
501
501
502
502
503
504
505
505
506
508
509
510
511
513
514
516
516
517
517
517
517
518
519
519
521
521
521
521
521
521
521
523
523
524
525
526
527
528
528


BFILE

,


BFILE
BFILE DML
BFILE

BFILE
DBMS_LOB
DBMS_LOB
APPEND
COMPARE
COPY
ERASE
FILECLOSE
FILECLOSEALL
FILEEXISTS
FILEGETNAME
FILEISOPEN
FILEOPEN
GETLENGTH
INSTR
LOADFROMFILE
READ
SUBSTR
TRIM
WRITE
,
DBMS_LOB
DBMS_LOB OCI
PL/SQL : LONG LOB

22

Oracle

528
529
529
530
530
530
530
530
530
531
531
532
532
533
533
534
535
536
536
536
536
536
537
537
537
538
541
542
543
543
544
544
545
547
549
550
550
550
551
552
552
553
553






KEEP
UNKEEP
SIZES
SQL-

EXPLAIN PLAN
TKPROF
SQL-Station Plan Analyzer

NESTED LOOP
TABLE ACCESS(FULL)
TABLE ACCESS(BY ROWID)

PL/SQL

PL/SQL
DBMS


DBMS_ALERT
DBMS_APPLICATION_INFO
SET_MODULE
READ_MODULE
SET_ACTION
SET_CLIENT_INFO
READ_CLIENT_INFO
DBMS_AQ DBMS_AQADM
DBMS_DEFER, DBMS_DEFER_SYS DBMS_DEFER_QUERY
DBMS_DDL
ALTER_COMPILE
ANALYZE_OBJECT
DBMS_DESCRIBE
DESCRIBE_PROCEDURE
DBMS_JOB
DBMS_LOB
DBMS_LOCK

553
554
554
554
555
555
555
555
556
556
556
557
559
561
561
561
561
561
562
562
562
562
563
567
568
569
569
569
569
569
569
569
569
570
570
570
570
570
571
571
573
573
573

ALLOCATE_UNIQUE
REQUEST
CONVERT
RELEASE
SLEEP
DBMS_OUTPUT
DBMS_PIPE
DBMS_REFRESH DBMS_SNAPSHOT
DBMS_REPCAT, DBMS_REPCAT_AUTH
DBMS_REPCAT_ADMIN
DBMS_ROWID
DBMS_SESSION
SET_ROLE
SET_SQL_TRACE
SET_NLS
CLOSE_DATABASE_LINK
SET_LABEL
SET_MLS_LABEL_FORMAT
RESET_PACKAGE
UNIQUE_SESSION_ID
DBMS_SHARED_POOL
DBMS_SQL
DBMS_TRANSACTION
SET TRANSACTION
ALTER SESSION ADVISE
COMMIT
ROLLBACK SAVEPOINT
BEGIN_DISCRETE_TRANSACTION
PURGE_MIXED
LOCAL_TRANSACTION_ID
STEP_ID
DBMS_UTILITY
COMPILE_SCHEMA
ANALYZE_SCHEMA
FORMAT_ERROR_STACK
FORMAT_CALL_STACK
IS_PARALLEL_SERVER
GET_TIME
NAME_RESOLVE
PORT_STRING
UTL_FILE
PL/SQL
D

573
573
574
575
575
575
575
576
576
576
576
576
576
576
576
576
577
577
577
577
577
577
577
577
578
578
578
578
578
578
578
578
579
579
579
579
579
579
580
580
581
593
594

all_*/user_*/dba_*
Dependencies ()
Collections ( )
Compile Errors ( )
Directories ()
Jobs ()
Libraries ()
LOBs ( )
Object Methods ( )
Object Method Parameters ( )
Object Method Results ( )
Object References ( )
Object Type Attributes ( )
Schema Objects ( )
Source Code ( )
Tables ()
Table Columns ( )
Triggers ()
Trigger Columns ( )
Views ()

dbms_alert_info
dict_columns

594
594
595
595
596
596
597
597
598
599
599
600
600
601
601
601
602
602
604
605
606
606
606
606
607


. ! .

.
,

.

.
.

.

.
.

,
, , e-mail -
.
ProgBook.net - .

.