没有合适的资源?快使用搜索试试~ 我知道了~
首页Oracle 10.2 Pro*C/C++编程指南:详尽教程
Oracle 10.2 Pro*C/C++编程指南:详尽教程
4星 · 超过85%的资源 需积分: 9 10 下载量 31 浏览量
更新于2024-07-26
收藏 21.55MB PDF 举报
"《Pro*C/C++ for Oracle 10.2程序员指南》(B14407-01,2005年6月发布)是一本详细的文档,专为Oracle 10.2版本的开发人员设计。该书由Syed Mujeeb Ahmed、Jack Melnick、Neelam Singh和Tim Smith等主要作者编写,同时还有Ruth Baylis、Paul Lane等贡献作者参与,以及多位技术专家如Bill Bailey、Subhranshu Banerjee等人共同撰稿。本书的核心内容涵盖了Pro*C和Pro*C++这两种用于Oracle数据库的高级编程语言,它是在10g Release 2(10.2)的背景下编写的。
Pro*C和Pro*C++是Oracle数据库的编译器接口,允许开发人员使用标准的C和C++语法编写存储过程和函数,这些程序可以直接在数据库内部执行,从而提高了性能和效率。这些工具特别适合那些希望将数据库操作与应用程序逻辑紧密集成的开发者,它们提供了访问数据库数据、处理事务、执行复杂的SQL语句等功能。
文档详细介绍了如何使用Pro*C/C++进行数据定义、输入/输出、异常处理、参数传递、结果集管理和错误处理等内容。此外,书中还涵盖了许多实用技巧和最佳实践,以及针对10.2版本特定优化的方法。值得注意的是,由于包含Oracle的专有信息,所有程序和文档都受版权保护,并且根据许可证协议,用户在使用时必须遵守严格的限制,例如禁止反向工程、拆解或逆向编译,除非法律另有规定或者为了实现与其他独立软件的互操作性。
阅读这本书对于理解Oracle数据库环境下的C/C++编程至关重要,它不仅提供了技术细节,也包含了法律注意事项,确保开发人员在开发过程中既高效又合规。对于任何正在进行Oracle 10.2项目或者希望提升数据库编程技能的开发者来说,这是一本非常有价值的参考资料。"
xvi
12 C++ Applications
Understanding C++ Support............................................................................................................... 12-1
No Special Macro Processing ........................................................................................................ 12-2
Precompiling for C++ ........................................................................................................................... 12-2
Code Generation.............................................................................................................................. 12-2
Parsing Code.................................................................................................................................... 12-3
Output Filename Extension........................................................................................................... 12-4
System Header Files ....................................................................................................................... 12-4
Example Programs................................................................................................................................. 12-4
cppdemo1.pc.................................................................................................................................... 12-4
cppdemo2.pc.................................................................................................................................... 12-7
cppdemo3.pc ............................................................................................................................... 12-10
13 Oracle Dynamic SQL
What is Dynamic SQL? ........................................................................................................................ 13-1
Advantages and Disadvantages of Dynamic SQL.......................................................................... 13-2
When to Use Dynamic SQL................................................................................................................. 13-2
Requirements for Dynamic SQL Statements .................................................................................. 13-2
How Dynamic SQL Statements are Processed ............................................................................... 13-3
Methods for Using Dynamic SQL ..................................................................................................... 13-3
Method 1 .......................................................................................................................................... 13-4
Method 2 .......................................................................................................................................... 13-4
Method 3 .......................................................................................................................................... 13-4
Method 4 .......................................................................................................................................... 13-4
Guidelines ....................................................................................................................................... 13-4
Avoiding Common Errors ..................................................................................................... 13-5
Using Method 1 ..................................................................................................................................... 13-6
Example Program: Dynamic SQL Method 1............................................................................... 13-7
Using Method 2 ..................................................................................................................................... 13-9
The USING Clause ....................................................................................................................... 13-10
Example Program: Dynamic SQL Method 2............................................................................. 13-11
Using Method 3 ................................................................................................................................... 13-14
PREPARE ....................................................................................................................................... 13-14
DECLARE ...................................................................................................................................... 13-15
OPEN ............................................................................................................................................. 13-15
FETCH ........................................................................................................................................... 13-15
CLOSE ............................................................................................................................................ 13-16
Example Program: Dynamic SQL Method 3............................................................................. 13-16
Using Method 4 ................................................................................................................................... 13-19
Need for the SQLDA ................................................................................................................... 13-19
The DESCRIBE Statement ........................................................................................................... 13-20
What is a SQLDA? ........................................................................................................................ 13-20
Implementing Oracle Method 4 ................................................................................................. 13-21
Restriction....................................................................................................................................... 13-21
Using the DECLARE STATEMENT Statement ............................................................................ 13-21
Using Host Arrays ....................................................................................................................... 13-22
Using PL/SQL ...................................................................................................................................... 13-22
xvii
With Method 1 .............................................................................................................................. 13-23
With Method 2 .............................................................................................................................. 13-23
With Method 3 .............................................................................................................................. 13-23
With Oracle Method 4 ................................................................................................................. 13-23
14 ANSI Dynamic SQL
Basics of ANSI Dynamic SQL ............................................................................................................ 14-1
Precompiler Options....................................................................................................................... 14-2
Overview of ANSI SQL Statements .................................................................................................. 14-2
Example Code.................................................................................................................................. 14-5
Oracle Extensions .................................................................................................................................. 14-5
Reference Semantics........................................................................................................................ 14-6
Using Arrays for Bulk Operations................................................................................................ 14-6
Support for Arrays of Structs ........................................................................................................ 14-8
Support for Object Types ............................................................................................................... 14-8
ANSI Dynamic SQL Precompiler Options ...................................................................................... 14-8
Full Syntax of the Dynamic SQL Statements .................................................................................. 14-9
ALLOCATE DESCRIPTOR.......................................................................................................... 14-10
DEALLOCATE DESCRIPTOR.................................................................................................... 14-10
GET DESCRIPTOR........................................................................................................................ 14-11
SET DESCRIPTOR ........................................................................................................................ 14-14
Use of PREPARE ........................................................................................................................... 14-17
DESCRIBE INPUT......................................................................................................................... 14-17
DESCRIBE OUTPUT..................................................................................................................... 14-18
EXECUTE ....................................................................................................................................... 14-18
Use of EXECUTE IMMEDIATE .................................................................................................. 14-19
Use of DYNAMIC DECLARE CURSOR.................................................................................... 14-19
OPEN Cursor................................................................................................................................. 14-20
FETCH ............................................................................................................................................ 14-20
CLOSE a Dynamic Cursor ........................................................................................................... 14-21
Differences From Oracle Dynamic Method 4 ........................................................................... 14-21
Restrictions..................................................................................................................................... 14-22
Example Programs............................................................................................................................... 14-22
ansidyn1.pc .................................................................................................................................... 14-22
ansidyn2.pc .................................................................................................................................... 14-29
15 Oracle Dynamic SQL: Method 4
Meeting the Special Requirements of Method 4 ........................................................................... 15-1
What Makes Method 4 Special? ................................................................................................... 15-2
What Information Does Oracle Need? ........................................................................................ 15-2
Where Is the Information Stored? ................................................................................................ 15-2
How is the SQLDA Referenced? .................................................................................................. 15-3
How is the Information Obtained? .............................................................................................. 15-3
Understanding the SQLDA ................................................................................................................ 15-3
Purpose of the SQLDA .................................................................................................................. 15-3
Multiple SQLDAs ........................................................................................................................... 15-4
xviii
Declaring a SQLDA ........................................................................................................................ 15-4
Allocating a SQLDA ...................................................................................................................... 15-4
Using the SQLDA Variables .............................................................................................................. 15-5
The N Variable ................................................................................................................................ 15-5
The V Variable ................................................................................................................................ 15-6
The L Variable ................................................................................................................................. 15-6
The T Variable ................................................................................................................................. 15-7
The I Variable .................................................................................................................................. 15-7
The F Variable ................................................................................................................................. 15-8
The S Variable ................................................................................................................................. 15-8
The M Variable ............................................................................................................................... 15-8
The C Variable ................................................................................................................................ 15-8
The X Variable ................................................................................................................................ 15-8
The Y Variable ................................................................................................................................ 15-9
The Z Variable ................................................................................................................................ 15-9
Some Preliminaries .............................................................................................................................. 15-9
Converting Data ............................................................................................................................. 15-9
Internal Datatypes ................................................................................................................... 15-9
External Datatypes ................................................................................................................ 15-10
Coercing Datatypes ...................................................................................................................... 15-11
Extracting Precision and Scale ............................................................................................ 15-12
Handling NULL/Not NULL Datatypes ................................................................................... 15-13
The Basic Steps ................................................................................................................................... 15-14
A Closer Look at Each Step .............................................................................................................. 15-15
Declare a Host String ................................................................................................................... 15-16
Declare the SQLDAs .................................................................................................................... 15-16
Allocate Storage Space for the Descriptors ............................................................................... 15-17
Set the Maximum Number to DESCRIBE ................................................................................ 15-17
Put the Query Text in the Host String ....................................................................................... 15-19
PREPARE the Query from the Host String .............................................................................. 15-19
DECLARE a Cursor ..................................................................................................................... 15-20
DESCRIBE the Bind Variables .................................................................................................... 15-20
Reset Number of Placeholders ................................................................................................... 15-21
Get Values and Allocate Storage for Bind Variables ............................................................... 15-21
OPEN the Cursor .......................................................................................................................... 15-23
DESCRIBE the Select List ............................................................................................................ 15-24
Reset Number of Select-List Items ............................................................................................. 15-25
Reset Length/Datatype of Each Select-list Item ...................................................................... 15-25
FETCH Rows from the Active Set ............................................................................................. 15-27
Get and Process Select-List Values ............................................................................................ 15-28
Deallocate Storage ........................................................................................................................ 15-29
CLOSE the Cursor ........................................................................................................................ 15-30
Using Host Arrays ....................................................................................................................... 15-30
sample12.pc.................................................................................................................................... 15-32
Example Program: Dynamic SQL Method 4 ................................................................................. 15-32
Sample Program : Dynamic SQL Method 4 using Scrollable Cursors ..................................... 15-43
xix
16 LOBs
What are LOBs?...................................................................................................................................... 16-1
Internal LOBs................................................................................................................................... 16-1
External LOBs.................................................................................................................................. 16-2
Security for BFILEs ......................................................................................................................... 16-2
LOBs versus LONG and LONG RAW......................................................................................... 16-2
LOB Locators ................................................................................................................................... 16-2
Temporary LOBs............................................................................................................................. 16-3
LOB Buffering Subsystem.............................................................................................................. 16-3
How to Use LOBs in Your Program ................................................................................................... 16-3
Three Ways to Access LOBs .......................................................................................................... 16-4
LOB Locators in Your Application ............................................................................................... 16-5
Initializing a LOB ............................................................................................................................ 16-6
Internal LOBs............................................................................................................................ 16-6
External LOBs........................................................................................................................... 16-6
Temporary LOBs...................................................................................................................... 16-7
Freeing LOBs ............................................................................................................................ 16-7
Rules for LOB Statements ................................................................................................................... 16-7
For All LOB Statements.................................................................................................................. 16-7
For the LOB Buffering Subsystem ................................................................................................ 16-7
For Host Variables........................................................................................................................... 16-8
LOB Statements ..................................................................................................................................... 16-9
APPEND........................................................................................................................................... 16-9
ASSIGN............................................................................................................................................. 16-9
CLOSE............................................................................................................................................. 16-10
COPY............................................................................................................................................... 16-10
CREATE TEMPORARY ............................................................................................................... 16-11
DISABLE BUFFERING................................................................................................................. 16-12
ENABLE BUFFERING.................................................................................................................. 16-12
ERASE............................................................................................................................................. 16-12
FILE CLOSE ALL .......................................................................................................................... 16-13
FILE SET ......................................................................................................................................... 16-13
FLUSH BUFFER ............................................................................................................................ 16-14
FREE TEMPORARY...................................................................................................................... 16-14
LOAD FROM FILE........................................................................................................................ 16-15
OPEN .............................................................................................................................................. 16-16
READ .............................................................................................................................................. 16-16
TRIM ............................................................................................................................................... 16-18
WRITE............................................................................................................................................. 16-18
DESCRIBE ...................................................................................................................................... 16-19
LOBs and the Navigational Interface.............................................................................................. 16-21
Transient Objects........................................................................................................................... 16-21
Persistent Objects .......................................................................................................................... 16-21
Navigational Interface Example.................................................................................................. 16-22
LOB Program Examples ..................................................................................................................... 16-23
READ a BLOB, Write a File Example......................................................................................... 16-23
Read a File, WRITE a BLOB Example ........................................................................................ 16-24
xx
lobdemo1.pc................................................................................................................................... 16-26
17 Objects
Introduction to Objects ........................................................................................................................ 17-1
Object Types..................................................................................................................................... 17-2
REFs to Object Types ...................................................................................................................... 17-2
Type Inheritance.............................................................................................................................. 17-2
Using Object Types in Pro*C/C++ ..................................................................................................... 17-3
NULL Indicators.............................................................................................................................. 17-3
The Object Cache .................................................................................................................................. 17-4
Persistent Versus Transient Copies of Objects............................................................................ 17-4
Associative Interface............................................................................................................................. 17-4
When to Use the Associative Interface......................................................................................... 17-4
ALLOCATE...................................................................................................................................... 17-4
FREE.................................................................................................................................................. 17-5
CACHE FREE ALL ......................................................................................................................... 17-5
Accessing Objects Using the Associative Interface .................................................................... 17-5
Navigational Interface.......................................................................................................................... 17-6
When to Use the Navigational Interface...................................................................................... 17-7
Rules Used in the Navigational Statements................................................................................ 17-7
OBJECT CREATE............................................................................................................................ 17-8
OBJECT DEREF ............................................................................................................................... 17-8
OBJECT RELEASE .......................................................................................................................... 17-9
OBJECT DELETE............................................................................................................................. 17-9
OBJECT UPDATE ......................................................................................................................... 17-10
OBJECT FLUSH............................................................................................................................. 17-10
Navigational Access to Objects ................................................................................................... 17-10
Converting Object Attributes and C Types.................................................................................... 17-12
OBJECT SET................................................................................................................................... 17-12
OBJECT GET.................................................................................................................................. 17-13
Object Options Set/Get ...................................................................................................................... 17-14
CONTEXT OBJECT OPTION SET.............................................................................................. 17-15
CONTEXT OBJECT OPTION GET............................................................................................. 17-15
New Precompiler Options for Objects............................................................................................ 17-16
VERSION........................................................................................................................................ 17-16
DURATION ................................................................................................................................... 17-16
OBJECTS......................................................................................................................................... 17-17
INTYPE........................................................................................................................................... 17-17
ERRTYPE........................................................................................................................................ 17-17
SQLCHECK Support for Objects ................................................................................................ 17-17
Type Checking at Runtime .......................................................................................................... 17-18
An Object Example in Pro*C/C++.................................................................................................... 17-18
Associative Access ........................................................................................................................ 17-18
Navigational Access...................................................................................................................... 17-19
Example Code for Type Inheritance ................................................................................................ 17-20
Example Code for Navigational Access .......................................................................................... 17-27
Using C Structures .............................................................................................................................. 17-33
剩余745页未读,继续阅读
155 浏览量
116 浏览量
2009-05-20 上传
105 浏览量
2012-09-29 上传
107 浏览量
190 浏览量
光流溢彩
- 粉丝: 6
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- PlantManager
- wlab-pro.github.io
- TaskToobig
- django-ra-erp:一个基于Django的框架,用于创建各种业务解决方案,并配有报告引擎和响应式仪表板
- PVsyst.v5.03.Multilingual.rar
- linphoneDoc.rar
- seckill:秒杀系统
- 50个动画图标 .aep .gif素材下载
- 易语言libcurl库7.73.0板源码+demo
- TaskItalic
- azure-k3s-cluster:使用k3s.io部署轻量级Kubernetes群集的Azure模板
- java邮件发送demo.rar
- More.Effective.C.rar
- caleydo.github.io:Caleydo网站
- handle-write-xx:手写***
- TaskDouble
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功