Programmer's Guide to the Oracle Precompilers Release 1.8 Part Number A42525-1 |
|
|
View PDF |
This chapter details the requirements for running the Oracle Precompilers. You learn what occurs during precompilation, how to issue the precompiler command, how to specify the many useful precompiler options, and how to do conditional and separate precompilations.
To run an Oracle Precompiler, you issue one of the language-specific commands shown in Table 6 - 1.
Host Language | Precompiler Command |
---|---|
COBOL | procob |
FORTRAN | profor |
The location of the precompiler differs from system to system. Typically, your system manager or DBA defines environment variables, logicals, or aliases or uses other operating system-specific means to make the precompiler executable accessible.
The INAME option specifies the source file to be precompiled. For example, the Pro*COBOL command
procob INAME=test
precompiles the file test.pco in the current directory, since the precompiler assumes that the filename extension is .pco. You need not use a file extension when specifying INAME unless the extension is nonstandard.
Input and output filenames need not be accompanied by their respective option names, INAME and ONAME. When the option names are not specified, the precompiler assumes that the first filename specified on the command line is the input filename and that the second filename is the output filename.
Thus, the Pro*FORTRAN command
profor MODE=ANSI myfile.pfo DBMS=V7 myfile.f
is equivalent to
profor MODE=ANSI INAME=myfile.pfo DBMS=V7 ONAME=myfile.f
Note: Option names and option values that do not name specific operating system objects, such as filenames, are not case-sensitive. In the examples in this guide, option names are written in upper case, and option values are usually in lower case. Filenames, including the name of the precompiler executable itself, always follow the case conventions used by the operating system on which it is executed.
During precompilation, an Oracle Precompiler generates host-language code that replaces the SQL statements embedded in your host program. The generated code includes data structures that contain the datatype, length, and address of each host variable, as well as other information required by the Oracle runtime library, SQLLIB. The generated code also contains the calls to SQLLIB routines that perform the embedded SQL operations.
The generated code also includes calls to the SQLLIB routines that perform embedded SQL operations. Note that the precompiler does not generate calls to Oracle Call Interface (OCI) routines.
Note: The precompiler does not generate calls to Oracle Call Interface (OCI) routines.
The precompiler can issue warnings and error messages. These messages have the prefix PCC-, and are described in Oracle7 Server Messages.
Many useful options are available at precompile time. They let you control how resources are used, how errors are reported, how input and output are formatted, and how cursors are managed. To specify a precompiler option, use the following syntax:
<option_name>=<value>
The value of an option is a string literal, which represents text or numeric values. For example, for the option
... INAME=my_test
the value is a string literal that specifies a filename, but for the option
... MAXOPENCURSORS=20
the value is numeric.
Some options take Boolean values, which you can represent with the strings YES or NO, TRUE or FALSE, or with the integer literals 1 or 0, respectively. For example, the option
... SELECT_ERROR=YES
is equivalent to
... SELECT_ERROR=TRUE
or
... SELECT_ERROR=1
The option value is always separated from the option name by an equal sign, leave no whitespace around the equal sign, because spaces delimit individual options. For example, you might specify the option AUTO_CONNECT on the command line as follows:
... AUTO_CONNECT=YES
You can abbreviate the names of options if the abbreviation is unambiguous. For example, you cannot use the abbreviation MAX because it might stand for MAXLITERAL or MAXOPENCURSORS.
A handy reference to the precompiler options is available online. To see the online display, enter the precompiler command with no arguments at your operating system prompt. The display gives the name, syntax, default value, and purpose of each option. Options marked with an asterisk (*) can be specified inline as well as on the command line.
Many of the options have default values, which are determined by:
For example, the option MAXOPENCURSORS specifies the maximum number of cached open cursors. The built-in precompiler default value for this option is 10. However, if MAXOPENCURSORS=32 is specified in the system configuration file, the default becomes 32. The user configuration file could set it to yet another value, which then overrides the system configuration value.
Then, if this option is set on the command line, the new command-line value takes precedence. Finally, an inline specification takes precedence over all preceding defaults. For more information, see "Configuration Files" .
You can interactively determine the current value for one or more options by using a question mark on the command line. For example, if you issue the Pro*COBOL command
procob ?
the complete option set, along with current values, is displayed on your terminal. In this case, the values are those built into the precompiler, overridden by any values in the system configuration file. But if you issue the following command
procob CONFIG=my_config_file.cfg ?
and there is a file named my_config_file.cfg in the current directory, the options from the my_config_file.cfg file are listed with the other default values. Values in the user configuration file supply missing values, and they supersede values built into the precompiler or values specified in the system configuration file.
You can also determine the current value of a single option by simply specifying the option name followed by "=?" as in
procob MAXOPENCURSORS=?
Note: With some operating systems, the "?" may need to be preceded by an "escape" character, such as a back-slash (\). For example, instead of "procob ?," you might need to use "procob \?" to list the Pro*COBOL option settings.
In general, you can use either uppercase or lowercase for command-line option names and values. However, if your operating system is case-sensitive, like UNIX, you must specify filename values, including the name of the precompiler executable, using the correct combination of upper and lowercase letters.
A configuration file is a text file that contains precompiler options. Each record (line) in the file contains one option, with its associated value or values. For example, a configuration file might contain the lines
FIPS=YES MODE=ANSI
to set defaults for the FIPS and MODE options.
There is a single system configuration file for each system. The name of the system configuration file is precompiler-specific and is shown in Table 6 - 2.
Precompiler | Configuration File |
---|---|
Pro*COBOL | pcccob.cfg |
Pro*FORTRAN | pccfor.cfg |
The location of the file is operating system-specific. On most UNIX systems, the Pro*COBOL configuration file is usually located in the $ORACLE_HOME/procob directory, and the Pro*FORTRAN equivalent is in the $ORACLE_HOME/profor directory, where $ORACLE_HOME is the environment variable for the database software.
Each precompiler user can have one or more user configuration files. The name of the configuration file must be specified using the CONFIG command-line option. For more information, see "Determining Current Values" .
Note: You cannot nest configuration files. This means that CONFIG is not a valid option inside a configuration file.
All the precompiler options can be entered on the command line or (except CONFIG) from a configuration file. Many options can also be entered inline. During a given run, the precompiler can accept options from all three sources.
You enter precompiler options on the command line using the following syntax:
... [option_name=value] [option_name=value] ...
Separate each option with one or more spaces. For example, you might enter the following options:
... ERRORS=no LTYPE=short
You enter options inline by coding EXEC ORACLE statements, using the following syntax:
EXEC ORACLE OPTION (option_name=value);
For example, you might code the following statement:
EXEC ORACLE OPTION (RELEASE_CURSOR=YES);
An option entered inline overrides the same option entered on the command line.
The EXEC ORACLE feature is especially useful for changing option values during precompilation. For example, you might want to change the HOLD_CURSOR and RELEASE_CURSOR values on a statement-by-statement basis. Appendix C shows you how to use inline options to optimize runtime performance.
Specifying options inline is also helpful if your operating system limits the number of characters you can enter on the command line, and you can store inline options in configuration files, which are discussed in the next section.
An EXEC ORACLE statement stays in effect until textually superseded by another EXEC ORACLE statement specifying the same option. In the following example, HOLD_CURSOR=NO stays in effect until superseded by HOLD_CURSOR=YES:
EXEC SQL BEGIN DECLARE SECTION; emp_name CHARACTER(20); emp_number INTEGER; salary REAL; dept_number INTEGER; EXEC SQL END DECLARE SECTION; ... EXEC SQL WHENEVER NOT FOUND GOTO no_more; EXEC ORACLE OPTION (HOLD_CURSOR=NO); EXEC SQL DECLARE emp_cursor CURSOR FOR SELECT EMPNO, DEPTNO FROM EMP; EXEC SQL OPEN emp_cursor; display 'Employee Number Dept'; display '--------------- ----'; LOOP EXEC SQL FETCH emp_cursor INTO :emp_number, :dept_number; display emp_number, dept_number; ENDLOOP; no_more: EXEC SQL WHENEVER NOT FOUND CONTINUE; LOOP display 'Employee number? '; read emp_number; IF emp_number = 0 THEN exit loop; EXEC ORACLE OPTION (HOLD_CURSOR=YES); EXEC SQL SELECT ENAME, SAL INTO :emp_name, :salary FROM EMP WHERE EMPNO = :emp_number; display 'Salary for ', emp_name, ' is ', salary; ENDLOOP; ...
The Oracle Precompilers can use a configuration file containing preset command-line options. By default, a text file called the system configuration file is used. However, you can specify any of several alternative files, called user configuration files, on the command line.
Configuration files offer several advantages. The system configuration file lets you standardize a set of options for all projects. User configuration files let you customize a set of options for each project. With configuration files, you need not enter long strings of options on the command line. Also, if your system limits the length of a command line, configuration files let you specify more options than the command line can hold.
Each record (line) in a configuration file holds one command-line option. For example, a configuration file might contain the following lines, which set defaults for the FIPS, MODE, and SQLCHECK options:
FIPS=YES MODE=ANSI SQLCHECK=SEMANTICS
Each Oracle Precompiler can have its own system configuration file. The name and location of the file are language- and system-specific. If the file is not found, you get a warning but the precompiler continues processing.
There is only one system configuration file for a given language, but you can create any number of user configuration files. You use the new command-line option CONFIG to specify the name and location of a particular user configuration file, as follows:
... CONFIG=<filename>
You cannot nest configuration files. Therefore, you cannot specify the CONFIG option in a configuration file. Also, you cannot specify CONFIG inline.
Many precompiler runtime options have built-in default values, which can be reset in a configuration file or on the command line. Command-line settings override user configuration file settings, which override system configuration file settings.
A precompilation unit is a file containing host-language code and one or more embedded SQL statements. The options specified for a given precompilation unit affect only that unit; they have no effect on other units.
For example, if you specify HOLD_CURSOR=YES and RELEASE_CURSOR=YES for unit A but not unit B, SQL statements in unit A run with these HOLD_CURSOR and RELEASE_CURSOR values, but SQL statements in unit B run with the default values. However, the MAXOPENCURSORS setting that is in effect when you connect to Oracle stays in effect for the life of that connection.
The scope of an inline option is positional, not logical. That is, an inline option affects SQL statements that follow it in the source file, not in the flow of program logic. An option setting stays in effect until the end-of-file unless you respecify the option.
is a quick reference to the precompiler options. Options marked with an asterisk can be entered inline.
Another handy reference is available online. To see the online display, just enter the precompiler command without options at your operating system prompt. The display gives the name, syntax, default value, and purpose of each option.
Note: There are some platform-specific options. For example, on byte-swapped platforms that use MicroFocus COBOL, the option COMP5 governs the use of certain COMPUTATIONAL items. Check your system-specific Oracle manuals.
Syntax | Default | Specifies ... |
---|---|---|
ASACC={YES|NO} | NO | carriage control for listing |
ASSUME_SQLCODE={YES|NO} | NO | precompiler presumes that SQLCODE is declared |
AUTO_CONNECT={YES|NO} | NO | automatic logon |
CONFIG=filename | name of user configuration file | |
COMMON_NAME=block_name * | name of FORTRAN COMMON blocks | |
DBMS={NATIVE|V6|V7} | NATIVE | version-specific behavior of Oracle at precompile time |
DEFINE=symbol * | symbol used in conditional precompilation | |
ERRORS={YES|NO} * | YES | whether errors are sent to the terminal |
FIPS={YES|NO}* | NO | whether ANSI/ISO extensions are flagged |
FORMAT={ANSI|TERMINAL} | ANSI | format of COBOL or FORTRAN input line |
HOLD_CURSOR={YES|NO}* | NO | how cursor cache handles SQL statements |
HOST={COBOL|COB74} | COBOL | COBOL version of input file |
[INAME=]filename | name of input file | |
INCLUDE=path* | directory path for INCLUDEd files | |
IRECLEN=integer | 80 | record length of input file |
LITDELIM={APOST|QUOTE} * | QUOTE | delimiter for COBOL strings |
LNAME=filename | name of listing file | |
LRECLEN=integer | 132 | record length of listing file |
LTYPE={LONG|SHORT|NONE} | LONG | type of listing |
MAXLITERAL=integer * | platform-specific | maximum length of strings |
MAXOPENCURSORS=integer * | 10 | maximum number of cursors cached |
MODE={ORACLE|ANSI|ANSI14|ANSI13} | ORACLE | compliance with the ANSI/ISO SQL standard |
MULTISUBPROG={YES|NO} | YES | whether FORTRAN COMMON blocks are generated |
NLS_LOCAL={YES|NO} | YES | blank-padding operations to be preformed by SQLLIB |
[ONAME=]filename | name of output file | |
ORACA={YES|NO}* | NO | whether the ORACA is used |
ORECLEN=integer | 80 | record length of output file |
PAGELEN=integer | 66 | lines per page in listing |
RELEASE_CURSOR={YES|NO} * | NO | how cursor cache handles SQL statements |
SELECT_ERROR={YES|NO}* | YES | how SELECT errors are handled |
SQLCHECK={FULL|SYNTAX|LIMITED|NONE}* | SYNTAX | extent of syntactic and semantic checking |
UNSAFE_NULL={YES|NO} | NO | disables the ORA-01405 message |
USERID=username/password | valid Oracle username and password | |
VARCHAR={YES|NO} | NO | recognize implicit VARCHAR group items in COBOL |
XREF={YES|NO}* | YES | cross reference section in listing |
This section is organized for easy reference. It lists the precompiler options alphabetically, and for each option gives its purpose, syntax, and default value. Usage notes that help you understand how the option works are also provided. Unless the usage notes say otherwise, the option can be entered on the command line, inline, or from a configuration file.
Purpose
Specifies whether the listing file follows the ASA convention of using the first column in each line for carriage control.
Syntax
ASACC={YES|NO}
Default
NO
Usage Notes
Cannot be entered inline.
Purpose
Instructs the Oracle Precompiler to presume that SQLCODE is declared whether or not it is declared in the Declare Section or of the proper type. ASSUME_SQLCODE=YES causes Releases 1.6 and later of the Oracle Precompilers to behave similarly to Release 1.5 in this respect.
Syntax
ASSUME_SQLCODE={YES|NO}
Default
NO
Usage Notes
Cannot be entered inline.
When ASSUME_SQLCODE=NO, SQLCODE is recognized as a status variable if and only if at least one of the following criteria is satisfied:
If the precompiler finds a SQLSTATE declaration (of exactly the right type of course) in a Declare Section or finds an INCLUDE of the SQLCA, it will not presume SQLCODE is declared.
When ASSUME_SQLCODE=YES, and when SQLSTATE and/or SQLCA (Pro*FORTRAN only) are declared as status variables, the precompiler presumes SQLCODE is declared whether or not it is declared in a Declare Section or of the proper type. This causes Releases 1.6.7 and later to behave like Release 1.5 in this regard.
Purpose
Specifies whether your program connects automatically to the default user account.
Syntax
AUTO_CONNECT={YES|NO}
Default
NO
Usage Notes
Cannot be entered inline.
When AUTO_CONNECT=YES, as soon as the precompiler encounters an executable SQL statement, your program tries to log on to Oracle automatically with the userid
<prefix><username>
where prefix is the value of the Oracle initialization parameter OS_AUTHENT_PREFIX (the default value is OPS$) and username is your operating system user or task name. In this case, you cannot override the default value for MAXOPENCURORS (10), even if you specify a different value on the command line.
When AUTO_CONNECT=NO (the default), you must use the CONNECT statement to log on to Oracle.
Purpose
For Pro*FORTRAN only, the COMMON_NAME option specifies a prefix used to name internal FORTRAN COMMON blocks. Your host program does not access the COMMON blocks directly. But, they allow two or more program units in the same precompilation unit to contain SQL statements.
Syntax
COMMON_NAME=blockname
Default
First five characters in name of input file
Usage Notes
The Pro*FORTRAN Precompiler uses a special program file called a block data subprogram to establish COMMON blocks for all the SQL variables in an input file. The block data subprogram defines two COMMON blocks -- one for CHARACTER variables, the other for non-CHARACTER variables -- and uses DATA statements to initialize the variables.
The format of a block data subprogram follows:
BLOCK DATA <subprogram_name> variable declarations COMMON statements DATA statements END
Your host program does not access the COMMON blocks directly. But, they allow two or more program files in the same precompilation file to contain SQL statements.
To name the COMMON blocks, the precompiler uses the name of the input file and the suffixes C, D, and I. At most, the first five characters of the filename are used. For example, if the name of the input file is ACCTSPAY, the precompiler names the COMMON blocks ACCTSC, ACCTSD, and ACCTSI.
The precompiler, however, can give COMMON blocks defined in different output files the same name, as the following schematic shows:
ACCTSPAY.PFO ===> ACCTSC, ACCTSD, ACCTSI in ACCTSPAY.FOR ACCTSREC.PFO ===> ACCTSC, ACCTSD, ACCTSI in ACCTSREC.FOR
If you were to link ACCTSPAY and ACCTSREC into an executable program, the linker would see three, not six, COMMON blocks.
To solve the problem, you can rename the input files, or you can override the default COMMON block names by specifying COMMON_NAME inline or on the command line as follows:
COMMON_NAME=<block_name>
where block_name is a legal COMMON block name. For example, if you specify COMMON_NAME=PAY, the precompiler names its COMMON blocks PAYC and PAYI. At most, the first five characters in block_name are used.
For example, if you specify COMMON_NAME=PAY, the precompiler names its COMMON blocks PAYC and PAYI. At most, the first 5 characters in block_name are used.
If you specify COMMON_NAME inline, its EXEC ORACLE OPTION statement must precede the FORTRAN PROGRAM, SUBROUTINE, or FUNCTION statement.
You might want to override the default COMMON block names if they conflict with your user-defined COMMON block names. However, the preferred practice is to rename the user-defined COMMON blocks.
COMMON_NAME is not needed if you specify MULTISUBPROG.
Purpose
Specifies the name of a user configuration file.
Syntax
CONFIG=filename
Default
None
Usage Notes
Can be entered only on the command line.
The Oracle Precompilers can use a configuration file containing preset command-line options. By default, a text file called the system configuration file is used. However, you can specify any of several alternative files, called user configuration files. For more information, see "Configuration Files" .
You cannot nest configuration files. Therefore, you cannot specify the option CONFIG in a configuration file.
Purpose
Specifies whether Oracle follows the semantic and syntactic rules of Oracle Version 6, Oracle7, or the native version of Oracle (that is, the version to which your application is connected).
Syntax
DBMS={NATIVE|V6|V7}
Default
NATIVE
Usage Notes
Cannot be entered inline.
With the DBMS option you can control the version-specific behavior of Oracle. When DBMS=NATIVE (the default), Oracle follows the semantic and syntactic rules of the native version of Oracle.
When DBMS=V6 or DBMS=V7, Oracle follows the rules of Oracle Version 6 or Oracle7, respectively. A summary of the differences between DBMS=V6 and DBMS=V7 follows:
If you precompile using the DBMS=V6 option, and connect to an Oracle7 database, then a data definition language (DDL) statement such as
CREATE TABLE T1 (COL1 CHAR(10))
creates the table using the VARCHAR2 (variable-length) datatype, as if the CREATE TABLE statement had been
CREATE TABLE T1 (COL1 VARCHAR2(10))
Table 6 - 4 shows how the compatible DBMS and MODE settings interact. All other combinations are incompatible or unrecommended.
Situation | DBMS=V7 MODE=ANSI | DBMS=V7 MODE=ORACLE | DBMS=V6 MODE=ORACLE |
---|---|---|---|
"no data found" warning code | +100 | +1403 | +1403 |
fetch nulls without using indicator variables | error -1405 | error -1405 | no error |
fetch truncated values without using indicator variables | no error but SQLWARN(2) is set | no error but SQLWARN(2) is set | error -1406 and SQLWARN(2) is set |
cursors closed by COMMIT or ROLLBACK | all explicit | CURRENT OF only | CURRENT OF only (1) |
open an already OPENed cursor | error -2117 | no error | no error |
close an already CLOSEd cursor | error -2114 | no error | no error |
SQL group function ignores nulls | no warning | no warning | SQLWARN(3) is set |
when SQL group function in multirow query is called | FETCH time | FETCH time | OPEN time |
declare SQLCA structure | optional | required | required (2) |
declare SQLCODE or SQLSTATE status variable | required | optional but Oracle ignores | optional but Oracle ignores (2) |
default external datatype of character host variables external datatype used for CHAR in TYPE and VAR statements |
CHARF | VARCHAR2 | VARCHAR2 |
default external datatype of string literals in SQL statements | CHARF | CHARF | VARCHAR2 |
default internal datatype of CHAR variables in SQL statements | CHAR | CHAR | VARCHAR2 |
default external datatype of CHAR variables in PL/SQL blocks | CHARF | CHARF | VARCHAR2 |
default external datatype of value function USER returns | CHARF | CHARF | VARCHAR2 |
external datatype code DESCRIBE returns (dynamic SQL Method 4) | 96 | 96 | 1 |
integrity constraints | enabled | enabled | disabled |
PCTINCREASE for rollback segments | not allowed | not allowed | allowed |
MAXEXTENTS storage parameters | not allowed | not allowed | allowed |
Purpose
Specifies a user-defined symbol that is used to include or exclude portions of source code during a conditional precompilation. For more information, see "Doing Conditional Precompilations" .
Syntax
DEFINE=symbol
Default
None
Usage Notes
If you enter DEFINE inline, the EXEC ORACLE statement takes the following form:
EXEC ORACLE DEFINE <symbol>;
Purpose
Specifies whether precompiler error messages are sent to the terminal and listing file or only to the listing file.
Syntax
ERRORS={YES|NO}
Default
YES
Usage Notes
When ERRORS=YES, error messages are sent to the terminal and listing file.
When ERRORS=NO, error messages are sent only to the listing file.
Purpose
Specifies whether extensions to ANSI/ISO SQL are flagged (by the FIPS Flagger). An extension is any SQL element that violates ANSI/ISO format or syntax rules, except privilege enforcement rules.
Syntax
FIPS={YES|NO}
Default
NO
Usage Notes
When FIPS=YES, the FIPS Flagger issues warning (not error) messages if you use an Oracle extension to the ANSI/ISO embedded SQL standard (SQL92) or use a SQL92 feature in a nonconforming manner.
The following extensions to ANSI/ISO SQL are flagged at precompile time:
Purpose
Specifies the format of COBOL or FORTRAN input lines.
Syntax
FORMAT={ANSI|TERMINAL}
Default
ANSI
Usage Notes
Cannot be entered inline.
The format of input lines is system-dependent. Check your system-specific Oracle manuals.
When FORMAT=ANSI, the format of input lines conforms as much as possible to the current ANSI standard.
Purpose
Specifies how the cursors for SQL statements and PL/SQL blocks are handled in the cursor cache.
Syntax
HOLD_CURSOR={YES|NO}
Default
NO
Usage Notes
You can use HOLD_CURSOR to improve the performance of your program. For more information, see Appendix C.
When a SQL data manipulation statement is executed, its associated cursor is linked to an entry in the cursor cache. The cursor cache entry is in turn linked to an Oracle private SQL area, which stores information needed to process the statement. HOLD_CURSOR controls what happens to the link between the cursor and cursor cache.
When HOLD_CURSOR=NO, after Oracle executes the SQL statement and the cursor is closed, the precompiler marks the link as reusable. The link is reused as soon as the cursor cache entry to which it points is needed for another SQL statement. This frees memory allocated to the private SQL area and releases parse locks.
When HOLD_CURSOR=YES and RELEASE_CURSOR=NO, the link is maintained; the precompiler does not reuse it. This is useful for SQL statements that are executed often because it speeds up subsequent executions. There is no need to reparse the statement or allocate memory for an Oracle private SQL area.
For inline use with implicit cursors, set HOLD_CURSOR before executing the SQL statement. For inline use with explicit cursors, set HOLD_CURSOR before opening the cursor.
Note that RELEASE_CURSOR=YES overrides HOLD_CURSOR=YES and that HOLD_CURSOR=NO overrides RELEASE_CURSOR=NO. For information showing how these two options interact, see Table C - 1 .
Purpose
Specifies the host language to be used.
Syntax
HOST={COB74|COBOL}
Default
COBOL
Usage Notes
Cannot be entered inline.
COB74 refers to the 1974 version of ANSI-approved COBOL. COBOL refers to 1985 version. Other values might be available on your platform.
Purpose
Specifies the name of the input file.
Syntax
INAME=filename
Default
None
Usage Notes
Cannot be entered inline.
When specifying the name of your input file on the command line, the keyword INAME is optional. For example, in Pro*COBOL, you can specify myprog.pco instead of INAME=myprog.pco.
The precompiler assumes the standard input file extension (see Table 6 - 5). So, you need not use a file extension when specifying INAME unless the extension is nonstandard. For example, in Pro*FORTRAN, you can specify myprog instead of myprog.pfo.
Host Language | Standard File Extension |
---|---|
COBOL | pco |
FORTRAN | pfo |
For Pro*COBOL only, if you use a nonstandard input file extension when specifying INAME, you must also specify HOST.
Purpose
Specifies a directory path for EXEC SQL INCLUDE files. It only applies to operating systems that use directories.
Syntax
INCLUDE=path
Default
Current directory
Usage Notes
Typically, you use INCLUDE to specify a directory path for the SQLCA and ORACA files. The precompiler searches first in the current directory, then in the directory specified by INCLUDE, and finally in a directory for standard INCLUDE files. Hence, you need not specify a directory path for standard files such as the SQLCA and ORACA.
You must still use INCLUDE to specify a directory path for nonstandard files unless they are stored in the current directory. You can specify more than one path on the command line, as follows:
... INCLUDE=<path1> INCLUDE=<path2> ...
The precompiler searches first in the current directory, then in the directory named by path1, then in the directory named by path2, and finally in the directory for standard INCLUDE files.
Remember, the precompiler looks for a file in the current directory first--even if you specify a directory path. So, if the file you want to INCLUDE resides in another directory, make sure no file with the same name resides in the current directory.
The syntax for specifying a directory path is system-specific. Follow the conventions of your operating system.
Purpose
Specifies the record length of the input file.
Syntax
IRECLEN=integer
Default
80
Usage Notes
Cannot be entered inline.
The value you specify for IRECLEN should not exceed the value of ORECLEN. The maximum value allowed is system-dependent.
Purpose
For Pro*COBOL only, the LITDELIM option specifies the delimiter for string constants and literals.
Syntax
LITDELIM={APOST|QUOTE}
Default
QUOTE
Usage Notes
When LITDELIM=APOST, the precompiler uses apostrophes when generating COBOL code. If you specify LITDELIM=QUOTE, quotation marks are used, as in
CALL "SQLROL" USING SQL-TMP0.
In SQL statements, you must use quotation marks to delimit identifiers containing special or lowercase characters, as in
EXEC SQL CREATE TABLE "Emp2" END-EXEC.
but you must use apostrophes to delimit string constants, as in
EXEC SQL SELECT ENAME FROM EMP WHERE JOB = 'CLERK' END-EXEC.
Regardless of which delimiter is used in the Pro*COBOL source file, the precompiler generates the delimiter specified by the LITDELIM value.
Purpose
Specifies a non-default name for the listing file.
Syntax
LNAME=filename
Default
input.LIS, where input is the base name of the input file.
Usage Notes
Cannot be entered inline.
By default, the listing file is written to the current directory.
Purpose
Specifies the record length of the listing file.
Syntax
LRECLEN=integer
Default
132
Usage Notes
Cannot be entered inline.
The value of LRECLEN can range from 80 through 255. If you specify a value below the range, 80 is used instead. If you specify a value above the range, 255 is used instead. LRECLEN should exceed IRECLEN by at least 8 to allow for the insertion of line numbers.
Purpose
Syntax
LTYPE={LONG|SHORT|NONE}
Default
LONG
Usage Notes
Cannot be entered inline.
When LTYPE=LONG, input lines appear in the listing file. When LTYPE=SHORT, input lines do not appear in the listing file. When LTYPE=NONE, no listing file is created.
Purpose
Specifies the maximum length of string literals generated by the precompiler so that compiler limits are not exceeded. For example, if your compiler cannot handle string literals longer than 132 characters, you can specify MAXLITERAL=132 on the command line.
Syntax
MAXLITERAL=integer
Default
The default is precompiler-specific as shown here:
Precompiler | Default |
---|---|
Pro*COBOL | 256 |
Pro*FORTRAN | 1000 |
The maximum value of MAXLITERAL is compiler-dependent. The default value is language-dependent, but you might have to specify a lower value. For example, some COBOL compilers cannot handle string literals longer than 132 characters, so you would specify MAXLITERAL=132.
Strings that exceed the length specified by MAXLITERAL are divided during precompilation, then recombined (concatenated) at run time.
You can enter MAXLITERAL inline but your program can set its value just once, and the EXEC ORACLE statement must precede the first EXEC SQL statement. Otherwise, the precompiler issues a warning message, ignores the extra or misplaced EXEC ORACLE statement, and continues processing.
Purpose
Specifies the number of concurrently open cursors that the precompiler tries to keep cached.
Syntax
MAXOPENCURSORS=integer
Default
10
Usage Notes
You can use MAXOPENCURSORS to improve the performance of your program. For more information, see Appendix C.
When precompiling separately, use MAXOPENCURSORS as described in "Separate Precompilations" .
MAXOPENCURSORS specifies the initial size of the SQLLIB cursor cache. If a new cursor is needed, and there are no free cache entries, Oracle tries to reuse an entry. Its success depends on the values of HOLD_CURSOR and RELEASE_CURSOR, and, for explicit cursors, on the status of the cursor itself. Oracle allocates an additional cache entry if it cannot find one to reuse. If necessary, Oracle keeps allocating additional cache entries until it runs out of memory or reaches the limit set by OPEN_CURSORS. To avoid a "maximum open cursors exceeded" Oracle error, MAXOPENCURSORS must be lower than OPEN_CURSORS by at least 6.
As your program's need for concurrently open cursors grows, you might want to respecify MAXOPENCURSORS to match the need. A value of 45 to 50 is not uncommon, but remember that each cursor requires another private SQL area in the user process memory space. The default value of 10 is adequate for most programs.
Purpose
Specifies whether your program observes Oracle practices or complies with the current ANSI SQL standard.
Syntax
MODE={ANSI|ISO|ANSI14|ISO14|ANSI13|ISO13|ORACLE}
Default
ORACLE
Usage Notes
Cannot be entered inline.
The following pairs of MODE values are equivalent: ANSI and ISO, ANSI14 and ISO14, ANSI13 and ISO13.
When MODE=ORACLE (the default), your embedded SQL program observes Oracle practices.
When MODE={ANSI14|ANSI13}, your program complies closely with the current ANSI SQL standard.
When MODE=ANSI, your program complies fully with the ANSI standard and the following changes go into effect:
When MODE={ANSI|ANSI14}, a 4-byte integer variable named SQLCODE (SQLCOD in FORTRAN) or a 5-byte character variable named SQLSTATE (SQLSTA in FORTRAN) must be declared. For more information, see "Error Handling Alternatives" .
Table 6 - 4 shows how the MODE and DBMS settings interact. Other combinations are incompatible or are not recommended.
Purpose
For Pro*FORTRAN only, the MULTISUBPROG option specifies whether the Pro*FORTRAN precompiler generates COMMON statements and BLOCK DATA subprograms.
Note: This option allows Pro*FORTRAN release 1.3 applications to migrate to later releases. You can ignore the MUTISUBPROG option if you are not migrating Pro*FORTRAN release 1.3 source code.
Syntax
MULTISUBPROG={YES|NO}
Default
YES
Usage Notes
Cannot be entered inline.
When MULTISUBPROG=YES, the precompiler generates COMMON statements and BLOCK DATA subprograms. Your host program does not access the COMMON blocks directly, but it allows two or more program units in the same precompilation unit to contain SQL statements.
However, the precompiler can give COMMON blocks defined in different output files the same name. If you link the files into an executable program, you get a link-time or runtime error. To solve this problem, you can rename the input files or override the default COMMON block names by specifying the option COMMON_NAME. To avoid the problem, specify MULTISUBPROG=NO.
Specify MULTISUBPROG=NO if your Pro*FORTRAN source code has only a single subprogram per source file (this was the restriction in release 1.3). When MULTISUBPROG=NO, the the COMMON_BLOCK option is ignored and the precompiler generates no COMMON statements or BLOCK DATA subprograms. Every program unit that contains executable SQL statements must have a Declare Section. Otherwise, you get a precompilation error. For input files that contain more than one embedded SQL program unit, the precompiler generates the same declarations in each unit.
Purpose
For Pro*COBOL only, the NLS_LOCAL option determines whether NLS character conversions are performed by the precompiler runtime library or by the Oracle Server.
Syntax
NLS_LOCAL={YES|NO}
Default
NO
Usage Notes
Cannot be entered inline.
When NLS_LOCAL=YES, the runtime library (SQLLIB) locally performs blank-padding and blank-stripping for host variables that have multi-byte NLS datatypes.
When NLS_LOCAL=NO, blank-padding and blank-stripping operations are not performed locally for host variables that have multi-byte NLS datatypes.
Attention: Release 7.2 of the Oracle7 Server does not perform any blank-padding or blank-stripping of NLS variables. When NLS_LOCAL=NO, the Oracle Server returns an error upon executing a SQL statement that uses multi-byte NLS data.
Purpose
Specifies the name of the output file.
Syntax
ONAME=filename
Default
System-dependent
Usage Notes
Cannot be entered inline.
Use this option to specify the name of the output file, where the name differs from that of the input file. For example, if you issue
procob INAME=my_test
the default output filename is my_test.cob. If you want the output filename to be my_test_1.cob, issue the command
procob INAME=my_test ONAME=my_test_1.cob
Note that you should add the .cob extension to files specified using ONAME. There is no default extension with the ONAME option.
Attention: Oracle recommends that you not let the output filename default, but rather name it explicitly using ONAME.
Purpose
Specifies whether a program can use the Oracle Communications Area (ORACA).
Syntax
ORACA={YES|NO}
Default
NO
Usage Notes
When ORACA=YES, you must place the INCLUDE ORACA statement in your program.
Purpose
Specifies the record length of the output file.
Syntax
ORECLEN=integer
Default
80
Usage Notes
Cannot be entered inline.
The value you specify for ORECLEN should equal or exceed the value of IRECLEN. The maximum value allowed is system-dependent.
Purpose
Specifies the number of lines per physical page of the listing file.
Syntax
PAGELEN=integer
Default
66
Usage Notes
Cannot be entered inline.
The maximum value allowed is system-dependent.
Purpose
Specifies how the cursors for SQL statements and PL/SQL blocks are handled in the cursor cache.
Syntax
RELEASE_CURSOR={YES|NO}
Default
NO
Usage Notes
You can use RELEASE_CURSOR to improve the performance of your program. For more information, see Appendix C.
When a SQL data manipulation statement is executed, its associated cursor is linked to an entry in the cursor cache. The cursor cache entry is in turn linked to an Oracle private SQL area, which stores information needed to process the statement. RELEASE_CURSOR controls what happens to the link between the cursor cache and private SQL area.
When RELEASE_CURSOR=YES, after Oracle executes the SQL statement and the cursor is closed, the precompiler immediately removes the link. This frees memory allocated to the private SQL area and releases parse locks. To make sure that associated resources are freed when you CLOSE a cursor, you must specify RELEASE_CURSOR=YES.
When RELEASE_CURSOR=NO and HOLD_CURSOR=YES, the link is maintained. The precompiler does not reuse the link unless the number of open cursors exceeds the value of MAXOPENCURSORS. This is useful for SQL statements that are executed often because it speeds up subsequent executions. There is no need to reparse the statement or allocate memory for an Oracle private SQL area.
For inline use with implicit cursors, set RELEASE_CURSOR before executing the SQL statement. For inline use with explicit cursors, set RELEASE_CURSOR before opening the cursor.
Note that RELEASE_CURSOR=YES overrides HOLD_CURSOR=YES and that HOLD_CURSOR=NO overrides RELEASE_CURSOR=NO. For information showing how these two options interact, see Table C - 1 .
Purpose
Specifies whether your program generates an error when a single-row SELECT statement returns more than one row or more rows than a host array can accommodate.
Syntax
SELECT_ERROR={YES|NO}
Default
YES
Usage Notes
When SELECT_ERROR=YES, an error is generated if a single-row select returns too many rows or an array select returns more rows than the host array can accommodate.
When SELECT_ERROR=NO, no error is generated when a single-row select returns too many rows or when an array select returns more rows than the host array can accommodate.
Whether you specify YES or NO, a random row is selected from the table. To ensure a specific ordering of rows, use the ORDER BY clause in your SELECT statement. When SELECT_ERROR=NO and you use ORDER BY, Oracle returns the first row, or the first n rows if you are selecting into an array. When SELECT_ERROR=YES, whether or not you use ORDER BY, an error is generated if too many rows are returned.
Purpose
Specifies the type and extent of syntactic and semantic checking.
Syntax
SQLCHECK={SEMANTICS|FULL|SYNTAX|LIMITED|NONE}
Default
SYNTAX
Usage Notes
The values SEMANTICS and FULL are equivalent, as are the values SYNTAX and LIMITED.
The Oracle Precompilers can help you debug a program by checking the syntax and semantics of embedded SQL statements and PL/SQL blocks. Any errors found are reported at precompile time.
You control the level of checking by entering the SQLCHECK option inline and/or on the command line. However, the level of checking you specify inline cannot be higher than the level you specify (or accept by default) on the command line. For example, if you specify SQLCHECK=NONE on the command line, you cannot specify SQLCHECK=SYNTAX inline.
If SQLCHECK=SYNTAX|SEMANTICS, the precompiler generates an error when PL/SQL reserved words are used in SQL statements, even though the SQL statements are not themselves PL/SQL. If a PL/SQL reserved word must be used as an identifier, you can enclose it in double-quotes.
When SQLCHECK=SEMANTICS, the precompiler checks the syntax and semantics of
However, the precompiler checks only the syntax of remote data manipulation statements (those using the AT db_name clause).
The precompiler gets the information for a semantic check from embedded DECLARE TABLE statements or, if you specify the option USERID, by connecting to Oracle and accessing the data dictionary. You need not connect to Oracle if every table referenced in a data manipulation statement or PL/SQL block is defined in a DECLARE TABLE statement.
If you connect to Oracle but some information cannot be found in the data dictionary, you must use DECLARE TABLE statements to supply the missing information. During precompilation, a DECLARE TABLE definition overrides a data dictionary definition if they conflict.
Specify SQLCHECK=SEMANTICS when precompiling new programs. If you embed PL/SQL blocks in a host program, you must specify SQLCHECK=SEMANTICS and the option USERID.
When SQLCHECK=SYNTAX, the precompiler checks the syntax of
No semantic checking is done. DECLARE TABLE statements are ignored and PL/SQL blocks are not allowed. When checking data manipulation statements, the precompiler uses Oracle7 syntax rules, which are are downwardly compatible. Specify SQLCHECK=SYNTAX when migrating your precompiled programs.
When SQLCHECK=NONE, no syntactic or semantic checking is done. DECLARE TABLE statements are ignored and PL/SQL blocks are not allowed. Specify SQLCHECK=NONE if your program
Table 6 - 6 summarizes the checking done by SQLCHECK. For more information about syntactic and semantic checking, see Appendix D.
SQLCHECK=SEMANTICS | SQLCHECK=SYNTAX | SQLCHECK=NONE | ||||
---|---|---|---|---|---|---|
Syntax | Semantics | Syntax | Semantics | Syntax | Semantics | |
DML | _/ | _/ | _/ | |||
Remote DML | _/ | _/ | ||||
PL/SQL | _/ | _/ |
Purpose
Specifying UNSAFE_NULL=YES prevents generation of ORA-01405 messages when fetching NULLs without using indicator variables.
Syntax
UNSAFE_NULL={YES|NO}
Default
NO
Usage Notes
Cannot be entered inline.
The UNSAFE_NULL=YES is allowed only when MODE=ORACLE and DBMS=V7.
The UNSAFE_NULL option has no effect on host variables in an embedded PL/SQL block. You must use indicator variables to avoid ORA-01405 errors.
Purpose
Specifies an Oracle username and password.
Syntax
USERID=username/password
Default
None
Usage Notes
Cannot be entered inline.
Do not specify this option when using the automatic logon feature, which accepts your Oracle username prefixed with the value of the Oracle initialization parameter OS_AUTHENT_PREFIX.
When SQLCHECK=SEMANTICS, if you want the precompiler to get needed information by connecting to Oracle and accessing the data dictionary, you must also specify USERID.
Purpose
For Pro*COBOL only, the VARCHAR option instructs the precompiler to treat the COBOL group item described in Chapter 1 of the Pro*COBOL Supplement to the Oracle Precompilers Guide as a VARCHAR datatype.
Syntax
VARCHAR={YES|NO}
Default
NO
Usage Notes
Cannot be entered inline.
When VARCHAR=YES, the implicit group item described in Chapter 1 of the Pro*COBOL Supplement to the Oracle Precompilers Guide is accepted as an Oracle7 VARCHAR external datatype with a length field and a string field.
When VARCHAR=NO, the Pro*COBOL Precompiler does not accept the implicit group items as VARCHAR external datatypes.
Purpose
Specifies whether a cross-reference section is included in the listing file.
Syntax
XREF={YES|NO}
Default
YES
Usage Notes
When XREF=YES, cross references are included for host variables, cursor names, and statement names. The cross references show where each object is defined and referenced in your program.
When XREF=NO, the cross-reference section is not included.
Conditional precompilation includes (or excludes) sections of code in your host program based on certain conditions. For example, you might want to include one section of code when precompiling under UNIX and another section when precompiling under VMS. Conditional precompilation lets you write programs that can run in different environments.
Conditional sections of code are marked by statements that define the environment and actions to take. You can code host-language statements as well as EXEC SQL statements in these sections. The following statements let you exercise conditional control over precompilation:
EXEC ORACLE DEFINE symbol; -- define a symbol EXEC ORACLE IFDEF symbol; -- if symbol is defined EXEC ORACLE IFNDEF symbol; -- if symbol is not defined EXEC ORACLE ELSE; -- otherwise EXEC ORACLE ENDIF; -- end this control block
All EXEC ORACLE statements must be terminated with the statement terminator for your host language. For example, in Pro*COBOL, a conditional statement must be terminated with "END-EXEC." and in Pro*FORTRAN it must be terminated by a return character.
In the following example, the SELECT statement is precompiled only when the symbol site2 is defined:
EXEC ORACLE IFDEF site2; EXEC SQL SELECT DNAME INTO :dept_name FROM DEPT WHERE DEPTNO = :dept_number; EXEC ORACLE ENDIF;
Blocks of conditions can be nested as shown in the following example:
EXEC ORACLE IFDEF outer; EXEC ORACLE IFDEF inner; ... EXEC ORACLE ENDIF; EXEC ORACLE ENDIF;
You can "comment out" host-language or embedded SQL code by placing it between IFDEF and ENDIF and not defining the symbol.
You can define a symbol in two ways. Either include the statement
EXEC ORACLE DEFINE symbol;
in your host program or define the symbol on the command line using the syntax
... INAME=filename ... DEFINE=symbol
where symbol is not case-sensitive.
Some port-specific symbols are predefined for you when the Oracle Precompilers are installed on your system. For example, predefined operating system symbols include CMS, MVS, MS-DOS, UNIX, and VMS.
With the Oracle Precompilers, you can precompile several host program modules separately, then link them into one executable program. This supports modular programming, which is required when the functional components of a program are written and debugged by different programmers. The individual program modules need not be written in the same language.
The following guidelines will help you avoid some common problems.
Cursor names are SQL identifiers, whose scope is the precompilation unit. Hence, cursor operations cannot span precompilation units (files). That is, you cannot declare a cursor in one file and open or fetch from it in another file. So, when doing a separate precompilation, make sure all definitions and references to a given cursor are in one file.
When you precompile the program module that connects to Oracle, specify a value for MAXOPENCURSORS that is high enough for any of the program modules. If you use it for another program module, MAXOPENCURSORS is ignored. Only the value in effect for the connect is used at run time.
If you want to use just one SQLCA, you must declare it globally in one of the program modules.
All references to an explicit cursor must be in the same program file. You cannot perform operations on a cursor that was DECLAREd in a different module. See Chapter 4 for more information about cursors.
Also, any program file that contains SQL statements must have a SQLCA that is in the scope of the local SQL statements.
To get an executable program, you must compile the source file(s) produced by the precompiler, then link the resulting object module with any modules needed from SQLLIB and system-specific Oracle libraries. Also, if you are embedding OCI calls, make sure to link in the OCI runtime library (OCILIB).
The linker resolves symbolic references in the object modules. If these references conflict, the link fails. This can happen when you try to link third party software into a precompiled program. Not all third-party software is compatible with Oracle, so you might have problems. Check with Oracle Customer Support to see if the software is supported.
Compiling and linking are system-dependent. For instructions, see your system-specific Oracle manuals.
Compiling and linking are system-dependent. For example, on some systems, you must turn off compiler optimization when compiling a host language program. For instructions, see your system-specific Oracle documentation.
When using multi-byte NLS features, you must link your object files to the current version of the SQLLIB runtime library. The multi-byte NLS features in this release are supported by the SQLLIB runtime library and not by the Oracle Server. The resulting application can then be executed with any release of the Oracle7 Server.