Scalable Database Server, HiRDB Version 8 UAP Development Guide
Before a UAP is preprocessed, the environment variable described below can be specified in the HiRDB.INI file, if necessary.
The HiRDB.INI file is installed in the %windir% directory.
Following are the three methods of activating the SQL preprocessor:
A command is entered in the following format:
PDCPP.EXE input-file-name [options [output-file-name|authorization-identifier]]
Table 8-8 Preprocessing options (for C in the Windows environment)
Preprocessing option | Description |
---|---|
/S | Specifies that only syntax is checked and that no post source will be output; when this option is omitted, the post source is output. Note that the SQL preprocessor may not be able to detect all syntax errors in the SQL statements because it does not perform a rigorous SQL syntax check unless /Xp is also specified. |
/O file-name | Specifies a filename for the post source that is output; when this option is omitted, the input filename with its file identifier changed to .C is used as the output filename. |
/A authorization-identifier | Specifies that the default authorization identifier, which is used when no authorization identifier is specified in a static SQL statement, is to be changed. A static SQL statement refers to the INSERT, UPDATE, DELETE, single-row SELECT, OPEN (format 1), CALL, LOCK, or PURGE TABLE statement. |
/h64 | Specifies that a post source for 64-bit mode is to be created. If an embedded variable that uses the long type is declared, an error occurs. |
/Xe{y|n} | Specifies whether the cursor for PREPARE statement execution is to be closed automatically. y: Creates a post source that closes the cursor automatically. n: Creates a post source that does not close the cursor automatically. If this option is omitted, the preprocessor creates a post source according to the specification value in the PDPRPCRCLS client environment definition. |
/Xv | Specifies that VARCHAR- and BINARY-type structures are to be analyzed as normal structures when the /E2 option is specified. To declare VARCHAR- and BINARY-type embedded variables, use the SQL TYPE IS-type variable declaration. This option must be specified together with the /E2 option. Do not specify this option if the UAP uses macros for repetition columns. |
/XA | Specifies that an X/Open-compliant API is to be used to create the UAP. |
/Xo | Specifies that the SQL statements extracted from the UAP are to be output to standard output. The output method for outputting the SQL statements is described below.
|
/E{1|2|3} ["option-character-string"] | Specifies that preprocessor declaration statements used in the UAP are to be validated or that embedded variables are to be used without being declared in the embedded SQL declare section, or both. /E1: Specifies that preprocessor declaration statements are to be validated. /E2: Specifies that embedded variables are to be used without being declared in the embedded SQL declare section. This value can also specify that pointers or structure references are to be used as embedded variables. /E3: Specifies that both /E1 and /E2 apply. "option-character-string": Specifies the path name of the directory from which the file to be included is to be retrieved. Specify the path name in the format of the /I option specified in the C compiler. When specifying multiple options in option-character-string, use semicolons to separate the options. You can also specify any C compiler. When the /E2 option is specified, this value ignored. When the /E1 option is specified, the path name to the compiler must be specified in the PATH environment variable because the preprocessor calls the C compiler internally. |
/Xp | Specifies that a rigorous SQL syntax check is to be executed. However, do not specify this option when the SQL reserved word deletion facility is used. |
Function | Omitted | /E1 | /E2 | /E3 |
---|---|---|---|---|
Validate the macro defined with #define. | N | Y | N | Y |
Validate the header file that was included with #include. | N | Y | N | Y |
Enable conditional compilation with #if, #ifdef, and other statements. | N | Y | N | Y |
Use variables declared anywhere in the UAP as embedded variables. | N | N | Y | Y |
Use structures as embedded variables. | N | N | Y | Y |
Use pointers as embedded variables. | N | N | Y | Y |
PDCPP SAMPLE.EC /S
PDCPP SAMPLE.EC /O MAIN.C
PDOCC.EXE SAMPLE.ECP /S
PDOCC.EXE SAMPLE.ECP /O MAIN.CPP
The SQL preprocessor returns a return code to the OS when the processing is completed. The return code can be referenced by the OS batch command ERRORLEVEL.
Table 8-9 lists the return codes.
Table 8-9 SQL preprocessor return codes (for C programs in a Windows environment)
Return code | Explanation |
---|---|
0 | Normal termination |
4, 8 | Error (preprocessing was completed) |
12, 16 | Error (preprocessing terminated abnormally) |
When a syntax error is detected in an SQL statement, the SQL preprocessor ignores that SQL statement and continues processing. If an error is detected in an option specification, however, processing is suspended. Processing terminates abnormally when a system error, such as a memory shortage or a file I/O error, occurs and processing cannot be continued.
For a syntax error in an SQL statement, the SQL preprocessor outputs an error message to the standard error output. By redirecting the standard error output, the error message can be stored in a file. This file can be referenced for the error content, the UAP source filename, and the error location (line number in the SQL statement).
Table 8-10 shows the standard input and output for the SQL preprocessor.
Table 8-10 SQL preprocessor standard input and output (for C programs in a Windows environment)
File | Application |
---|---|
Standard input | File input (cannot be used by the user) |
Standard output | File output (cannot be used by the user) |
Standard error output | Output of error messages |
The following environment variables can be set in the HIRDB.INI file before a UAP is preprocessed (the HIRDB.INI file is installed in the %windir% directory):
[HiRDB] 1 PDCBLFIX=.AAA 2 PDCBLLIB=E:\USER\COPY 3
Following are the three methods of activating the SQL preprocessor:
A command is entered in the following format:
PDCBL.EXE input-file-name [options [output-file-name|authorization-identifier]]
Table 8-11 Preprocessing options (for COBOL in the Windows environment)
Preprocessing option | Description |
---|---|
/S | Specifies that only syntax is checked and that no post source will be output; when this option is omitted, the post source is output. Note that the SQL preprocessor may not be able to detect all syntax errors in the SQL statements because it does not perform a rigorous SQL syntax check unless /Xp is also specified. |
/O file-name | Specifies that the filename for the output post source is to be changed. When this option is omitted, the input filename with its file identifier changed to .CBL (for COBOL language) or .OCB (for OOCOBOL language) and is used as the output filename. If the input file identifier is .CBL (for COBOL language) or .OCB (for OOCOBOL language), this option must be specified to change the post source filename to an identifier other than .CBL (for COBOL language) or .OCB (for OOCOBOL language). |
/XC | Specifies that the double quotation mark is used as the quotation mark in the character string to be created by the SQL preprocessor; the default quotation mark is the apostrophe. |
/A authorization-identifier | Specifies that the default authorization identifier, which is used when no authorization identifier is specified in a static SQL statement, is to be changed. A static SQL statement refers to the INSERT, UPDATE, DELETE, single-row SELECT, OPEN (format 1), CALL, LOCK, or PURGE TABLE statement. |
/XD | Specifies that a DLL is to be created. The prerequisite compiler for creating a DLL is COBOL85 Version 4.0 04-02 or a later version. Do not create an application that contains both UAPs that were preprocessed by specifying the /XD option and UAPs that were preprocessed without specifying the /XD option. Otherwise, an error (KCCBO204R-S) occurs in the COBOL runtime library during application execution. |
/Xe{y|n} | Specifies whether the cursor for PREPARE statement execution is to be closed automatically. y: Creates a post source that closes the cursor automatically. n: Creates a post source that does not close the cursor automatically. If this option is omitted, the preprocessor creates a post source according to the specification value in the PDPRPCRCLS client environment definition. |
/XAD | Specifies that a UAP that used an X/Open-compliant API is to be created as a DLL. |
/XA | Specifies that the UAP is to be created by using an X/Open-compliant API. |
/Xo | Specifies that the SQL statements extracted from the UAP are to be output to standard output. The output method for outputting the SQL statements is described below.
|
/E2 | Specifies that embedded variables are to be used without being declared in the embedded SQL declare section. |
/Xp | Specifies that a rigorous SQL syntax check is to be executed. However, do not specify this option when the SQL reserved word deletion facility is used. |
PDCBL SAMPLE.ECB /S
PDCBL SAMPLE.ECB /O MAIN.CBL
PDOCB.EXE SAMPLE.EOC /S
PDOCB.EXE SAMPLE.EOC /O MAIN.OCB
The SQL preprocessor returns a return code to the OS when the processing is completed. The return code can be referenced by the OS batch command ERRORLEVEL.
Table 8-12 lists the return codes.
Table 8-12 SQL preprocessor return codes (for COBOL programs in a Windows environment)
Return code | Explanation |
---|---|
0 | Normal termination |
4, 8 | Error (preprocessing was completed) |
12, 16 | Error (preprocessing terminated abnormally) |
When a syntax error is detected in an SQL statement, the SQL preprocessor ignores that SQL statement and continues processing. If an error is detected in an option specification, however, processing is suspended. Processing terminates abnormally when a system error, such as a memory shortage or a file I/O error, occurs and processing cannot be continued.
For a syntax error in an SQL statement, the SQL preprocessor outputs an error message to the standard error output. By redirecting the standard error output, the error message can be stored in a file. This file can be referenced for the error content, the UAP source filename, and the error location (line number in the SQL statement).
Table 8-13 shows the standard input and output of the SQL preprocessor.
Table 8-13 SQL preprocessor standard input and output (for COBOL programs in a Windows environment)
File | Application |
---|---|
Standard input | File input (cannot be used by the user) |
Standard output | File output (cannot be used by the user) |
Standard error output | Output of error messages |
All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd.