没有合适的资源?快使用搜索试试~ 我知道了~
首页Pro*C/C++Precompiler Programmer’s Guide
The Pro*C/C++ Programmer's Guide is intended for programmers, systems analysts, project managers, and other Oracle users who perform, or are interested in learning about, the following tasks: ■Design and develop software applications in the Oracle environment. ■Convert existing software applications to run in an Oracle environment. ■Manage the development of software applications. To use this document, you need a working knowledge of applications programming in C and C++, and familiarity with the use of the Structured Query Language (SQL).
资源详情
资源评论
资源推荐

Pro*C/C++™ Precompiler
Programmer’s Guide
Release 8.0
December, 1997
Part No. A58233-01

Pro*C/C++™ Precompiler Programmer’s Guide
Part No. A58233-01
Release 8.0
Copyright © 1997, Oracle Corporation. All rights reserved.
Primary Author: Jack Melnick
Contributing Author: Paul Lane
Contributors: Julie Basu, Brian Becker, Beethoven Cheng, Michael Chiocca, Pierre Dufour, Nancy Ikeda,
Thomas Kurian, Shiao-Yen Lin, Jacqui Pons, Ajay Popat, Ekkehard Rohwedder, Pamela Rothman, Alan
Thiesen, Gael Turk
Graphic Designer: Valarie Moore
The programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inher-
ently dangerous applications. It shall be licensee’s responsibility to take all appropriate fail-safe, back
up, redundancy and other measures to ensure the safe use of such applications if the Programs are
used for such purposes, and Oracle disclaims liability for any damages caused by such use of the Pro-
grams.
This Program contains proprietary information of Oracle Corporation; it is provided under a license
agreement containing restrictions on use and disclosure and is also protected by copyright patent and
other intellectual property law. Reverse engineering of the software 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.
If this Program is delivered to a U.S. Government Agency of the Department of Defense, then it is deliv-
ered with Restricted Rights and the following legend is applicable:
Restricted Rights Legend Programs delivered subject to the DOD FAR Supplement are 'commercial
computer software' and use, duplication and disclosure of the Programs 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 disclo-
sure of the Programs shall be subject to the restrictions in FAR 52..227-14, Rights in Data -- General,
including Alternate III (June 1987). Oracle Corporation, 500 Oracle Parkway, Redwood City, CA 94065.
Oracle, Pro*COBOL, SQL*Forms, SQL*Net, and SQL*Plus are registered trademarks of Oracle Corpora-
tion, Redwood City, California.
Net8, Oracle Call Interface, Oracle7, Oracle7 Server, Oracle8, Oracle8 Server, Oracle Forms, PL/SQL,
Pro*C, Pro*C/C++, and Trusted Oracle are trademarks of Oracle Corporation, Redwood City, California.
VMS is a registered trademark of Digital Equipment Corporation.
All other products or company names are used for identification purposes only, and may be trademarks
of their respective owners.

iii
Contents
Send Us Your Comments................................................................................................................ xxv
Preface....................................................................................................................................................... xxvii
What This Guide Has to Offer....................................................................................................... xxviii
Who Should Read This Guide? ..................................................................................................... xxviii
How the Pro*C/C++ Guide Is Organized..................................................................................... xxviii
Conventions Used in This Guide................................................................................................... xxxi
Notation ........................................................................................................................................ xxxi
ANSI/ISO Compliance..................................................................................................................... xxxi
Requirements .............................................................................................................................. xxxii
Migrating an Application................................................................................................................ xxxii
Your Comments Are Welcome....................................................................................................... xxxii
1 Introduction
What Is an Oracle Precompiler?....................................................................................................... 1-2
Why Use the Oracle Pro*C/C++ Precompiler?.............................................................................. 1-3
Why Use SQL?..................................................................................................................................... 1-3
Why Use PL/SQL?............................................................................................................................... 1-4
What Does the Pro*C/C++ Precompiler Offer?............................................................................. 1-4
Does the Oracle Pro*C/C++ Precompiler Meet Industry Standards?....................................... 1-7
Requirements ................................................................................................................................ 1-7
Compliance.................................................................................................................................... 1-8
Certification................................................................................................................................... 1-8
FIPS Flagger................................................................................................................................... 1-9

iv
Migrating an Application from Earlier Releases.......................................................................... 1-9
Frequently Asked Questions............................................................................................................ 1-9
2 Learning the Basics
Key Concepts of Embedded SQL Programming .......................................................................... 2-2
Embedded SQL Statements......................................................................................................... 2-2
Embedded SQL Syntax................................................................................................................ 2-5
Static Versus Dynamic SQL Statements .................................................................................... 2-5
Embedded PL/SQL Blocks ......................................................................................................... 2-6
Host and Indicator Variables ...................................................................................................... 2-6
Oracle Datatypes........................................................................................................................... 2-7
Arrays............................................................................................................................................. 2-7
Datatype Equivalencing............................................................................................................... 2-7
Private SQL Areas, Cursors, and Active Sets ........................................................................... 2-7
Transactions................................................................................................................................... 2-8
Errors and Warnings.................................................................................................................... 2-8
Steps in Developing an Embedded SQL Application................................................................. 2-9
Sample Tables ................................................................................................................................... 2-11
Sample Data................................................................................................................................. 2-11
Sample Program: A Simple Query ................................................................................................ 2-12
3 Developing a Pro*C/C++ Application
Support for the C Preprocessor........................................................................................................ 3-2
How the Pro*C/C++ Preprocessor Works................................................................................ 3-2
Preprocessor Directives ............................................................................................................... 3-3
ORA_PROC Macro....................................................................................................................... 3-4
Specifying the Location of Header Files.................................................................................... 3-4
Some Preprocessor Examples ..................................................................................................... 3-5
SQL Statements Not Allowed in #include ................................................................................ 3-7
Including the SQLCA, ORACA, and SQLDA .......................................................................... 3-7
EXEC SQL INCLUDE and #include Summary........................................................................ 3-8
Defined Macros............................................................................................................................. 3-8
Migrating From Earlier Pro*C/C++ Releases................................................................................. 3-9
Character Strings........................................................................................................................... 3-9
Deprecated Precompiler Option................................................................................................. 3-9

v
Error Message Codes ................................................................................................................. 3-10
Include Files................................................................................................................................. 3-10
Output Files................................................................................................................................. 3-10
Indicator Variables ..................................................................................................................... 3-10
Programming Guidelines................................................................................................................ 3-11
C++ Support................................................................................................................................ 3-11
Comments.................................................................................................................................... 3-11
Constants ..................................................................................................................................... 3-11
Delimiters..................................................................................................................................... 3-12
File Length................................................................................................................................... 3-12
Function Prototyping................................................................................................................. 3-12
Host Variable Names................................................................................................................. 3-13
Line Continuation....................................................................................................................... 3-13
MAXLITERAL Default Value................................................................................................... 3-13
Operators ..................................................................................................................................... 3-14
Statement Labels......................................................................................................................... 3-14
Statement Terminator ................................................................................................................ 3-15
Precompile-time Evaluation of Numeric Constants .................................................................. 3-15
Using Numeric Constants in Pro*C/C++............................................................................... 3-16
Numeric Constant Rules and Examples.................................................................................. 3-16
Oracle Datatypes............................................................................................................................... 3-17
Internal Datatypes...................................................................................................................... 3-17
External Datatypes ..................................................................................................................... 3-18
Host Variables................................................................................................................................... 3-27
Declaring Host Variables........................................................................................................... 3-27
Referencing Host Variables....................................................................................................... 3-31
Indicator Variables........................................................................................................................... 3-32
Using the Keyword INDICATOR............................................................................................ 3-32
An Example................................................................................................................................. 3-33
Guidelines.................................................................................................................................... 3-34
Oracle Restrictions...................................................................................................................... 3-34
Host Structures.................................................................................................................................. 3-34
Host Structures and Arrays....................................................................................................... 3-36
PL/SQL Records......................................................................................................................... 3-36
Nested Structures and Unions.................................................................................................. 3-37
剩余719页未读,继续阅读
安全验证
文档复制为VIP权益,开通VIP直接复制

评论3