没有合适的资源?快使用搜索试试~ 我知道了~
首页OCI程序员指南:理解INTEGER类型与数据转换
OCI程序员指南:理解INTEGER类型与数据转换
需积分: 10 4 下载量 167 浏览量
更新于2024-07-23
收藏 15.09MB PDF 举报
Oracle Call Interface (OCI) 是Oracle数据库提供的一个重要编程接口,专为开发人员设计,以便在Java、C++等高级语言环境中与Oracle Database进行交互。《Oracle® Call Interface Programmer's Guide》是针对Oracle 11g Release 2(11.2)的一个详细指南,版权归属Oracle及其关联公司,由Rod Ward、Jack Melnick等主要作者以及多位贡献者共同编撰。
本书的核心内容围绕如何利用OCI进行高效、安全的数据操作展开。其中,INTEGER数据类型是关键知识点。INTEGER是一种用于存储数值的内置数据类型,它将数字转换成二进制形式,但其大小是系统依赖的,这意味着不同平台上的INTEGER可能占用不同数量的字节。在存储时,主机系统的架构决定了字节的顺序,这可能是大端模式或小端模式。
对于输入和输出,oci程序员需要指定长度规格,确保数据的一致性。当从Oracle Database检索到的数值不是整数时,Oracle会截断小数部分,并且不会返回错误或任何提示,因为这是预期的行为。然而,如果返回的数值超出了所用计算机系统的signed integer类型的容量范围,oci程序将会遇到“转换溢出”错误,开发者需要处理这种边界情况以避免程序崩溃。
此外,书中的其他章节可能会探讨如何使用oci的异常处理机制来捕获和处理这类转换错误,以及如何优化性能,如使用缓冲区减少网络传输和提高数据读写效率。此外,还可能包含示例代码、API函数文档以及对oci数据类型、连接管理、游标操作、SQL执行、结果集处理等的深入讲解。
值得注意的是,使用OCI编程时,必须遵循严格的许可证协议,限制了使用和披露的规定,并受到知识产权法律的保护。未经授权,用户不能随意使用或分享这份软件及相关文档。
《Oracle Call Interface Programmer's Guide》是一本实用的参考文献,对于希望通过OCI与Oracle Database集成的开发人员来说,提供了宝贵的技术指导和实践案例,帮助他们编写出健壮、高效的数据库应用程序。
xvi
NULL Indicator Structure............................................................................................................ 11-21
Creating Objects ............................................................................................................................ 11-23
Attribute Values of New Objects......................................................................................... 11-24
Freeing and Copying Objects ...................................................................................................... 11-25
Object Reference and Type Reference........................................................................................ 11-25
Create Objects Based on Object Views and Object Tables with Primary-Key-Based OIDs 11-25
Error Handling in Object Applications...................................................................................... 11-26
Type Inheritance.................................................................................................................................. 11-27
Substitutability............................................................................................................................... 11-27
NOT INSTANTIABLE Types and Methods.............................................................................. 11-28
OCI Support for Type Inheritance.............................................................................................. 11-28
OCIDescribeAny() ................................................................................................................. 11-29
Bind and Define Functions................................................................................................... 11-29
OCIObjectGetTypeRef()........................................................................................................ 11-29
OCIObjectCopy().................................................................................................................... 11-29
OCICollAssignElem()............................................................................................................ 11-29
OCICollAppend()................................................................................................................... 11-29
OCICollGetElem().................................................................................................................. 11-30
OTT Support for Type Inheritance............................................................................................. 11-30
Type Evolution..................................................................................................................................... 11-30
12 Object-Relational Data Types in OCI
Overview of OCI Functions for Objects........................................................................................... 12-1
Mapping Oracle Data Types to C....................................................................................................... 12-2
OCI Type Mapping Methodology................................................................................................ 12-3
Manipulating C Data Types with OCI.............................................................................................. 12-3
Precision of Oracle Number Operations...................................................................................... 12-4
Date (OCIDate) ...................................................................................................................................... 12-5
Date Example................................................................................................................................... 12-5
Datetime and Interval (OCIDateTime, OCIInterval)..................................................................... 12-6
Datetime Functions......................................................................................................................... 12-7
Datetime Example........................................................................................................................... 12-8
Interval Functions ........................................................................................................................... 12-8
Number (OCINumber)......................................................................................................................... 12-9
OCINumber Examples ................................................................................................................. 12-10
Fixed or Variable-Length String (OCIString)................................................................................ 12-12
String Functions............................................................................................................................. 12-12
String Example .............................................................................................................................. 12-12
Raw (OCIRaw) ..................................................................................................................................... 12-13
Raw Functions ............................................................................................................................... 12-13
Raw Example ................................................................................................................................. 12-13
Collections (OCITable, OCIArray, OCIColl, OCIIter) ................................................................ 12-14
Generic Collection Functions....................................................................................................... 12-14
Collection Data Manipulation Functions................................................................................... 12-14
Collection Scanning Functions.................................................................................................... 12-15
Varray/Collection Iterator Example .......................................................................................... 12-15
Nested Table Manipulation Functions....................................................................................... 12-16
xvii
Nested Table Element Ordering.......................................................................................... 12-17
Nested Table Locators .................................................................................................................. 12-17
Multilevel Collection Types.............................................................................................................. 12-17
Multilevel Collection Type Example.......................................................................................... 12-18
REF (OCIRef) ....................................................................................................................................... 12-18
REF Manipulation Functions....................................................................................................... 12-19
REF Example.................................................................................................................................. 12-19
Object Type Information Storage and Access ............................................................................... 12-20
Descriptor Objects......................................................................................................................... 12-20
AnyType, AnyData, and AnyDataSet Interfaces .......................................................................... 12-20
Type Interfaces .............................................................................................................................. 12-21
Creating a Parameter Descriptor for OCIType Calls........................................................ 12-21
Obtaining the OCIType for Persistent Types .................................................................... 12-22
Type Access Calls................................................................................................................... 12-23
Extensions to OCIDescribeAny()......................................................................................... 12-23
OCIAnyData Interfaces................................................................................................................ 12-23
NCHAR Typecodes for OCIAnyData Functions ..................................................................... 12-24
OCIAnyDataSet Interfaces........................................................................................................... 12-24
Binding Named Data Types.............................................................................................................. 12-25
Named Data Type Binds.............................................................................................................. 12-25
Binding REFs................................................................................................................................. 12-25
Information for Named Data Type and REF Binds ................................................................. 12-26
Information Regarding Array Binds .......................................................................................... 12-26
Defining Named Data Types ............................................................................................................ 12-26
Defining Named Data Type Output Variables......................................................................... 12-26
Defining REF Output Variables .................................................................................................. 12-27
Information for Named Data Type and REF Defines, and PL/SQL OUT Binds................. 12-27
Information About Array Defines....................................................................................... 12-28
Binding and Defining Oracle C Data Types.................................................................................. 12-28
Bind and Define Examples........................................................................................................... 12-29
Salary Update Examples .............................................................................................................. 12-31
Method 1 - Fetch, Convert, Assign...................................................................................... 12-32
Method 2 - Fetch and Assign................................................................................................ 12-32
Method 3 - Direct Fetch......................................................................................................... 12-32
Summary and Notes.............................................................................................................. 12-33
SQLT_NTY Bind and Define Examples ......................................................................................... 12-33
SQLT_NTY Bind Example ...........................................................................................................
12-33
SQLT_NTY Define Example........................................................................................................ 12-34
13 Direct Path Loading
Direct Path Loading Overview ........................................................................................................... 13-1
Data Types Supported for Direct Path Loading......................................................................... 13-3
Direct Path Handles........................................................................................................................ 13-4
Direct Path Context.................................................................................................................. 13-4
OCI Direct Path Function Context......................................................................................... 13-4
Direct Path Column Array and Direct Path Function Column Array ............................. 13-5
Direct Path Stream ................................................................................................................... 13-6
xviii
Direct Path Interface Functions..................................................................................................... 13-6
Limitations and Restrictions of the Direct Path Load Interface ............................................... 13-7
Direct Path Load Examples for Scalar Columns......................................................................... 13-7
Data Structures Used in Direct Path Loading Example ..................................................... 13-7
Outline of an Example of a Direct Path Load for Scalar Columns ................................... 13-9
Using a Date Cache in Direct Path Loading of Dates in OCI ................................................. 13-13
OCI_ATTR_DIRPATH_DCACHE_SIZE............................................................................ 13-13
OCI_ATTR_DIRPATH_DCACHE_NUM .......................................................................... 13-13
OCI_ATTR_DIRPATH_DCACHE_MISSES....................................................................... 13-13
OCI_ATTR_DIRPATH_DCACHE_HITS ........................................................................... 13-14
OCI_ATTR_DIRPATH_DCACHE_DISABLE ................................................................... 13-14
Direct Path Loading of Object Types .............................................................................................. 13-14
Direct Path Loading of Nested Tables ....................................................................................... 13-14
Describing a Nested Table Column and Its Nested Table............................................... 13-15
Direct Path Loading of Column Objects.................................................................................... 13-15
Describing a Column Object................................................................................................. 13-15
Allocating the Array Column for the Column Object...................................................... 13-17
Loading Column Object Data into the Column Array..................................................... 13-17
OCI_DIRPATH_COL_ERROR............................................................................................. 13-18
Direct Path Loading of SQL String Columns............................................................................ 13-18
Describing a SQL String Column ........................................................................................ 13-18
Allocating the Column Array for SQL String Columns................................................... 13-20
Loading the SQL String Data into the Column Array...................................................... 13-20
Direct Path Loading of REF Columns........................................................................................ 13-21
Describing the REF Column................................................................................................. 13-21
Allocating the Column Array for a REF Column.............................................................. 13-23
Loading the REF Data into the Column Array.................................................................. 13-23
Direct Path Loading of NOT FINAL Object and REF Columns............................................. 13-24
Inheritance Hierarchy............................................................................................................ 13-24
Describing a Fixed, Derived Type to Be Loaded............................................................... 13-25
Allocating the Column Array............................................................................................... 13-25
Loading the Data into the Column Array .......................................................................... 13-25
Direct Path Loading of Object Tables......................................................................................... 13-25
Direct Path Loading a NOT FINAL Object Table..................................................................... 13-26
Direct Path Loading in Pieces ........................................................................................................... 13-27
Loading Object Types in Pieces................................................................................................... 13-27
Direct Path Context Handles and Attributes for Object Types.................................................. 13-28
Direct Path Context Attributes.................................................................................................... 13-28
OCI_ATTR_DIRPATH_OBJ_CONSTR............................................................................... 13-28
Direct Path Function Context and Attributes ........................................................................... 13-28
OCI_ATTR_DIRPATH_OBJ_CONSTR...............................................................................
13-28
OCI_ATTR_NAME................................................................................................................ 13-29
OCI_ATTR_DIRPATH_EXPR_TYPE.................................................................................. 13-30
OCI_ATTR_DIRPATH_NO_INDEX_ERRORS................................................................. 13-30
OCI_ATTR_NUM_COLS...................................................................................................... 13-30
OCI_ATTR_NUM_ROWS .................................................................................................... 13-31
Direct Path Column Parameter Attributes................................................................................ 13-32
xix
OCI_ATTR_NAME................................................................................................................ 13-32
OCI_ATTR_DIRPATH_SID ................................................................................................. 13-34
OCI_ATTR_DIRPATH_OID ................................................................................................ 13-34
Direct Path Function Column Array Handle for Nonscalar Columns.................................. 13-34
OCI_ATTR_NUM_ROWS Attribute................................................................................... 13-34
14 Object Advanced Topics in OCI
Object Cache and Memory Management ......................................................................................... 14-1
Cache Consistency and Coherency............................................................................................... 14-3
Object Cache Parameters................................................................................................................ 14-4
Object Cache Operations................................................................................................................ 14-4
Pinning and Unpinning .......................................................................................................... 14-4
Freeing ....................................................................................................................................... 14-4
Marking and Unmarking........................................................................................................ 14-5
Flushing..................................................................................................................................... 14-5
Refreshing ................................................................................................................................. 14-5
Loading and Removing Object Copies ........................................................................................ 14-5
Pinning an Object Copy .......................................................................................................... 14-5
Unpinning an Object Copy..................................................................................................... 14-7
Freeing an Object Copy........................................................................................................... 14-7
Making Changes to Object Copies................................................................................................ 14-7
Marking an Object Copy......................................................................................................... 14-7
Unmarking an Object Copy.................................................................................................... 14-8
Synchronizing Object Copies with the Server ............................................................................ 14-8
Flushing Changes to the Server ............................................................................................. 14-8
Refreshing an Object Copy..................................................................................................... 14-9
Object Locking............................................................................................................................... 14-10
Lock Options........................................................................................................................... 14-10
Locking Objects for Update.................................................................................................. 14-10
Locking with the NOWAIT Option..................................................................................... 14-10
Implementing Optimistic Locking ...................................................................................... 14-11
Commit and Rollback in Object Applications .......................................................................... 14-11
Object Duration ............................................................................................................................. 14-11
Durations Example ................................................................................................................ 14-12
Memory Layout of an Instance ................................................................................................... 14-13
Object Navigation ............................................................................................................................... 14-14
Simple Object Navigation ............................................................................................................ 14-14
OCI Navigational Functions ............................................................................................................. 14-15
Pin/Unpin/Free Functions.......................................................................................................... 14-15
Flush and Refresh Functions ....................................................................................................... 14-16
Mark and Unmark Functions ...................................................................................................... 14-16
Object Meta-Attribute Accessor Functions................................................................................ 14-16
Other Functions.............................................................................................................................
14-16
Type Evolution and the Object Cache............................................................................................. 14-17
OCI Support for XML......................................................................................................................... 14-17
XML Context.................................................................................................................................. 14-18
XML Data on the Server............................................................................................................... 14-18
xx
Using OCI XML DB Functions.................................................................................................... 14-18
OCI Client Access to Binary XML............................................................................................... 14-19
Accessing XML Data from an OCI Application ................................................................ 14-20
Repository Context ................................................................................................................ 14-20
Create Repository Context from a Dedicated OCI Connection ...................................... 14-20
Create Repository Context from a Connection Pool......................................................... 14-21
Associating Repository Context with a Data Connection................................................ 14-21
Setting XMLType Encoding Format Preference................................................................ 14-21
Example of Using a Connection Pool.................................................................................. 14-21
15 Using the Object Type Translator with OCI
OTT Overview ....................................................................................................................................... 15-1
What Is the Object Type Translator?................................................................................................. 15-2
Creating Types in the Database .................................................................................................... 15-3
Invoking OTT .................................................................................................................................. 15-4
Command Line......................................................................................................................... 15-4
Configuration File.................................................................................................................... 15-4
INTYPE File .............................................................................................................................. 15-4
OTT Command Line............................................................................................................................. 15-4
OTT Command-Line Invocation Example .................................................................................. 15-5
OTT ............................................................................................................................................ 15-5
USERID...................................................................................................................................... 15-5
INTYPE...................................................................................................................................... 15-5
OUTTYPE.................................................................................................................................. 15-5
CODE......................................................................................................................................... 15-5
HFILE......................................................................................................................................... 15-6
INITFILE.................................................................................................................................... 15-6
Intype File............................................................................................................................................... 15-6
OTT Data Type Mappings................................................................................................................... 15-8
Mapping Object Data Types to C.................................................................................................. 15-8
OTT Type Mapping Example...................................................................................................... 15-10
Null Indicator Structs ................................................................................................................... 15-12
OTT Support for Type Inheritance............................................................................................. 15-13
Substitutable Object Attributes............................................................................................ 15-15
Outtype File.......................................................................................................................................... 15-15
Using OTT with OCI Applications.................................................................................................. 15-16
Accessing and Manipulating Objects with OCI ....................................................................... 15-17
Calling the Initialization Function.............................................................................................. 15-18
Tasks of the Initialization Function ............................................................................................ 15-19
OTT Reference ..................................................................................................................................... 15-19
OTT Command-Line Syntax........................................................................................................ 15-20
OTT Parameters............................................................................................................................. 15-21
USERID.................................................................................................................................... 15-21
INTYPE.................................................................................................................................... 15-22
OUTTYPE................................................................................................................................ 15-22
CODE....................................................................................................................................... 15-22
INITFILE.................................................................................................................................. 15-22
剩余1369页未读,继续阅读
2017-03-29 上传
2009-04-08 上传
点击了解资源详情
点击了解资源详情
点击了解资源详情
点击了解资源详情
2007-05-15 上传
2009-06-10 上传
2009-12-14 上传
flyingsnowshade
- 粉丝: 0
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 前端协作项目:发布猜图游戏功能与待修复事项
- Spring框架REST服务开发实践指南
- ALU课设实现基础与高级运算功能
- 深入了解STK:C++音频信号处理综合工具套件
- 华中科技大学电信学院软件无线电实验资料汇总
- CGSN数据解析与集成验证工具集:Python和Shell脚本
- Java实现的远程视频会议系统开发教程
- Change-OEM: 用Java修改Windows OEM信息与Logo
- cmnd:文本到远程API的桥接平台开发
- 解决BIOS刷写错误28:PRR.exe的应用与效果
- 深度学习对抗攻击库:adversarial_robustness_toolbox 1.10.0
- Win7系统CP2102驱动下载与安装指南
- 深入理解Java中的函数式编程技巧
- GY-906 MLX90614ESF传感器模块温度采集应用资料
- Adversarial Robustness Toolbox 1.15.1 工具包安装教程
- GNU Radio的供应商中立SDR开发包:gr-sdr介绍
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功