PL/SQL Packages and Types Reference, 10g Release 1 10.1Part No.. PL/SQL Packages and Types Reference, 10g Release 1 10.1Part No.. This reference manual describes the Oracle PL/SQL packag
Trang 110g Release 1 (10.1)
Part No B10802-01
December 2003
Trang 2PL/SQL Packages and Types Reference, 10g Release 1 (10.1)
Part No B10802-01
Copyright © 1998, 2003 Oracle Corporation All rights reserved.
Primary Author: Den Raphaely
Contributing Authors: Gina Abeles, Cathy Baird, Deanna Bradshaw, Craig Foch, Laurel Hale, Paul Lane, Jeff Levinger, Roza Leyderman, Chuck Murray, Eric Paapanen, Kathy Rich, Vivian Schupmann, Ingrid Stuart, Randy Urbano
Contributors: Ted Burroughs, Shelley, Higgins, Jennifer Polk, Colin McGregor, Chuck Murray, Richard Smith
Graphics Production Specialist: Valarie Moore
The Programs (which include both the software and documentation) contain proprietary information of Oracle; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent and other intellectual and industrial property laws Reverse engineering, disassembly or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited The information contained in this document is subject to change without notice If you find any problems
in the documentation, please report them to us in writing Oracle does not warrant that this document is error-free Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or
mechanical, for any purpose, without the express written permission of Oracle.
If the Programs are delivered to the U.S Government or anyone licensing or using the programs on behalf of the U.S Government, the following notice is applicable:
Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial computer software" and use, duplication, and disclosure of the Programs, including documentation, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement.
Otherwise, Programs delivered subject to the Federal Acquisition Regulations are "restricted computer software" and use, duplication, and disclosure of the Programs shall be subject to the restrictions in FAR 52.227-19, Commercial Computer Software - Restricted Rights (June, 1987) Oracle, 500 Oracle Parkway, Redwood City, CA 94065.
The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently dangerous applications It shall be the licensee's responsibility to take all appropriate fail-safe, backup, redundancy, and other measures to ensure the safe use of such applications if the Programs are used for such purposes, and Oracle disclaims liability for any damages caused by such use of the Programs.
Oracle is a registered trademark, and ConText, Oracle Store, Oracle7, Oracle8, Oracle8i, Oracle9i,
PL/SQL, Pro*C, and SQL*Plus are trademarks or registered trademarks of Oracle Corporation Other names may be trademarks of their respective owners.
Trang 3Send Us Your Comments xxv
Preface xxvii
Audience xxviii
Organization xxviii
Related Documentation xxviii
Conventions xxix
Documentation Accessibility xxxi
What's New in PL/SQL Packages and Types Reference? xxxiii
Oracle Database 10g Release 1 (10.1) New Features xxxiv
Oracle9i Release 2 (9.2) New Features xl
Oracle9i Release 1 (9.0.1) New Features xlii
Oracle8i Release 2 (8.1.6) New Features xliii
Oracle8i Release 1 (8.1.5) New Features xliii
Trang 5Summary of DBMS_ADVISOR Subprograms 12-20
Trang 621 DBMS_CDC_SUBSCRIBE
Using DBMS_CDC_SUBSCRIBE 21-2
Summary of DBMS_CDC_SUBSCRIBE Subprograms 21-5
22 DBMS_CRYPTO
Using the DBMS_CRYPTO Subprograms 22-2
Summary of DBMS_CRYPTO Subprograms 22-10
Trang 9Summary of DBMS_LOGMNR Subprograms 47-6
Trang 11Summary of DBMS_PROFILER Subprograms 64-8
Trang 13Summary of DBMS_RULE_ADM Subprograms 82-3
Trang 15Summary of DBMS_STREAMS_TABLESPACE_ADM Subprograms 99-5
Trang 17Summary of DBMS_XMLSAVE Subprograms 117-3
Constants of DBMS_XMLSCHEMA 118-2
Summary of DBMS_XMLSCHEMA Subprograms 118-3
Catalog Views of the DBMS_XMLSCHEMA 118-18
Trang 21Summary of UTL_DBWS Subprograms 153-3
Trang 22Using ANYDATA TYPE 168-2
Summary of ANYDATA Subprograms 168-5
Trang 23Summary of ANYDATASET TYPE Subprograms 169-3
170 ANYTYPE TYPE
Summary of ANYTYPE Subprograms 170-2
171 Oracle Streams AQ TYPEs
Summary of Types 171-2
172 Database URI TYPEs
Summary of URITYPE Supertype Subprograms 172-2
Summary of HTTPURITYPE Subtype Subprograms 172-9
Summary of DBURITYPE Subtype Subprogams 172-18
Summary of XDBURITYPE Subtype Subprograms 172-27
Summary of URIFACTORY Package Subprograms 172-36
173 JMS Types
Using JMS Types 173-2
Summary of JMS Types 173-14
174 Logical Change Record TYPEs
Summary of Logical Change Record Types 174-2
Trang 24177 interMedia ORDImage TYPE
Documentation of ORDImage 177-2
178 interMedia ORDImageSignature TYPE
Documentation of ORDImageSignature 178-2
179 interMedia SQL/MM Still Image TYPE
Documentation of SQL/MM Still Image 179-2
180 interMedia ORDVideo TYPE
Trang 25PL/SQL Packages and Types Reference, 10g Release 1 (10.1)
Part No B10802-01
Oracle Corporation welcomes your comments and suggestions on the quality and usefulness of thisdocument Your input is an important part of the information used for revision
■ Did you find any errors?
■ Is the information clearly presented?
■ Do you need more information? If so, where?
■ Are the examples correct? Do you need more examples?
■ What features did you like most?
If you find any errors or have any other suggestions for improvement, please indicate the documenttitle and part number, and the chapter, section, and page number (if available) You can send com-ments to us in the following ways:
■ Electronic mail: infodev_us@oracle.com
■ FAX: (650) 506-7227 Attn: Server Technologies Documentation Manager
■ Postal service:
Trang 27This reference manual describes the Oracle PL/SQL packages shipped with theOracle database server This information applies to versions of the Oracle databaseserver that run on all platforms unless otherwise specified.
This preface contains these topics:
Trang 28PL/SQL Packages and Types Reference is intended for programmers, systems analysts,
project managers, and others interested in developing database applications Thismanual assumes a working knowledge of application programming and familiaritywith SQL to access information in relational database systems Some sections alsoassume a knowledge of basic object-oriented programming
Organization
SeeTable 1–1, " Summary of Oracle Supplied PL/SQL Packages" on page 1-8 forinformation about the organization of this reference
Related Documentation
For more information, see these Oracle resources:
■ Oracle Database Application Developer's Guide - Fundamentals
■ PL/SQL User's Guide and Reference
Many books in the documentation set use the sample schemas of the seed database,
which is installed by default when you install Oracle Refer to Oracle Database
Sample Schemas for information on how these schemas were created and how you
can use them yourself
Printed documentation is available for sale in the Oracle Store at
http://oraclestore.oracle.com/
To download free release notes, installation documentation, white papers, or othercollateral, please visit the Oracle Technology Network (OTN) You must registeronline before using OTN; registration is free and can be done at
http://otn.oracle.com/admin/account/membership.html
If you already have a username and password for OTN, then you can go directly tothe documentation section of the OTN Web site at
http://otn.oracle.com/docs/index.htm
Trang 29documentation set It describes:
Bold Bold typeface indicates terms that are
defined in the text or terms that appear in
a glossary, or both.
When you specify this clause, you create an
index-organized table.
Italics Italic typeface indicates book titles,
emphasis, syntax clauses, or placeholders.
Oracle Database Concepts
Ensure that the recovery catalog and target
database do not reside on the same disk.
You can specify this clause only for a NUMBER
Trang 30Conventions in Code Examples
Code examples illustrate SQL, PL/SQL, SQL*Plus, or other command-linestatements They are displayed in a monospace (fixed-width) font and separatedfrom normal text as shown in this example:
SELECT username FROM dba_users WHERE username = 'MIGRATE';
The following table describes typographic conventions used in code examples andprovides examples of their use
[ ] Brackets enclose one or more optional
items Do not enter the brackets.
DECIMAL (digits [ , precision ])
{ } Braces enclose two or more items, one of
which is required Do not enter the braces.
{ENABLE | DISABLE}
| A vertical bar represents a choice of two
or more options within brackets or braces.
Enter one of the options Do not enter the vertical bar.
{ENABLE | DISABLE}
[COMPRESS | NOCOMPRESS]
Horizontal ellipsis points indicate either:
■ That we have omitted parts of the code that are not directly related to the example
■ That you can repeat a portion of the code
CREATE TABLE AS subquery;
SELECT col1, col2, , coln FROM
SQL> SELECT NAME FROM V$DATAFILE;
NAME - /fsl/dbs/tbs_01.dbf
/fs1/dbs/tbs_02.dbf
/fsl/dbs/tbs_09.dbf
9 rows selected.
Other notation You must enter symbols other than
brackets, braces, vertical bars, and ellipsis points as shown.
acctbal NUMBER(11,2);
acct CONSTANT NUMBER(4) := 3;
Trang 31Documentation Accessibility
Our goal is to make Oracle products, services, and supporting documentationaccessible, with good usability, to the disabled community To that end, ourdocumentation includes features that make information available to users ofassistive technology This documentation is available in HTML format, and containsmarkup to facilitate access by the disabled community Standards will continue toevolve over time, and Oracle is actively engaged with other market-leadingtechnology vendors to address technical obstacles so that our documentation can be
variables for which you must supply particular values.
DB_NAME = database_name
UPPERCASE Uppercase typeface indicates elements
supplied by the system We show these terms in uppercase in order to distinguish them from terms you define Unless terms appear in brackets, enter them in the order and with the spelling shown.
However, because these terms are not case sensitive, you can enter them in lowercase.
SELECT last_name, employee_id FROM employees;
SELECT * FROM USER_TABLES;
DROP TABLE hr.employees;
lowercase Lowercase typeface indicates
programmatic elements that you supply.
For example, lowercase indicates names
of tables, columns, or files.
Note:Some programmatic elements use a mixture of UPPERCASE and lowercase.
Enter these elements as shown.
SELECT last_name, employee_id FROM employees;
sqlplus hr/hr CREATE USER mjones IDENTIFIED BY ty3MU9;
Trang 32Accessibility of Links to External Web Sites in Documentation Thisdocumentation may contain links to Web sites of other companies or organizationsthat Oracle does not own or control Oracle neither evaluates nor makes anyrepresentations regarding the accessibility of these Web sites.
Trang 33■ Oracle9i Release 2 (9.2) New Features
■ Oracle9i Release 1 (9.0.1) New Features
■ Oracle8i Release 2 (8.1.6) New FeaturesOracle8i Release 1 (8.1.5) New Features
Trang 34Oracle Database 10g Release 1 (10.1) New Features
Trang 39■ ANYDATASET TYPE
■ Oracle Streams AQ TYPEs
■ Logical Change Record TYPEs
■ Rule TYPEs
Trang 40Oracle9i Release 2 (9.2) New Features
This release includes the following new chapters:
■ Advanced Queuing Types
Trang 42Oracle9i Release 1 (9.0.1) New Features
This release includes the following new packages:
Trang 43■ UTL_RAW
Oracle8i Release 2 (8.1.6) New Features
This release included the following new packages
Trang 45Introduction
Oracle supplies many PL/SQL packages with the Oracle server to extend databasefunctionality and provide PL/SQL access to SQL features You can use the suppliedpackages when creating your applications or for ideas in creating your own storedprocedures
This chapter contains the following topics:
■ Package Overview
■ Abbreviations for Datetime and Interval Datatypes
■ Summary of Oracle Supplied PL/SQL Packages
Note: This manual covers the packages provided with the Oracle
database server Packages supplied with other products, such as
Oracle Developer or the Oracle Application Server, are not covered
See Also: Oracle Database Application Developer's Guide
Trang 46-Package Overview
Package Overview
A package is an encapsulated collection of related program objects stored together in
the database Program objects are procedures, functions, variables, constants,cursors, and exceptions
Packages have many advantages over standalone procedures and functions Forexample, they:
■ Let you organize your application development more efficiently
■ Let you grant privileges more efficiently
■ Let you modify package objects without recompiling dependent schema objects
■ Enable Oracle to read multiple package objects into memory at once
■ Let you overload procedures or functions Overloading means creating multiple
procedures with the same name in the same package, each taking arguments ofdifferent number or datatype
■ Can contain global variables and cursors that are available to all procedures andfunctions in the package
Package Components
PL/SQL packages have two parts: the specification and the body, althoughsometimes the body is unnecessary The specification is the interface to yourapplication; it declares the types, variables, constants, exceptions, cursors, andsubprograms available for use The body fully defines cursors and subprograms,and so implements the specification
Unlike subprograms, packages cannot be called, parameterized, or nested
However, the formats of a package and a subprogram are similar:
CREATE PACKAGE name AS specification (visible part) public type and item declarations
subprogram specifications END [name];
CREATE PACKAGE BODY name AS body (hidden part) private type and item declarations
subprogram bodies [BEGIN
initialization statements]
Trang 47END [name];
The specification holds public declarations that are visible to your application Thebody holds implementation details and private declarations that are hidden fromyour application You can debug, enhance, or replace a package body withoutchanging the specification You can change a package body without recompilingcalling programs because the implementation details in the body are hidden fromyour application
Using Oracle Supplied Packages
Most Oracle supplied packages are automatically installed when the database iscreated and theCATPROC.SQL script is run For example, to create theDBMS_ALERT
package, theDBMSALRT.SQL andPRVTALRT.PLB scripts must be run whenconnected as the userSYS These scripts are run automatically by theCATPROC.SQL
script
Certain packages are not installed automatically Special installation instructions forthese packages are documented in the individual chapters
To call a PL/SQL function from SQL, you must either own the function or have
EXECUTE privileges on the function To select from a view defined with a PL/SQLfunction, you must haveSELECT privileges on the view No separateEXECUTE
privileges are needed to select from the view Instructions on special requirementsfor packages are documented in the individual chapters
Creating New Packages
To create packages and store them permanently in an Oracle database, use the
CREATE PACKAGE andCREATE PACKAGE BODY statements You can execute thesestatements interactively from SQL*Plus or Enterprise Manager