Tài liệu Oracle PLSQL Language- P3 pdf

50 364 0
Tài liệu Oracle PLSQL Language- P3 pdf

Đ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

routines can now call the JSP as if it were another PL/SQL module. 1.19.1 Example Let's write a simple "Hello, World" JSP that will accept an argument: package oreilly.plsquick.demos; public class Hello { public static String sayIt (String toWhom) { return "Hello, " + toWhom + "!"; } } Saved in a file called Hello.java, we can load the source code directly into Oracle. Doing so will automatically compile the code. A simple form of the loadjava command: loadjava -user scott/tiger -oci8 oreilly/plsquick/ demos/Hello.java The Hello.java file follows the Java file placement convention for packages and so exists in a subdirectory named oreilly/plsquick/demos. Now we can fire up our favorite SQL interpreter, connect as SCOTT/TIGER, and create the call spec for the Hello.sayIt( ) method: CREATE FUNCTION hello_there (to_whom IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'oreilly.plsquick.demos.Hello.sayIt (java.lang.String) return java.lang.String'; / Now we can call our function very easily: BEGIN DBMS_OUTPUT.PUT_LINE(hello_there('world')); END; / And we get: Hello, world! Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. as the expected output. 1.19.2 Publishing Java to PL/SQL To write a call spec, use the AS LANGUAGE JAVA clause in a CREATE statement. The syntax for this clause is: { IS | AS } LANGUAGE JAVA NAME 'method_fullname [ (type_fullname, . ] [ return type_fullname ]' method_fullname is the package-qualified name of the Java class and method. It is case-sensitive and uses dots to separate parts of the package full name. type_fullname is the package-qualified name of the Java datatype. Notice that a simple string, not an SQL name, follows the NAME keyword. Type mapping follows most JDBC rules regarding the legal mapping of SQL types to Java types. Oracle extensions exist for Oracle-specific datatypes. Most datatype mappings are relatively straightforward, but passing Oracle8 objects of a user-defined type is harder than one would think. Oracle provides a JPublisher tool that generates the Java required to encapsulate an Oracle8 object and its corresponding REF. Refer to Oracle's JPublisher documentation for guidelines on usage. The AS LANGUAGE JAVA clause is the same whether you are using Java as a standalone JSP, the implementation of a packaged program, or the body of an object type method. For example, here is the complete syntax for creating JSPs as PL/SQL-callable functions or procedures: CREATE [OR REPLACE] { PROCEDURE procedure_name [(param[, param] .)] | FUNCTION function_name [(param[, param] .)] RETURN sql_type } [AUTHID {DEFINER | CURRENT_USER}] [PARALLEL_ENABLE] [DETERMINISTIC] { IS | AS } LANGUAGE JAVA NAME 'method_fullname [ (type_fullname, . ] [ return type_fullname ]' When using Java as the implementation of a packaged procedure or function, Oracle allows you to place the Java call spec in either the package specification (where the call spec substitutes for the subprogram specification) or in the package body (where the call spec substitutes for the subprogram body). Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Similarly, when using JSPs in object type methods, the Java call spec can substitute for either the object type method specification or its body. Note that Java functions typically map to PL/SQL functions, but Java functions declared void map to PL/SQL procedures. Also, you will quickly learn that mistakes in mapping PL/SQL parameters to Java parameters become evident only at runtime. 1.19.3 Data Dictionary To learn what Java library units are available in your schema, look in the USER_OBJECTS data dictionary view where the object_type is like `JAVA%'. If you see a Java class with INVALID status, it has not yet been successfully resolved. Note that the names of the Java source library units need not match the names of the classes they produce. As of press time, there is no apparent way to discover which stored programs are implemented as Java stored procedures. You can look in the USER_SOURCE view for named programs that contain the source text `AS LANGUAGE JAVA', but that may not yield accurate results. The USER_DEPENDENCIES view does not track the relationship between PL/SQL cover programs and their underlying Java class. Even if you have loaded the Java source code into the database, there is no supported way of retrieving the source from the data dictionary. Previous: 1.18 External Procedures Oracle PL/SQL Language Pocket Reference 1.18 External Procedures The Oracle Library Navigation Copyright (c) 2000 O'Reilly & Associates. All rights reserved. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. By Steven Feuerstein & Bill Pribyl; ISBN 1-56592-335-9E Second Edition, published September 1997. (See the catalog page for this book.) Search the text of Oracle PL/SQL Programming, 2nd Edition. Index Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Y | Z Table of Contents Dedication Foreword Preface Part I: Programming in PL/SQL Chapter 1: Introduction to PL/SQL Chapter 2: PL/SQL Language Fundamentals Chapter 3: Effective Coding Style Part II: PL/SQL Language Elements Chapter 4: Variables and Program Data Chapter 5: Conditional and Sequential Control Chapter 6: Database Interaction and Cursors Chapter 7: Loops Chapter 8: Exception Handlers Chapter 9: Records in PL/SQL Chapter 10: PL/SQL Tables Part III: Built-In Functions Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Chapter 11: Character Functions Chapter 12: Date Functions Chapter 13: Numeric, LOB, and Miscellaneous Functions Chapter 14: Conversion Functions Part IV: Modular Code Chapter 15: Procedures and Functions Chapter 16: Packages Chapter 17: Calling PL/SQL Functions in SQL Part V: New PL/SQL8 Features Chapter 18: Object Types Chapter 19: Nested Tables and VARRAYs Chapter 20: Object Views Chapter 21: External Procedures Part VI: Making PL/SQL Programs Work Chapter 22: Code Design Tips Chapter 23: Managing Code in the Database Chapter 24: Debugging PL/SQL Chapter 25: Tuning PL/SQL Applications Chapter 26: Tracing PL/SQL Execution Part VII: Appendixes Appendix A: What's on the Companion Disk? Appendix B: Calling Stored Procedures from PL/SQL Version 1.1 Appendix C: Built-In Packages The Oracle PL/SQL CD Bookshelf Navigation Copyright © 2000 O'Reilly & Associates. All Rights Reserved. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Full Text Search If you are having difficulty searching, or if you have not used this search utility before, please read this. The Oracle PL/SQL CD Bookshelf Navigation Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Y | Z Index: Symbols and Numbers \:= (assignment) operator 2.1. The PL/SQL Character Set 4.4.3. Default Values 9.5. Assigning Values to and from Records -- (comment indicator) : 2.5.1. Single-Line Comment Syntax > (label delimeters) : 5.2.1. The GOTO Statement ' (quotation mark) 2.3.1. Embedding Single Quotes Inside a String 11.1.10. The REPLACE function ; (semicolon) : 2.4. The Semicolon Delimiter /* and */ (comment block delimiters) : 2.5.2. Multiline Comment Syntax || (concatenation) operator 4.3.3. Function Results with NULL Arguments 11.1.3. The CONCAT function Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Y | Z The Oracle Library Navigation Copyright (c) 2000 O'Reilly & Associates. All rights reserved. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Y | Z Index: A ABS function : 13.1.1. The ABS function absolute value : 13.1.1. The ABS function abstract data types : (see ADTs) abstraction : 18.1.5.3. Abstraction access to compiled code, tuning : 25.2. Tuning Access to Compiled Code to data, tuning : 25.3. Tuning Access to Your Data data structure, encapsulating : 1.7.2. Synchronize Program and Data Structures to SQL, minimizing : 25.3.1. Use Package Data to Minimize SQL Access ACCESS table, tuning : 25.2.3. Tune ACCESS$ Table to Reduce First Execution Time of Code actual parameters : 15.6.3. Actual and Formal Parameters Ada programming language : Preface ADD_MONTHS function : 12.1.1. The ADD_MONTHS function customizing : 12.2.1. Customizing the Behavior of ADD_MONTHS adding collection elements : 19.4.3. Adding and Removing Elements administration of Oracle databases : About the Contents administration, Oracle/AQ : C.3.2. DBMS_AQADM (PL/SQL 8 Only) ADTs (abstract datatypes) (see also object types) 18.1.4.2. Classification building : 22.6. Construct Abstract Data Types (ADTs) advanced queuing : 1.4.7.2. Oracle/AQ, the Advanced Queueing Facility ADVISE_COMMIT procedure : C.15.1. The ADVISE_COMMIT procedure ADVISE_NOTHING procedure : C.15.2. The ADVISE_NOTHING procedure ADVISE_ROLLBACK procedure : C.15.3. The ADVISE_ROLLBACK procedure aggregate assignment into rows : 10.6.3. Aggregate Assignment operations 9.1.3.2. Aggregate operations 9.5.4. Aggregate Assignment 9.6.1.2. Records of the same type of nested records : 9.7.3. Aggregate Assignments of Nested Records Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. values, combining with scalars : 17.8.2. Combining Scalar and Aggregate Values aggregation : 18.1.4.3. Inheritance alerts : (see DBMS_ALERT package) algorithms, tuning : 25.4. Tuning Your Algorithms aliases column 6.7. Column Aliases in Cursors 9.3.2. Setting the Record's Column Names directory : 13.2.1. The BFILENAME function for cursor variables : 6.12.6.3. Cursor variable aliases alignment of code : (see coding, layout of) ALLOCATE_UNIQUE procedure : C.7.1. The ALLOCATE_UNIQUE procedure ALTER SESSION command : 26.1.1. Enabling Program Units for Tracing ALTER TABLE statement : 20.6. Schema Evolution ALTER_COMPILE procedure : C.4.1. The ALTER_COMPILE procedure ALTER_QUEUE procedure : C.3.2.4. The ALTER_QUEUE procedure ANALYZE statement : 25.1. Analyzing Program Performance ANALYZE_OBJECT procedure : C.4.2. The ANALYZE_OBJECT procedure ANALYZE_SCHEMA procedure : C.16.1. The ANALYZE_SCHEMA procedure anchored datatypes 1.6.1. Anchored declarations 4.5. Anchored Declarations anchoring to subtypes : 4.6.3. Emulating Constrained Subtypes angle brackets (>) as label delimiters : 5.2.1. The GOTO Statement anonymous blocks : 15.3. The Anonymous PL/SQL Block labels for : 15.3.6. Block Labels nested : 15.3.4. Nested Blocks in Oracle Tools : 15.3.3. Anonymous Blocks in the Oracle Tools APPEND procedure : C.6.1. The APPEND procedure applications, tuning : 25. Tuning PL/SQL Applications access to compiled code : 25.2. Tuning Access to Compiled Code access to data : 25.3. Tuning Access to Your Data analyzing performance : 25.1. Analyzing Program Performance optimizing algorithms : 25.4. Tuning Your Algorithms AQ : (see advanced queuing) arguments, trapping invalid : 22.2.4.1. Trap invalid argument values arrays (see also tables) 1.4.3.4. PL/SQL tables building with tables : 10.9.4. Building Traditional Arrays with PL/SQL Tables package for (see also PSG_array package) Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 10.9.4.3. Features of the array package variable arrays : 1.4.7.3. Variable arrays and nested tables objects for : 18.1.2. Some Simple Examples variable-size : (see VARRAYs) ASCII function : 11.1.1. The ASCII function assertion modules : 22.2.4. Use Assertion Modules to Validate Parameters and Assumptions assigning objects : 18.4.1.2. Direct assignment assignment (\:=) operator 2.1. The PL/SQL Character Set 4.4.3. Default Values 9.5. Assigning Values to and from Records association operator for positional notation (=>) : 2.1. The PL/SQL Character Set association, object : 18.1.4.3. Inheritance atomics of PL/SQL language : 2.1. The PL/SQL Character Set attributes, cursor 6.9. Cursor Attributes 6.12.2. Similarities to Static Cursors attributes, object : 18.1.1. Terminology collections as : 19.2.1.2. Collection as an attribute of an object type dot notation for 18.3.4.1. Dots in data structures 18.3.4.3. Attribute or method? object equality and : 18.3.6.2. Equality comparisons authority, execute/run : (see execute authority) Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Y | Z The Oracle Library Navigation Copyright (c) 2000 O'Reilly & Associates. All rights reserved. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... Cursors Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark variables in : 6.4.2 PL/SQL Variables in a Cursor Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Y | Z The Oracle Library Navigation Copyright (c) 2000 O'Reilly & Associates All rights reserved Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark... dynamic SQL 6.2.1 Types of Cursors Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Y | Z The Oracle Library Navigation Copyright (c) 2000 O'Reilly & Associates All rights reserved Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Symbols | A | B... : 1.2 The Concept of Programming in Oracle Applications COPY procedure : C.6.3 The COPY procedure correlated subqueries : 17.8.3 Replacing Correlated Subqueries correlation variables : 18.4.2.2 REFs COS function : 13.1.7 The COS function COSH function : 13.1.8 The COSH function COUNT function 10.8.2.1 The COUNT function Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 19.6.1... on : C Built-In Packages Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Y | Z The Oracle Library Navigation Copyright (c) 2000 O'Reilly & Associates All rights reserved Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W |... Code as Possible Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark shared, executing : 23.1 Executing Stored Code structuring of : 1.7.5 Structured Code and Other Best Practices style of : 1.7.4 Standardize Your PL/SQL Development Environment testing : 24.2.5 Change and Test One Area of Code at a Time coding : 1.2 The Concept of Programming in Oracle Applications analyzing size... 1: Set Up the Listener Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Y | Z The Oracle Library Navigation Copyright (c) 2000 O'Reilly & Associates All rights reserved Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W |... function concatenation (||) operator 4.3.3 Function Results with NULL Arguments 11.1.3 The CONCAT function concatenation, string 4.3.3 Function Results with NULL Arguments Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 11.1.3 The CONCAT function conditional control structures : 5 Conditional and Sequential Control formatting : 3.3 Formatting Control Structures conditional... : 14.2.2 The CONVERT function characters adding to strings : 11.1.11 The RPAD function converting to numbers, package for : 17.8.7 Recursive Processing in a SQL Statement Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark datatypes for : 4.2.3 Character Datatypes extracting from strings : 11.1.14 The SUBSTR function NLS datatypes for : 4.2.6 NLS Character Datatypes replacing... 6.9.4 The %ISOPEN Attribute %NOTFOUND 6.6.2 Fetching Past the Last Row 6.9.2 The %NOTFOUND Attribute %ROWCOUNT : 6.9.3 The %ROWCOUNT Attribute closing : 6.8 Closing Cursors Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark column aliases in : 6.7 Column Aliases in Cursors corresponding to records : 9.1.4 Guidelines for Using Records cursor variables 1.4.5.2 Cursor variables... Structure 15 Procedures and Functions anonymous : 15.3 The Anonymous PL/SQL Block constructing : 15.2.1 Sequence of Section Construction cursors in : 15.3.5.4 Cursor scope Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark labels for : 15.3.6 Block Labels local : 15.7 Local Modules nested 15.3.4 Nested Blocks 15.3.5.2 Scope and nested blocks parameters of : 15.6 Parameters . to Java types. Oracle extensions exist for Oracle- specific datatypes. Most datatype mappings are relatively straightforward, but passing Oracle8 objects. think. Oracle provides a JPublisher tool that generates the Java required to encapsulate an Oracle8 object and its corresponding REF. Refer to Oracle& apos;s

Ngày đăng: 24/12/2013, 02:17

Từ khóa liên quan

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

  • Đang cập nhật ...

Tài liệu liên quan