Tải bản đầy đủ (.pdf) (15 trang)

Teach Yourself PL/SQL in 21 Days- P16

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (173.02 KB, 15 trang )

monitoring locks, 449
rows, 445
tables, 443-444
exclusive mode, 444
row exclusive mode,
444
row share mode, 444
share lock mode, 444
share row exclusive
mode, 444
LOG function, 158
logarithms, returning, 158
logic errors, 378-379
nonterminating loops, 380
order of operations, 379
logical operators, 76-78
AND, 77
nulls, 89
syntax, 77
NOT, 76-77
nulls, 89
syntax, 76
OR, 77-78
expressions using, 78
nulls, 89
syntax, 77
login_denied exception, 208
logs, maintaining with trig-
gers, 304-306
LONG datatype, 46
syntax, 46


LONG RAW datatype, 47
syntax, 47
LOOP loops, 144, 146
example, 144
EXIT statements with, 144
syntax, 143
loops, 121
CURSOR FOR, 254
debugging, 136
FOR, 121-122, 146
common errors, 124
EXIT statement, 140
listing, 121
nesting, 121
guidelines, 147
incrementing through,
123-124
listing, 123
infinite, 144, 380
jumping into (GOTO), 130
labels, 142-143
changing execution
order, 143
listing, 142
syntax, 142
LOOP, 144, 146
example, 144
EXIT statements with,
144
syntax, 143

nesting, 148
order of execution, 125
REPEAT...UNTIL,
144-146
example, 145
simulating, 145
reversing, 122-123
listing, 122
selecting, 146
spacing, 148
style tips, 148-149
FOR loop confusing
style, 148
FOR loop suggested
style, 148
terminating, 121, 138
WHILE, 134-135,
137-138, 146
examples, 134-135,
137-138
EXIT statement, 139
EXIT WHEN state-
ment, 140
in functions, 137-138
stepping through, 136
syntax, 134
LOWER function, 157
LPAD function, 157
LTRIM function, 157
LUB function, 160

M
MAP method, 366
MAX function, 160
messages
AQ (Advanced Queuing),
587
delay, 587
expiration, 587
repository, 588
queuing, 591
defining payload types,
591-592
placing messages in,
598-604
queue tables, creating,
592-595
queues, creating,
595-597
retrieving messages
from, 604-608
starting/stopping,
597-598
methods, 336
accessor, 342
constructor, 341
referencing, 347
index-by tables, 271-274
MAP, 366
mutator, 342
ORDER, 364-366

publishing, calling Java
from PL/SQL, 571-573
SELF parameter, 361-362
listing, 362
specifying, 362
678 locking
30 SQL Index 11/30/99 1:27 PM Page 678
SSThresh
calling from PL/SQL,
567-568
calling from
SQL*Plus, 566-567
publishing, 565-566
MIN function, 160
minus sign (-)
negation operator, 65, 67
subtraction operator, 65
MLSLABEL datatype
defining output variables,
462
VARIABLE_VALUE pro-
cedure, 469
MOD function, 158
MODE statement, 103
IN, 103
IN OUT, 103
OUT, 103
monitoring locks, 449
MONTHS_BETWEEN
function, 159, 182

syntax, 182
MSLABEL datatype
(syntax), 48
mutating tables (triggers),
320-323, 326-328
workaround example,
323-324
mutator methods, 342
mypi function listing, 107
N
naming
cursors, 247
functions, 101
pipes, 545
stored functions, 106
variables, 35
mixed case, 397
preceding with v_ or
p_, 397
NCLOB datatype (National
Character Large Object),
402
nested blocks, 15
nested tables, 274
declaring, 275
entries
adding to, 275-278
removing, 279-281
extending, 277-278
initializing, 276-277

nesting
blocks, 54
listing, 54-55
FOR loops, 121
listing, 122
functions, 55-56
IF statements, 115-117
listing, 116
syntax, 115
vs IF...ELSIF state-
ment, 119
loops, 148
order of execution, 125
objects, 350
dot notation, 356-357
visibility, 358
procedures, 55-56
networks, performance
(SQL limitations), 8
NEW_LINE procedure, 497
NEW_TIME function, 159,
183-184
syntax, 183
NEXTVAL pseudocolumns,
241
NEXT_DATE procedure,
521
NEXT_DAY function, 159,
179-181
syntax, 179

NEXT_ITEM_TYPE func-
tion, 545
NLS parameters (jobs), 515
NLSSORT function, 157
NLS_CHARSET_ID func-
tion, 160
NLS_CHARSET_NAME
function, 160
NLS_INITCAP function,
157
NLS_LOWER function, 157
NLS_UPPER function, 157
non-query statements, 454,
456-460
binding variables, 455
closing cursor, 456
DBMS_SQL pkg and, 454
executing statements, 456
opening cursor, 454
parsing, 454-455
NOT operator, 76-77
nulls, 89
syntax, 76
Notepad, cutting and past-
ing blocks from, 18
not_logged_on exception,
208
no_data_found exception,
208, 232
NULL statement (uses), 110

nulls
AND operator, 89
checking for, 90
IF statement, 90
in expressions, 86-89, 91
listing, 88
specifying alternate
values, 91
three-valued logic, 87
treating as specific val-
ues, 91
nulls 679
30 SQL Index 11/30/99 1:27 PM Page 679
NOT operator, 89
OR operator, 89
NUMBER datatype, 38
defining output variables,
461
syntax, 39-40
VARIABLE_VALUE
procedure, 468
NUMBER datatype:
subtypes, 40-41
number functions, 158
ABS, 158
ACOS, 158
ASIN, 158
ATAN, 158
ATAN2, 158
CEIL, 158

COS, 158
COSH, 158
EXP, 158
FLOOR, 158
LN, 158
LOG, 158
MOD, 158
POWER, 158
ROUND, 158
SIGN, 158
SIN, 158
SINH, 158
SQRT, 158
TAN, 158
TANH, 158
TRUNC, 158
numbers
absolute values, returning,
158
arc cosines, returning, 158
arc sines, returning, 158
arc tangents, returning,
158
converting to strings,
174-175
converting strings to, 159,
168-173
format masks, 169-170
NLS parameters, 170
converting to strings, 159

cosines, returning, 158
determining negative/
positive/zero, 158
dividing (returning
remainders), 158
exponentiation, 158
factorials, 150
FACTORIAL function,
150
hyperbolic cosines, return-
ing, 158
hyperbolic sines, return-
ing, 158
hyperbolic tangents,
returning, 158
logarithms, 158
raising to powers, 158
rounding, 158
sines, returning, 158
square roots, 158
tangents, returning, 158
truncating, 158
NVL function, 91, 160
O
object identifiers, 349, 358
Object Navigator
(Procedure Builder), 24
object tables, 337, 349,
351-356
creating, 350

deleting objects from,
356
inserting objects,
351-352
retrieving/updating
data, 352-356
versus column storage,
368
object types, 337
defining, 337, 339-343
accessor methods, 342
constructor methods,
341
mutator methods, 342
syntax, 340-341
methods, 368
see also classes
object views, 337
object-oriented program-
ming, see OOP
objects, 336
comparing, 363-366
MAP method, 366
ORDER method,
364-366
deleting from object
tables, 356
instantiating, 336, 343-345
methods (SELF parame-
ter), 361-362

nesting, 350
dot notation, 356-357
visibility, 358
Oracle limitations, 367
overloading functions, 363
package (private versus
public), 205
referencing, 358-359, 361
DREF operator, 359,
361
object identifiers, 358
REF operator, 359, 361
retrieving
from columns, 347-349
from object tables,
352-353
storing
as columns, 345-347
object tables, 349,
351-356
updating
from columns, 347-349
from object tables,
352-356
680 nulls
30 SQL Index 11/30/99 1:27 PM Page 680
OOP (object-oriented pro-
gramming), 335-336
advantages, 336
attributes, 336

classes, 336
encapsulation, 334-335
benefits, 368
inheritance, 335
methods, 336
SELF parameter,
361-362
objects, 336
Oracle limitations, 367
overloading, 363
polymorphism, 335-336
OPEN command, 249
OPEN..FOR statement,
258-259
opening cursors, 248-249
OPEN command, 249
opening files, 494
OPEN_CURSOR function,
454
operands, 64
operators, 64-73, 75-79
arithmetic, 65-67
addition (+), 65
division (/), 65
exponentiation (**),
65-66
identity (+), 65, 67
multiplication (*), 65
negation (-), 65, 67
subtraction (-), 65

binary, 65
comparison, 68-70, 72-74
BETWEEN, 68, 72
dates, 82-83
equality (=), 68
IN, 68, 72-73
inequality (!), 68
inequality (=), 68
IS NULL, 68, 74, 90
less than (<), 68
less than/equal to (<=),
68
LIKE, 68, 70-71
strings, 79-81
DREF, 359, 361
listing, 360
logical, 76-78
AND, 77
NOT, 76-77
OR, 77-78
order of execution (logic
errors), 379
precedence, 84-85
parentheses, 85
REF, 359, 361
listing, 359
relational (sample expres-
sions), 69
string, 78-79
concatenation (||),

78-79
LIKE, 78
unary, 65
VALUE, 354
OR operator, 77-78
expressions using, 78
nulls, 89
syntax, 77
Oracle
databases (obtaining for
exercises), 12
Developer 2000
(Procedure Builder),
24-28
Web site, 12
Oracle Enterprise Server
(SQLPlus Worksheet), 11
Oracle Technology Network,
see OTN
ORDER method, 364-366
order of operations (logic
errors), 379
others exception, 208
OTN (Oracle Technology
Network), 12
OUT arguments, calling
Java from PL/SQL,
575-578
output variables
dbms output.put line()

procedure, 17
defining, 461-463
CHAR datatype, 462
DATE datatype, 462
MLSLABEL datatype,
462
NUMBER datatype,
461
RAW datatype, 462
ROWID datatype, 462
VARCHAR2 datatype,
462
overloaded functions, 178
overloading, 363
advantages, 199-200
body, 199, 201-202
creating, 202-203
cursors, 256-257
return clause, 257
DBMS LOCK, 446-448
ALLOCATE_UNIQUE
function, 446
CONVERT function,
447-448
RELEASE function,
448-449
REQUEST function,
446-447
SLEEP function, 449
DBMS OUTPUT, 25, 484

disabling, 485
enabling, 484-485
reading from, 487-490
writing to, 486-487
DBMS_ALERT, 532
see also alerts
DBMS_JOB, 510
overloading 681
30 SQL Index 11/30/99 1:27 PM Page 681
DBMS_LOB
external LOB func-
tions, 406
internal LOB func-
tions, 416
DBMS_OUTPUT, 491
debugging with, 383,
385
exceptions raised by,
491
DBMS_PIPE, 543-546
functions, 545, 555
procedures, 545,
553-555
DBMS_SQL
anon blocks, 467, 469
error handling func-
tions, 471
non-query statements,
454, 456-460
queries, 460-461,

463-467
DEBUG, 385-387
creating components,
386-387
DEBUG.ERASE pro-
cedure, 388
DEBUG.OUT proce-
dure, 387
declaring, 240-241
dependency, 206
guidelines, 200
invoking, 203
objects, private versus
public, 205
packages, 199, 201-206
procedures, 197
recompiling, 204-205
specification, 199-200
variable declarations,
240
state, 205
subprograms, 199
calling, 203-204
TEXT IO, 25
UTL_FILE, 491, 496-497
clearing buffer, 500
P
PACK_MESSAGE proce-
dure, 545-547
PACK_MESSAGE_RAW

procedure, 553-554
PACK_MESSAGE_ROWID
procedure, 554
parameters
assigning values, 105
CREATE PROCEDURE
command, 191
cursors
declaring, 248
initializing, 248
passing to, 247
scope, 256
defining, 102-103
referencing tables, 103
syntax, 103
dropping queue tables,
609
enqueuing messages,
602-604
event triggers, defining,
312
granting revoking queue
access, 609
job definitions, 516
message queues, creating,
596-597
modes, 103
IN, 103
IN OUT, 103
OUT, 103

NLS (jobs), 515
Passing to functions, 111
procedures, 195
parameter definitions,
195
SELF, 361-362
listing, 362
specifying, 362
triggers, 298-299,
312-313, 318-319
condition, 299, 313,
318
correlation names,
299-300, 318
declarations, 299, 313,
318
instead-of, 318
pl/sql code, 299, 313,
318
table name, 299, 318
verb list, 298, 318
parentheses ( ), operator
precedence, 85
PARSE procedure, 454
parsing statements, 454-455
queries, 461
payload, AQ (Advanced
Queuing), 587
payload types, defining
(message queuing),

591-592
percent sign (%) (wildcard
character), 70
performance, network (SQL
limitations), 8
pipes
clearing message buffer,
554
creating, 546, 550-551
moving messages to
buffer, 548
multiple sessions, 544
naming, 545
operation of, 544
private, 544
public, 543
682 overloading
30 SQL Index 11/30/99 1:27 PM Page 682
RAW data
PACK_MESSAGE_
RAW procedure,
553-554
UNPACK_
MESSAGE_RAW
procedure, 554
readers, 543
reading data from,
551-553
removing, 549-550, 553
removing all data from,

555
retrieving message from
buffer, 548-549
rowids
decoding, 554
sending, 554
sending data to, 547
size, 545
versus alerts, 555-557
writers, 543
PL/SQL, 10
block structure, 13
compiling and execut-
ing blocks, 15-17
syntax, 14-15
blocks, alternatives to
retyping, 18-20
calling from Java (SQLJ),
578-579
calling procedures and
functions, 580, 582
executing blocks,
578-579
calling Java from, 569
datatype compatibility,
574-575
Employee class,
569-570
methods, publishing,
571-573

OUT and IN OUT
arguments, 575-578
calling methods
(SSThresh), 567-568
output (dbms output.put
line() procedure), 17
processing benefits, 9
platform independence
(PL/SQL benefits), 9
Platinum Technology Inc.
Web site, 11
PLS_INTEGER datatype,
43
syntax, 44
plus sign (+)
addition operator, 65
identity operator, 65, 67
pointers (cursors), 246
pointers, see locators
polling (alerts), setting time
interval, 536
polymorphism, 335-336
portability (PL/SQL bene-
fits), 9
POWER function, 158
powers, raising numbers to,
158
precedence, operators,
84-85
parentheses, 85

predefined exceptions
invalid_cursor, 232
no_data_found, 232
too_many_rows, 232
value_error, 232
when_others, 232
predefined Oracle errors,
207-209
cursor_already_open, 208
dup_val_on_index, 208
invalid_cursor, 208
invalid_number, 208
login_denied, 208
not_logged_on, 208
no_data_found, 208
others, 208
program_error, 208
storage_error, 208
timeout_on_resource, 208
too_many_rows, 208
transaction_backed_out,
208
value_error, 208
zero_divide, 208
private objects (packages),
205
private pipes, 544
creating, 546, 550-551
privileges, database (exer-
cise completion require-

ments), 12
Procedural Language/
Structured Query
Language, see PL/SQL
procedural languages, 10
procedure blocks, 51
syntax, 52-53
Procedure Builder (Oracle
Developer 2000), 24-28
database connections,
27-28
PL/SQL interpreter, 25-26
SS THRESH function,
creating, 26
starting, 24
procedures, 190, 192-195,
197, 199
AQ (Advanced Queueing),
608
dropping queue tables,
609
dropping queues, 608
queue access,
granting/revoking,
609-610
BROKEN, 522
procedures 683
30 SQL Index 11/30/99 1:27 PM Page 683

×