Oracle® Data Provider for .NET
Developer’s Guide
Release 9.2.0.4
Part No. B10961-01
October 2003
Oracle Data Provider for .NET Developer’s Guide, Release 9.2.0.4
Part No. B10961-01
Copyright © 2002, 2003 Oracle Corporation. All rights reserved.
Primary Author: Janis Greenberg
Contributing Authors: Riaz Ahmed, Kiminari Akiyama, Steven Caminez, Naveen Doraiswamy, Neeraj
Gupta, Sinclair Hsu, Alex Keh, Arnold Poon, Chithra Ramamurthy, Ashish Shah, Martha Woo
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 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 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 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 Corporation disclaims liability for any damages caused by such use of the
Programs.
Oracle is a registered trademark, and Oracle9i, Oracle8i, Oracle8, Oracle Store, SQL*Plus, and PL/SQL
are trademarks or registered trademarks of Oracle Corporation. Other names may be trademarks of their
respective owners.
iii
Contents
Send Us Your Comments .................................................................................................................... v
Preface........................................................................................................................................................... vii
Audience ................................................................................................................................................ viii
Organization.......................................................................................................................................... viii
Related Documentation ........................................................................................................................ ix
Conventions............................................................................................................................................. x
Documentation Accessibility .............................................................................................................. xv
What’s New in Oracle Data Provider for .NET?.................................................................. xvii
New Features in Oracle Data Provider for .NET Release 9.2.0.4................................................. xviii
Volume 1
1 Introducing Oracle Data Provider for .NET
Overview of Oracle Data Provider for .NET (ODP.NET)............................................................ 1-2
ODP.NET Assembly ........................................................................................................................... 1-2
Oracle.DataAccess.Client Classes and Enumerations............................................................. 1-2
Oracle.DataAccess.Types Classes and Structures.................................................................... 1-5
Using ODP.NET in a Simple Application...................................................................................... 1-8
iv
2 Installing and Configuring
System Requirements ........................................................................................................................ 2-2
Installing Oracle Data Provider for .NET ...................................................................................... 2-3
File Locations ....................................................................................................................................... 2-3
3 Features of Oracle Data Provider for .NET
Connecting to the Oracle Database Server .................................................................................... 3-2
Connection String Attributes ..................................................................................................... 3-2
Connection Pooling ..................................................................................................................... 3-3
Operating System Authentication.............................................................................................. 3-5
Privileged Connections................................................................................................................ 3-5
Password Expiration .................................................................................................................... 3-6
Proxy Authentication ................................................................................................................... 3-7
Transparent Application Failover (TAF) Callback Support................................................... 3-7
ODP.NET Types Overview................................................................................................................ 3-9
Obtaining Data From an OracleDataReader ............................................................................... 3-11
Typed OracleDataReader Accessors........................................................................................ 3-11
.NET Type Accessors .......................................................................................................... 3-11
ODP.NET Type Accessors.................................................................................................. 3-13
Obtaining LONG and LONG RAW Data................................................................................ 3-14
Obtaining LOB Data................................................................................................................... 3-15
Controlling the Number of Rows Fetched in One Server Round-Trip............................... 3-16
Use of FetchSize .................................................................................................................. 3-16
Fine-Tuning FetchSize ........................................................................................................ 3-17
Using the RowSize Property.............................................................................................. 3-17
Setting FetchSize Value at Design Time........................................................................... 3-17
Setting FetchSize Value at Runtime.................................................................................. 3-18
OracleCommand Object .................................................................................................................. 3-18
Transaction .................................................................................................................................. 3-18
Parameter Binding...................................................................................................................... 3-18
OracleDbType Enumeration Type.................................................................................... 3-19
Inference of DbType, OracleDbType, and .NET Types ................................................. 3-21
PL/SQL Associative Array ................................................................................................ 3-25
Array Binding ...................................................................................................................... 3-28
v
PL/SQL REF CURSOR and OracleRefCursor ............................................................................. 3-31
Obtaining an OracleRefCursor................................................................................................. 3-31
Obtaining a REF CURSOR ........................................................................................................ 3-31
Populating an OracleDataReader from a REF CURSOR ...................................................... 3-32
Populating the DataSet From a REF CURSOR....................................................................... 3-32
Populating an OracleRefCursor From a REF CURSOR........................................................ 3-32
Updating a DataSet Obtained From a REF CURSOR ........................................................... 3-33
Behavior of ExecuteScalar Method for REF CURSOR .......................................................... 3-33
LOB Support...................................................................................................................................... 3-33
Updating LOBs Using a DataSet .............................................................................................. 3-35
Updating LOBs Using OracleCommand and OracleParameter.......................................... 3-36
Updating LOBs Using ODP.NET LOB Objects...................................................................... 3-36
Temporary LOBs ........................................................................................................................ 3-37
Globalization Support..................................................................................................................... 3-37
Globalization Settings................................................................................................................ 3-37
Client Globalization Settings ............................................................................................. 3-38
Session Globalization Settings........................................................................................... 3-38
Thread-Based Globalization Settings ............................................................................... 3-39
Globalization-Sensitive Operations ......................................................................................... 3-40
Operations Dependent on Client Computer's Globalization Settings......................... 3-40
Operations Dependent on Thread Globalization Settings ............................................ 3-40
Operations Sensitive to Session Globalization Parameters........................................... 3-40
Guaranteeing Uniqueness in Updating DataSet to Database ................................................. 3-41
What Constitutes Uniqueness in DataRows?......................................................................... 3-42
Configuring PrimaryKey and Constraints Properties .......................................................... 3-42
Updating Without PrimaryKey and Constraints Configuration......................................... 3-44
OracleDataAdapter Safe Type Mapping...................................................................................... 3-44
Potential Data Loss..................................................................................................................... 3-45
SafeMapping Property............................................................................................................... 3-46
Using Safe Type Mapping.................................................................................................. 3-46
OracleDataAdapter Requery Property ......................................................................................... 3-47
Debug Tracing ................................................................................................................................... 3-48
Registry Settings for Tracing Calls........................................................................................... 3-48
TraceFileName..................................................................................................................... 3-48
TraceLevel ............................................................................................................................ 3-49
评论1