Page 1031
Page 1032
Oracle Programmer/2000 is a suite of programmatic interfaces that allows you to manipulate Oracle7 databases. Some of the products are topics of other chapters in this book ”Oracle Objects for OLE, Chapters 40 through 42, and Open Database Connectivity (ODBC) in Chapter 57. All products in this suite have been separate products in the past and continue to be available separately on server platforms (non-Microsoft Windows and Macintosh) such as UNIX, AIX, and VMS. In addition to Objects for OLE and ODBC the other components of Programmer/2000 are Oracle Call Interface, SQL*Module, and, of course, the precompilers. This chapter focuses on Oracle precompilers. The Oracle Call Interface and SQL*Module products are described at the end of the chapter.
Extracting and manipulating data from a relational database is very difficult if not for tools such as precompilers. The precompiler allows SQL statements to be embedded within procedural languages. Applications developed with this tool can use the best features of SQL combined with the best features of the procedural language, creating a powerful module. This chapter discusses Oracle precompilers, creating a source program with embedded SQL, new features in version 1.8 of the Oracle precompilers, and some of other products in the Programmer/2000 suite.
The precompiler is a mechanism that allows SQL statements to be embedded within procedural languages. This tool provides the programmer with unlimited capabilities. To fully explain all the benefits of this tool, this chapter focuses on the features of the precompiler, what languages source code can be, how standardized the precompilers are, what options they have, how to precompile source code, and conditional precompiling.
Embedded SQL statements are not understood by high-level languages. The precompiler must therefore take the SQL statements and translate them into something the high-level language understands. Libraries contain data structures that help guide the translation process for consistency. Remembering this general concept will help you understand the precompiler features.
One of the primary reasons you use a precompiler is gaining the capability to use SQL statements in a high-level language. Oracle precompilers offer many benefits and features that can help in this development. These features include the following:
Page 1033
Each of these features is discussed in further detail later in the chapter.
Oracle has precompilers for eight procedural languages:
With Oracle precompilers, you can mix object modules produced in several host languages and link them together into one executable program.
Because SQL has become the standard language for relational databases, standardization is an important issue. Oracle precompilers take exceptional efforts to meet standards set by the following organizations:
Compliance for these requirements is measured by NIST, which uses over 300 test programs. Oracle precompilers conform to these standards by checking the SQL statements that are embedded for standard syntax and semantics. However, there is much more to precompiler function than syntax checking.
Page 1034
To increase flexibility among applications, Oracle precompilers have options that the programmer can manipulate to allow for certain conditions. For example, if a line of the source program exceeds 80 characters, the default, an error occurs. This can be extended to 132 characters or other value. Table 45.1 outlines many of these controls. The * character next to an item indicates that it can be entered inline, meaning it can be changed multiple times in a program.
Table 45.1. Precompiler options.
Syntax | Default | Specifies |
COMMON_NAME=block_name | Name of FORTRAN common blocks. | |
DEFINE=symbol | Symbol used in condi- tional precompilation. | |
ERRORS=YESNo* | YES | Whether errors are sent to the terminal. |
FORMAT=ANSITERMINAL | ANSI | Format of COBOL or FORTRAN input line. |
HOLD_CURSOR=YESNO* | NO | How a cursor cache handles SQL statements. |
HOST=C, COBOL, COB74, ADA, etc. | Host language. | |
INAME= path and filename | Name of input file. | |
INCLUDE=path* | Directory path for the included files. | |
IRECLEN=integer | 80 | Record length of input file. |
LNAME=path and filename | Name of listing file. | |
LRECLEN=integer | 132 | Record length of listing file. |
LTYPE=LONGSHORTNONE | LONG | Type of listing. |
MAXLITERAL=integer* | Maximum length of string. | |
MAXOPENCURSORS=integer* | 10 | Maximum number of cursors cached. |
MODE=ORACLEANSIANSI14ISOISO13 | ORACLE | Compliance with ANSI/ISO standard. |
ONAME=path and filename | Name of output file. | |
ORACA=YESNO | NO | Whether the ORACA is used. |
Page 1035
Syntax | Default | Specifies |
ORECLEN=integer | 80 | Record length of output file. |
RELEASE_CURSOR=YESNO* | NO | How cursor cache handles SQL statements. |
SELECT_ERROR=YESNO* | YES | How SELECT errors are handled. |
SQLCHECK=SEMANTICSFULLSYNTAXLIMITEDNONE* | SYNTAX | Extent of syntax and/or semantic checking. |
USERID=username/password | Valid Oracle username and password. | |
XREF=YESNO* | YES | Cross-reference section in listing. |
A precompiler command line might look something like the following:
proc iname=example.pc include=ora_pcc: include=clib: ireclen=132
The only required argument is iname. This argument tells the precompiler the source filename.
Follow these general guidelines when setting options for precompiling:
You can use all these options in several ways when precompiling your program, but what is the best way to precompile, compile, and link your source program?
In version 1.8 of the precompilers, executables exist for each of the languages previously mentioned. Each host language has a different command to run the precompiler, with the exception of C++, which uses PROC with the CODE=CPP option.