Teach Yourself PL/SQL in 21 Days- P16

15 358 0
Teach Yourself PL/SQL in 21 Days- P16

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

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 CHANGE, 520 CLOSE_CURSOR, 456 COLUMN_VALUE, 463 creating, 190, 192 debugging information, 193 declarative part, 190 defining, 52-53 listing, 53 dependencies, discovering, 192 exception-handling part, 190 executable part, 190 FCLOSE, exceptions raised by, 494 FCLOSEALL, exceptions raised by, 494 FCLOSE_ALL, 494 FFLUSH, 500 exceptions raised by, 498 INTERVAL, 521 nesting, 55-56 NEW_LINE, 497 NEXT_DATE, 521 overloading, 197 PACK_MESSAGE, 545-547 PACK_MESSAGE_RAW, 553-554 PACK_MESSAGE_ ROWID, 554 parameters (definitions), 195 PARSE, 454 PURGE, 545, 555 PUT, 497 exceptions raised by, 498 PUTF, 498 exceptions raised by, 498 PUT_LINE, 498 exceptions raised by, 498 re-creating, 194 listing, 194 recursive, 197, 199 terminating conditions, 198 REGISTER, 534 REMOVE, 535 REMOVEALL, 536 replacing, 194 RESET_BUFFER, 545, 554 RETURN statement, 192 RUN, 514-515 SET_DEFAULTS, 536 SIGNAL, 533 stored, 190 creating, 191 dropping, 197 invoking, 194, 199 listing information, 195 recompiling, 193-194 SUBMIT, 512, 514 parameters, 512 swapn (listing), 57-58 UNPACK_MESSAGE, 545, 548-549 UNPACK_MESSAGE_ RAW, 554 UNPACK_MESSAGE_ ROWID, 554 uses, 190 VARIABLE_VALUE CHAR datatype, 468 DATE datatype, 468 MLSLABEL datatype, 469 NUMBER datatype, 468 RAW datatype, 468 ROWID datatype, 469 VARCHAR2 datatype, 468 versus functions, 190 WAITANY, 535 WAITONE, 534 WHAT, 521 processing (PL/SQL bene- fits), 9 producers, 586 AQ (Advanced Queuing), 587 program code, see listings program_error exception, 208 propagate exceptions, 214 propagation, AQ (Advanced Queuing), 587-588 pseudocolumns, 241 CURRVAL and NEXTVAL, 241 ROWID, 242 ROWNUM, 242 public objects (packages), 205 public pipes, 543 creating, 550-551 publishing methods, calling Java from PL/SQL, 571-573 SSThresh method, creat- ing Java procedures, 565-566 PURGE procedure, 545, 555 PUT command, 193 PUT procedure, 497 exceptions raised by, 498 PUTF procedure, 498 exceptions raised by, 498 PUT_LINE command, 193 listing, 193 PUT_LINE procedure, 498 exceptions raised by, 498 684 procedures 30 SQL Index 11/30/99 1:27 PM Page 684 Q queries, 460-461, 463-467 binding variables, 461 closing cursor, 466 counting rows returned, 160 defining output variables, 461-463 CHAR datatype, 462 DATE datatype, 462 RAW datatype, 462 ROWID datatype, 462 executing (SQL*Plus), 10 executing statements, 463 fetching rows, 463 parsing statements, 461 reading results into vari- ables, 463-465 SELECT statement exam- ple, 466-467 Quest Software Web site, 11 queuing AQ (Advanced Queuing), 585-586, 608 agents, 587 consumers, 587 control data, 587 deferred messaging0, 587 delay, 587 dequeue, 587 disconnected messag- ing, 587 dropping queue tables, 609 dropping queues, 608 enqueue, 587 granting/revoking access, 609-610 message repository, 588 messages, 587 expiration, 587 payload, 587 producers, 587 propagation, 587-588 sample scenario, 590 server configuration, 588-589 transaction support, 588 transparency, 588 message queuing, 591 defining payload types, 591-592 queue tables, creating, 592-595 queues, creating, 595-597 placing messages in queues, 598, 602 parameters, 602-604 record types, 599-602 retrieving messages from queues, 604, 606 dequeuing change mes- sages, 606-608 record types, 604-606 starting/stopping queues, 597-598 R raising exceptions, 214 RAW datatype, 46 defining output variables, 462 syntax, 47 VARIABLE_VALUE pro- cedure, 468 RAWTOHEX function, 159 READ function (LOBs), 416, 421 BFILE, 406, 411 read-only transactions, 438 read-write transactions, 438 readers (pipes), 543 reading from DBMS OUT- PUT package (syntax), 487-490 RECEIVE_MESSAGE function, 545, 548 recompiling packages, 204-205 stored procedures, 193-194 record variables %rowtype attribute, 236 cursor-based, 239 declaring, 234-235 table-based, 236 records attributes (%TYPE), 235-236 dequeuing messages, 604 DEQUEUE_OPTIONS _T, 605-606 enqueing messages, 599-602 AQ$_AGENT, 601 AQ$_RECIPIENT_ LIST_T, 602 ENQUEUE_OPTIONS _T, 600 referencing fields (dot notation), 237 recursive functions, 149 FACTORIAL, 150 testing, 151 uses, 152 recursive procedures, 197, 199 terminating conditions, 198 REF cursor type (declaring in packages), 260 REF operator, 359, 361 listing, 359 REF operator 685 30 SQL Index 11/30/99 1:27 PM Page 685 referencing objects, 358-359, 361 DREF operator, 359, 361 object identifiers, 358 REF operator, 359, 361 values (index-by tables), 268-269 REGISTER procedure, 534 relational operators (sample expressions), 69 RELEASE function (DBMS LOCK package), 448-449 remainders (division), returning, 158 REMOVE procedure, 535 REMOVEALL procedure, 536 REMOVE_PIPE function, 545, 549-550 removing classes (SSConstants), 568-569 data (varrays), 283-284 jobs, 520 pipes, 549-550, 553 REPEAT .UNTIL loops, 144-146 example, 145 simulating, 145 REPLACE function, 157 Repositories, message (AQ), 588 REQUEST function (DBMS LOCK package), 446-447 requirements (completing exercises), 12 RESET_BUFFER proce- dure, 545, 554 retrieving objects from columns, 347-349 from object tables, 352-353 return data types, 105 RETURN statement, 101, 192 return values, function, dis- playing, 23 retyping blocks (alterna- tives), 18-20 REVERSE keyword (loops), 122-123 revoking access queues (AQ), 609-610 ROLLBACK command, 441 ROLLBACK statements, 234 rolling back transactions, 438, 441 ROLLBACK command, 441 savepoints, 441-442 ROUND function, 158-159, 184-185 format masks, 177 syntax, 184-185 rounding numbers, 158 ROW ID, converting to string, 159 row-level triggers, 296 ROWID datatype defining output variables, 462 syntax, 47-48 VARIABLE_VALUE pro- cedure, 469 ROWID pseudocolumns, 242 ROWIDTOCHAR function, 159 ROWNUM pseudocolumns, 242 rows counting number returned, 160 fetching into buffer, 463 inserting, 226-229 employee table exam- ple, 227, 229 locking, 445 RPAD function, 157 RTRIM function, 157 RUN procedure, 514-515 S SAVEPOINT statements, 234 savepoints, 441-442 saving address objects in tables, 346 scalar variables, 34 scientific notation, 174 scope, 58 cursors, 262 exceptions, 214 listing, 58-59 SELECT FUNCTION com- mand, 161 SELECT statement, 223, 229-230 examples, 229-230 exceptions, 232 syntax, 229, 233 SELF parameter, 361-362 listing, 362 specifying, 362 SEND_MESSAGE function, 545, 547 Server Manager, 11 servers configuring for AQ (Advanced Queuing), 588-589 PL/SQL processing bene- fits, 9 SET SERVEROUTPUT ON statement, 108 686 referencing 30 SQL Index 11/30/99 1:27 PM Page 686 SET TRANSACTION com- mand, 439 SET TRANSACTION state- ments, 234 SET_DEFAULTS proce- dure, 536 SHUTDOWN trigger (list- ing), 315 SIGN function, 158 SIGNAL procedure, 533 SIN function, 158 sines, returning, 158 hyperbolic, 158 inverse, 158 SINH function, 158 slash (/), 65 SLEEP function (DBMS LOCK package), 449 SNP parameters, 511 software (exercise comple- tion requirements), 12 SOUNDEX function, 157 SQL, 9 limitations, 8 SQL*Plus @ command, 18-19 calling methods (SSThresh), 566-567 EDIT command, 19-20 interactivity, 10 entering statements, 10 executing queries, 10 Server Manager, 11 SQL-Navigator (Quest Software), 11 SQL-Programmer (Sylvain Faust Inc.), 11 SQL-Station (Platinum Technology Inc.), 11 SQLCODE function, 160, 211-212 SQLERRM function, 160, 211-212 SQLJ, calling PL/SQL from Java, 578-579 calling procedures and functions, 580, 582 executing blocks, 578-579 SQLPlus Worksheet, 11, 28 executing blocks, 28-29 SQRT function, 158 square roots, 158 squareme function listing, 110 SS CONSTANTS class, cre- ating Java procedures, 562-563 SS THRESH function creating (Procedure Builder), 26 listing, 20 with an error, 21 SSConstants class, removing from databases, 568-569 SSThresh function, 563 listing, 100 SSThresh method calling from PL/SQL, 567-568 calling from SQL*Plus, 566-567 publishing, 565-566 starting Procedure Builder (Oracle Developer 2000), 24 queues, 597-598 starting transactions, 438-439 SET TRANSACTION command, 439 STARTUP triggers (listing), 315 statement labels, 128 accessing, 128 format, 128 statement-level triggers, 296 statements BEGIN, 101 bulk-binding, 284 BULK COLLECT key- word, 285-286 FORALL keyword, 286-288 COMMIT, 440 CREATE FUNCTION, 26 CREATE TABLE, 224 DELETE, 223 syntax, 231 DML (LOCK TABLE), 233 END, 101 EXCEPTION, 101, 106 executing, 456 for queries, 463 EXIT, 138-142 changing loop execution order, 143 with FOR loop, 140 with WHILE loop, 139 within functions, 141 EXIT WHEN, 138-142 syntax, 138 with WHILE loop, 140 FETCH (INTO clause), 259 GOTO, 128-129, 131-132, 134 disadvantages, 133-134 example, 133 scoping rules, 129, 131, 133 syntax, 128 IF, 112-113 common errors, 120 formatting, 119-120 jumping into (GOTO), 131 jumping within (GOTO), 131-133 statements 687 30 SQL Index 11/30/99 1:27 PM Page 687 [...]... procedures, 190 dropping, 197 invoking, 194, 199 listing information, 195 recompiling, 193-194 storing objects as columns, 345-347 retrieving/updating, 347-349 object tables, 349, 351-356 creating, 350 inserting objects, 351-352 string expressions, 86 string operators, 78-79 concatenation (||), 78-79 listing, 78 LIKE, 78 strings capitalizing, 157 initial letters, 156-157 comparing, 79-81 case sensitivity,... integrity (maintaining), 300-304 listing, 302 defining, 299-300, 313, 319 delete, 296 enabling/disabling, 310-311 event, 311-312 defining, 312-314 writing, 314-317 example, 295-296 execution order, 297 firing (events), 294 guidelines, 298 historical logs, 304-306 insert, 296 instead-of, 318 syntax, 318 writing, 319 limitations, 320-324, 326-328 DDL statements, 320 mutating tables, 320-323, 326-328 listing,... adding\removing data, 283-284 declaring, 282-283 variables binding, 455 queries, 461 BLOB, initializing, 160 CLOB, initializing, 160 691 cursors, 257-261 as arguments, 260-261 assigning, 260 declaring, 257-258 FETCH statement, 259 OPEN FOR statement, 258-259 return clauses, 258 strong, 258 weak, 258 declaring, 49-50 listing, 50-51 naming, 35 mixed case, 397 preceding with v_ or p_, 397 output, defining,... correcting (example), 375-376 SYSDATE function, 159, 175-176 date/time origin, 186 default output, 176 formatting output, 176 T tables adding data to (CLOB data), 423-424 adding records to, 458-460 creating, 223-224, 456, 458 CREATE TABLE command, 224 DUAL, 161 index-by, 266 declaring, 266-267 deleting entries, 270271 inserting entries into, 267-268 methods, 271-274 referencing values, 268-269 updating... SERVEROUTPUT ON, 108 SQL, entering in SQL*Plus, 10 executing queries, 10 terminators (block syntax), 14 transaction control, 234 UPDATE, 223 object tables, 355 syntax, 231 see also loops STDDEV function, 160 stepping through loops, incrementing, 123-124 listing, 123 stopping queues, 597-598 storage_error exception, 208 stored functions creating, 106-108 syntax, 106 naming, 106 squareme (listing), 110 stored procedures,... updating entries, 270 inserting rows, 226-229 employee table example, 227, 229 689 locking, 443-444 exclusive mode, 444 row exclusive mode, 444 row share mode, 444 share lock mode, 444 share row exclusive mode, 444 message queuing, creating, 592-595 mutating (triggers), 320-323, 326-328 nested, 274 adding entries to, 275-278 declaring, 275 extending, 277-278 initializing, 276-277 removing entries, 279-281... 79-81 listing, 81 concatenating (CONCAT function), 156 converting dates to, 166-168 hex to raw, 159 multibyte to singlebyte, 159 numbers to, 159, 174-175 raw to hex, 159 single-byte to multibyte, 159 to dates, 159, 161-166 to labels, 159 to numbers, 159, 168-173 padding, 157 phonetic representations, 157 replacing, 157 returning as lowercase, 157 returning length, 157 returning location of INSTR function,... package, 485 disabling, 485 enabling, 485 reading from buffer, 487-490 writing to buffer, 486-487 functions, declaring, 101-102 LOCK TABLE statement, 233 LONG datatype, 46 LONG RAW datatype, 47 message queues creating, 596-597 starting/stopping, 597-598 MSLABEL datatype, 48 PLS_INTEGER datatype, 44 program blocks, 14-15 nesting, 15 RAW datatype, 47 ROWID datatype, 48 triggers, 298-300 instead-of, 318... 318 declarations, 299, 313, 318 pl/sql code, 299, 313, 318 table name, 299, 318 verb list, 298, 318 records, predating, 329 row-level, 296 SHUTDOWN (listing), 315 single-row inserts, 329 STARTUP (listing), 315 statement-level, 296 syntax, 298-300 update, 296 viewing code, 309-310 creating command file, 310 TRIM function (LOBs), 416, 422, 429 troubleshooting, see debugging TRUNC function, 158-159, 176-178... package, 491, 496-497 clearing buffer, 500 file input, 496 opening files, 494 testing for open files, 497 writing to files PUT procedure, 497 PUTF procedure, 498 V VALUE operator, 354 Values, index-by tables, referencing, 268-269 value_error exception, 208, 232 VARCHAR2 datatype, 35 defining output variables, 462 subtypes, 36 syntax, 35-36 VARIABLE_VALUE procedure, 468 vs CHAR (listing), 38 variable declarations . 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,. values, returning, 158 arc cosines, returning, 158 arc sines, returning, 158 arc tangents, returning, 158 converting to strings, 174-175 converting strings to,

Ngày đăng: 20/10/2013, 17:15

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan