Sunteți pe pagina 1din 1087

Scribd

Upload a Document
Search Documents
Search Books, Presentations, Business, Academics
Explore

Documents

Books - Fiction
Books - Non-fiction
Health & Medicine
Brochures/Catalogs
Government Docs
How-To Guides/Manuals
Magazines/Newspapers
Recipes/Menus
School Work
+ all categories

Featured
Recent

People

Authors
Students
Researchers
Publishers
Government & Nonprofits
Businesses
Musicians
Artists & Designers
Teachers
+ all categories

Most Followed
Popular

Sign Up
|
Log In
Explore Content

Oracle Application Oracle Parkway


Dangerous Applications Partitioned Indexes Oracle Providers
Oracle9i Application Developer ’s Guide - Large Objects (LOBs), Release 2 (9.2)

Part No. A96591-01

Copyright © 1996, 2002 Oracle Corporation. All rights reserved.

Primary Authors: Eric Paapanen, Shelley Higgins, Susan Kotsovolos, Den Raphaely

Contributing Authors: K. Akiyama, Geeta Arora, S. Banerjee, Yujie Cao, T. H. Chang, E. Chong, S. Das,
C. Freiwald, C. Iyer, M. Jagannath, R. Krishnan, M. Krishnaprasad, S. Lari, Li-Sen Liu, D. Mullen,V.
Nimani, A. Roy, S. Shah, A. Shivarudraiah, J. Srinivasan, R. Toohey, Anh-Tuan Tran, G. Viswana, A.
Yalamanchi

Contributors: J. Balaji, D. Cruceanu, M. Chien, G. Edmiston, M. Fry, J. Kalogeropoulos, V. Karra, P.


Manavazhi, S. Muthulingam, R. Ratnam, C. Shay, A. Shehade, E. Shirk, Jan Syssauw, S. Vedala, E. Wan,
J. Yang

Graphics: Va lerie Moore, Charles Keller

The Programs (which include both the software and documentation) contain proprietary information of
Oracle Corporation; 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 Corporation does not warrant that this
document isnoerror-free.
Programs, Except
part of these as maymay
Programs be expressly permitted
be reproduced in your license
or transmitted in anyagreement forany
form or by these
means,

electronic or mechanical, for any purpose, without the express written permission of Oracle Corporation.
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 Corporation, 500
Oracle Parkway, Redwood City, CA 94065.

The Programs
dangerous are not intended
applications. It shallfor
be use
the in any nuclear,
licensee's aviation, mass
responsibility transit,
to take medical, orfail-safe,
all appropriate other inherently
backup,
redundancy, and other measures to ensure the safe use of such applications if the Programs are used for
such purposes, and Oracle Corporation disclaims liability for any damages caused by such use of the
Programs.

Oracle is a registered trademark, and Gist, Oracle Store, Oracle7, Oracle8, Oracle8i, Oracle9i, PL/ SQL,
Pro*C, Pro*C/ C++, Pro*COBOL, and SQL*Plus are trademarks or registered trademarks of Oracle
Corporation. Other names may be trademarks of their respective owners.
Contents
Send Us Your Comments ............................................................................................................... xxxi

Preface...................................................................................................................................................... xxxiii
Audience ........................................................................................................................................... xxxiv
Organization ..................................................................................................................................... xxxiv
Related Documents......................................................................................................................... xxxvii
Conventions...................................................................................................................................... xxxix

Documentation Accessibility ............................................................................................................. xlii


What’s New with Large Objects (LOBs)? ............................................................................... xlv
LOB Features Introduced with Oracle9i, Release 2 (9.2) ................................................................ xlv
LOB Features Introduced with Oracle9i, Release 1 (9.0.1) ........................................................... xlvii

LOB Features Introduced with Oracle8i Release 2 (8.1.6) ............................................................. xlix


LOB Features Introduced with Oracle8i, Release 8.1.5 ...................................................................... l

1 Introduction to LOBs
Why Use LOBs?................................................................................................................................... 1-2

Unstructured Data ........................................................................................................................ 1-2


LOB Datatype Helps Support Internet Applications .............................................................. 1-3

WhyUsing
Not XML, LOBs, and
Use LONGs? .......................................................................................................................
Oracle Text (interMedia Text)........................................................... 1-4
1-3
LONG-to-LOB Migration API .......................................................................................................... 1-5

SQL Semantics Support for LOBs ................................................................................................... 1-5


Partitioned Index-Organized Tables and LOBs ............................................................................ 1-6

iii
Extensible Indexing on LOBs ........................................................................................................... 1-6
Function-Based Indexing on LOBs .................................................................................................. 1-7

XML Documents Can be Stored in XMLType Columns as CLOBs ........................................... 1-8


Compatibility and Migration Issues ............................................................................................... 1-8

Examples in This Guide .................................................................................................................... 1-9


2 Basic LOB Components

The LOB D atatype .............................................................................................................................. 2-2


Internal LOBs................................................................................................................................. 2-2
External LOBs (BFILEs)................................................................................................................ 2-2
Internal LOBs Use Copy Semantics, External LOBs Use Reference Semantics ................... 2-3
Varying-Width Character Data ......................................................................................................... 2-4
Using DBMS_LOB.LOADFROMFILE and Functions that Access OCI................................ 2-4
LOB Value and Locators .................................................................................................................... 2-5
Inline storage of the LOB value .................................................................................................. 2-5
LOB Locators ................................................................................................................................. 2-5
Setting the LOB Column/ Attribute to Contain a Locator ...................................................... 2-6

Accessing
Creating a that
Tables LOBContain
ThroughLOBs
a Locator.......................................................................................... 2-7
................................................................................................. 2-8
Initializing Internal LOBs to NULL or Empty .......................................................................... 2-8

Initializing LOBs Example Using Table Multimedia_tab ..................................................... 2-10


Initializing Internal LOB Columns to a Value ........................................................................ 2-10

Initializing External LOBs to NULL or a File Name.............................................................. 2-10


3 LOB Support in Different Programmatic Environments

Eight Programmatic Environments Operate on LOBs ................................................................. 3-2


Comparing the LOB Interfaces ......................................................................................................... 3-3

Provide
Using PL/SQLa LOB Locator Before
(D BMS_LOB Invoking
Package) the DBMS_LOB
To Work Routine ....................................... 3-6
With LOBs ......................................................
PL/ SQL - LOB Guidelines........................................................................................................... 3-7

PL/ SQL Functions and Procedures that Operate on LOBs.................................................... 3-8


PL/ SQL Functions/ Procedures To Modify BLOB, CLOB, and NCLOB Values ................ 3-8

PL/ SQL
LOB Functions/
Values Procedures To Read or Examine Internal and External
.................................................................................................................................... 3-9
PL/ SQL Functions/ Procedures To Operate on Temporary LOBs........................................ 3-9

iv

PL/ SQL Read-Only Functions/ Procedures for BFILEs ....................................................... 3-10


PL/ SQL Functions/ Procedures To Open and Close Internal and External LOBs ........... 3-10
Using C (OCI) To Work With LOBs ............................................................................................... 3-10
Set CSID Parameter To OCI_UCS2ID to Read/ Write in UCS2 ........................................... 3-11
Off dA P Fi d Wid h V V i Wid h
Offset and Amount Parameters: Fixed-Width Versus Varying-Width,

Character or Byte ........................................................................................................................ 3-11


OCILobLoadFromFile: Specify Amount Parameter to be Less than Length of BFILE..... 3-13

OCILobRead: Specify Amount Parameter to be 4 gigabytes - 1.......................................... 3-13


OCI LOB Examples..................................................................................................................... 3-13

Further Information About OCI............................................................................................... 3-13


OCI Functions that Operate on BLOBs, BLOBs, NCLOBs, and BFILEs ............................. 3-14

OCI Functions To Modify Internal LOB (BLOB, CLOB, and NCLOB) Values.................. 3-14
OCI Functions To Read or Examine Internal LOB and External LOB (BFILE) Values .... 3-15

OCI Functions For Temporary LOBs....................................................................................... 3-15


OCI Read-Only Functions For BFILEs..................................................................................... 3-15

OCI
Using C++LOB Locator
(OCCI) Functions
To Work With......................................................................................................
LOBs ....................................................................................... 3-22 3-16
OCI LOB-Buffering
Distinct Functions
Classes for Each 3-16
.................................................................................................. 3-23
LOB Type.........................................................................................

Offset and Amount


OCI Functions Parameters:
To Open and Close Fixed-Width
Internal and Versus
External Varying-Width,
LOBs ......................................... 3-16
Character or Byte ........................................................................................................................ 3-24
OCI Example — Is the LOB Open: main() and seeIfLOBIsOpen ........................................ 3-17
Loading from Files with OCCIClob.copy() and OCCIBlob.copy(): Amount Parameter . 3-25
OCCIClob.read(), OCCIBlob.read(), and OCCIBfile.read():Amount Parameter .............. 3-25
Further Information About OCCI ............................................................................................ 3-26

OCCI Methods that Operate on BLOBs, BLOBs, NCLOBs, and BFILEs ............................ 3-26
OCCI Methods To Modify Internal LOB (BLOB, CLOB, and NCLOB) Values ................ 3-26

OCCI Methods To Read or Examine Internal LOB and BFILE Values............................... 3-27
OCCI Read-Only Methods For BFILEs ................................................................................... 3-27

Other
Using C/C++OCCI LOBTo
(Pro*C) Methods
Work w ith LOBs ................................................................................... 3-29
........................................................................................................ 3-27
First Provide
OCCI MethodsanTo
Allocated
Open andInput
Close Locator
Internal Pointer that Represents
and External LOB ............................ 3-29
LOBs ........................................ 3-28
Pro*C/ C++ Statements that Operate on BLOBs, CLOBs, NCLOBs, and BFILEs ............. 3-29
Pro*C/ C++ Embedded SQL Statements To Modify Internal LOB Values ........................ 3-30

Pro*C/ C++ Embedded SQL Statements To Read or Examine Internal and


External LOB Values .................................................................................................................. 3-30
Pro*C/ C++ Embedded SQL Statements For Temporary LOBs........................................... 3-31
Pro*C/ C++ Embedded SQL Statements For BFILEs............................................................. 3-31
Q
Pro*C/ C++ Embedded SQL Statements For LOB Locators ................................................. 3-31

Pro*C/ C++ Embedded SQL Statements For LOB Buffering ............................................... 3-32
Pro*C/
and C++ Embedded
External SQL Statements To Open and Close Internal
LOBs ...................................................................................................................... 3-32

Using COBOL (Pro*COBOL) to Work w ith LOBs ..................................................................... 3-33


First Provide an Allocated Input Locator Pointer that Represents LOB ............................ 3-33
Pro*COBOL Statements that Operate on BLOBs, CLOBs, NCLOBs, and BFILEs ............ 3-33
Pro*COBOL Embedded SQL Statements To Modify Internal LOB Values ....................... 3-34
Pro*COBOL Embedded SQL Statements To Read or Examine Internal
and External LOB Values........................................................................................................... 3-35
Pro*COBOL Embedded SQL Statements For Temporary LOBs.......................................... 3-35
Pro*COBOL Embedded SQL Statements For BFILEs............................................................ 3-35

Pro*COBOL Embedded SQL Statements For LOB Locators ................................................ 3-35


Pro*COBOL Embedded SQL Statements For LOB Buffering .............................................. 3-36

Pro*COBOL Embedded SQL Statements To Open and Close Internal LOBs


and BFILEs ................................................................................................................................... 3-36
Using Visual Basic (Oracle Objects for OLE (OO4O)) to Work w ith LOBs .......................... 3-37
OO4O Syntax Reference ............................................................................................................ 3-37
OraBlob, OraClob, and OraBfile Object Interfaces Encapsulate Locators .......................... 3-38
Example of OraBlob and OraBfile ............................................................................................ 3-38

OO4O Methods and Properties to Access Data Stored in LOBs.......................................... 3-39


OO4O Methods To Modify BLOB, CLOB, and NCLOB Values .......................................... 3-41

OO4O Methods To Read or Examine Internal and External LOB Values.......................... 3-42
OO4O Methods To Open and Close External LOBs (BFILEs) ............................................. 3-42

OO4O Methods For Internal LOB-Buffering .......................................................................... 3-43


OO4O Properties For Operating on LOBs .............................................................................. 3-43

OO4O
Using Java Read-Only
(JD BC) To Methods
Work w ithFor External
LOBs 3-45
3-43
........................................................................................
Lobs (BFILEs) ......................................................
3-45
Changing Internal Persistent LOBs Using Java ......................................................................
OO4O Properties For Operating on External LOBs (BFILEs) .............................................. 3-44
Reading Internal Persistent LOBs and External LOBs (BFILEs) with Java ........................ 3-45
Calling DBMS_LOB Package From Java (JDBC) .................................................................... 3-46

vi

Referencing LOBs Using Java (JDBC)...................................................................................... 3-46


JDBC Syntax References and Further Information ................................................................ 3-46

JDBC Methods for Operating on LOBs ................................................................................... 3-46


JDBC oracle.sql.BLOB Methods To Modify BLOB Values ................................................... 3-48

JDBC oracle.sql.BLOB Methods To Read or Examine BLOB Values .................................. 3-48


JDBC oracle.sql.BLOB Methods and Properties for BLOB-Buffering ................................. 3-49

JDBC l l CLOB M th d T M dif CLOB V l 3 49


JDBC oracle.sql.CLOB Methods To Modify CLOB Values .................................................. 3-49
JDBC oracle.sql.CLOB Methods To Read or Examine CLOB Value ................................... 3-49

JDBC oracle.sql.CLOB Methods and Properties for CLOB-Buffering ................................ 3-50


Higher Releases...........................................................................................................................
JDBC oracle.sql.BFILE Methods To Read or Examine External LOB (BFILE) Values ...... 3-51
3-50
JDBC Temporary LOB APIs ...................................................................................................... 3-51
JDBC oracle.sql.BFILE
JDBC: Opening and Closing Methods LOBs and Properties for BFILE-Buffering ................................
........................................................................................... 3-51
3-52
JDBC: OracleBlob and OracleClob Do Not Work in Oracle8i 8.1.x and
JDBC: Opening and Closing BLOBs ........................................................................................ 3-53

JDBC: Opening and Closing CLOBs ........................................................................................ 3-54


JDBC: Opening and Closing BFILEs ........................................................................................ 3-56

Trimming LOBs using JDBC ..................................................................................................... 3-60


JDBC: New LOB Streaming APIs ............................................................................................. 3-61

New CLOB Streaming APIs ...................................................................................................... 3-62


New BFILE Streaming APIs ...................................................................................................... 3-63
OLEDB (Oracle Provider for OLEDB — OraOLEDB) ............................................................... 3-70
JDBC and Empty LOBs .............................................................................................................. 3-68
4 Managing LOBs

Rules for using Directory Objects and BFILEs ............................................................................. 4-1


DBA Actions Required Prior to Working with LOBs .................................................................. 4-2
Set Maximum Number of Open BFILEs ................................................................................... 4-2
Using SQL DML for Basic Operations on LOBs ...................................................................... 4-2
Changing Tablespace Storage for a LOB................................................................................... 4-3
Managing Temporary LOBs .............................................................................................................. 4-5
Using SQL*Loader to Load LOBs .................................................................................................... 4-5
LOBFILES....................................................................................................................................... 4-5

Inline versus Out-of-Line LOBs ...................................................................................................... 4-6

vii
Application Developer's Guide - LOBs
Download this Document for FreePrintMobileCollectionsReport Document
This is a private document.

Info and Rating

Geert Follow

Share & Embed

Related Documents

PreviousNext

1.
p.
p.

p.

2.
p.

p.

p.

3.
p.

p.
p.

4.
p.

p.

p.

5.
p.

p.

p.

6.
p.
p.

p.

More from this user

PreviousNext

1.
8 p.

162 p.

974 p.

2.
118 p.

964 p.
14 p.

3.
468 p.

900 p.

1524 p.

4.
374 p.

1496 p.

120 p.

5.
874 p.

1004 p.

376 p.

6.
528 p.

2740 p.

1968 p.

7.
1210 p.

532 p.
22 p.

8.
44 p.

156 p.

706 p.

9.
39 p.

Recent Readcasters

Add a Comment
Submit
Characters: 400

Upload a Document
Search Books, Presentations Search Documents

Follow Us!
scribd.com/scribd
twitter.com/scribd
facebook.com/scribd

About
Press
Blog
Partners
Scribd 101
Web Stuff
Scribd Store
Support
FAQ
Developers / API
Jobs
Terms
Copyright
Privacy

Copyright © 2010 Scribd Inc.

The Scribd Archive


This document was uploaded by someone just like you and is now part of The Scribd Archive*. Give back to the
community and gain 24 hours of download access by uploading something of your own.

Subscribe to The Scribd Archive and download as many documents as you'd like.

Monthly Subscription
Most Popular
$9/mo.

1 Day Pass
$5

1 Year Pass
$59
Choose payment option
Pay with Credit Card
Pay with PayPal or Credit
* The Scribd Archive is a collection of millions of documents, including research reports, best-selling books, news
source materials, and more. Read the Scribd Archive FAQ for more information.

S-ar putea să vă placă și