Processes an application program source file containing embedded SQL statements. A modified source file is produced containing host language calls for the SQL statements and, by default, a package is created in the database.
Scope
This API can be called from any node in db2nodes.cfg. It updates the database catalogs on the catalog node. Its effects are visible to all nodes.
Authorization
One of the following:
The user also needs all privileges required to compile any static SQL statements in the application. Privileges granted to groups are not used for authorization checking of static statements. If the user has sysadm authority, but not explicit privileges to complete the bind, the database manager grants explicit dbadm authority automatically.
Required Connection
Database
Version
sql.h
C API Syntax
/* File: sql.h */ /* API: Precompile Program */ /* ... */ SQL_API_RC SQL_API_FN sqlaprep ( _SQLOLDCHAR * pProgramName, _SQLOLDCHAR * pMsgFileName, struct sqlopt * pPrepOptions, struct sqlca * pSqlca); /* ... */ |
Generic API Syntax
/* File: sql.h */ /* API: Precompile Program */ /* ... */ SQL_API_RC SQL_API_FN sqlgprep ( unsigned short MsgFileNameLen, unsigned short ProgramNameLen, struct sqlca * pSqlca, struct sqlopt * pPrepOptions, _SQLOLDCHAR * pMsgFileName, _SQLOLDCHAR * pProgramName); /* ... */ |
API Parameters
When the TARGET option is used, the input file name extension does not have to be from this predefined list.
The preferred extension for C++ applications containing embedded SQL on UNIX based systems is sqC; however, the sqx convention, which was invented for systems that are not case sensitive, is tolerated by UNIX based systems.
REXX API Syntax
This API can be called from REXX through the SQLDB2 interface. See How the API Descriptions are Organized, or the Application Development Guide. For a description of the syntax, see the Command Reference.
Sample Programs
Usage Notes
A modified source file is produced, which contains host language equivalents to the SQL statements. By default, a package is created in the database to which a connection has been established. The name of the package is the same as the program file name (minus the extension and folded to uppercase), up to a maximum of 8 characters.
Following connection to a database, sqlaprep executes under the transaction that was started. PRECOMPILE PROGRAM then issues a COMMIT or a ROLLBACK operation to terminate the current transaction and start another one.
Precompiling stops if a fatal error or more than 100 errors occur. If a fatal error does occur, PRECOMPILE PROGRAM stops precompiling, attempts to close all files, and discards the package.
The following table lists valid values for the type and the
val fields of the precompile options structure (see SQLOPT), as well as their corresponding CLP options. For
a description of the precompile options (including default values), see the
Command Reference.
Table 5. PRECOMPILE Option Types and Values
CLP Option | API Option Type | API Option Values |
---|---|---|
ACTION ADD | SQL_ACTION_OPT | SQL_ACTION_ADD |
ACTION REPLACE | SQL_ACTION_OPT | SQL_ACTION_REPLACE |
BINDFILE | SQL_BIND_OPT | Null |
BINDFILE filename | SQL_BIND_OPT | sqlchar structure |
BLOCKING ALL | SQL_BLOCK_OPT | SQL_BL_ALL |
BLOCKING NO | SQL_BLOCK_OPT | SQL_BL_NO |
BLOCKING UNAMBIG | SQL_BLOCK_OPT | SQL_BL_UNAMBIG |
CCSIDG value | SQL_CCSIDG_OPT | sqlopt.sqloptions.val |
CCSIDM value | SQL_CCSIDM_OPT | sqlopt.sqloptions.val |
CCSIDS value | SQL_CCSIDS_OPT | sqlopt.sqloptions.val |
CHARSUB BIT | SQL_CHARSUB_OPT | SQL_CHARSUB_BIT |
CHARSUB DEFAULT | SQL_CHARSUB_OPT | SQL_CHARSUB_DEFAULT |
CHARSUB MIXED | SQL_CHARSUB_OPT | SQL_CHARSUB_MIXED |
CHARSUB SBCS | SQL_CHARSUB_OPT | SQL_CHARSUB_SBCS |
CNULREQD NO | SQL_CNULREQD_OPT | SQL_CNULREQD_NO |
CNULREQD YES | SQL_CNULREQD_OPT | SQL_CNULREQD_YES |
COLLECTION coll-id | SQL_COLLECTION_OPT | sqlchar structure |
CONNECT 1 | SQL_CONNECT_OPT | SQL_CONNECT_1 |
CONNECT 2 | SQL_CONNECT_OPT | SQL_CONNECT_2 |
DATETIME DEF | SQL_DATETIME_OPT | SQL_DATETIME_DEF |
DATETIME EUR | SQL_DATETIME_OPT | SQL_DATETIME_EUR |
DATETIME ISO | SQL_DATETIME_OPT | SQL_DATETIME_ISO |
DATETIME JIS | SQL_DATETIME_OPT | SQL_DATETIME_JIS |
DATETIME LOC | SQL_DATETIME_OPT | SQL_DATETIME_LOC |
DATETIME USA | SQL_DATETIME_OPT | SQL_DATETIME_USA |
DECDEL COMMA | SQL_DECDEL_OPT | SQL_DECDEL_COMMA |
DECDEL PERIOD | SQL_DECDEL_OPT | SQL_DECDEL_PERIOD |
DEC 15 | SQL_DEC_OPT | SQL_DEC_15 |
DEC 31 | SQL_DEC_OPT | SQL_DEC_31 |
DEFERRED_PREPARE ALL | SQL_DEFERRED_PREPARE_OPT | SQL_DEFERRED_PREPARE_ALL |
DEFERRED_PREPARE NO | SQL_DEFERRED_PREPARE_OPT | SQL_DEFERRED_PREPARE_NO |
DEFERRED_PREPARE YES | SQL_DEFERRED_PREPARE_OPT | SQL_DEFERRED_PREPARE_YES |
DEGREE 1 | SQL_DEGREE_OPT | SQL_DEGREE_1 |
DEGREE ANY | SQL_DEGREE_OPT | SQL_DEGREE_ANY |
DEGREE degree | SQL_DEGREE_OPT | Integer between 1 and 32767. |
DISCONNECT EXPLICIT | SQL_DISCONNECT_OPT | SQL_DISCONNECT_EXPL |
DISCONNECT CONDITIONAL | SQL_DISCONNECT_OPT | SQL_DISCONNECT_COND |
DISCONNECT AUTOMATIC | SQL_DISCONNECT_OPT | SQL_DISCONNECT_AUTO |
DYNAMICRULES BIND | SQL_DYNAMICRULES_OPT | SQL_DYNAMICRULES_BIND |
DYNAMICRULES RUN | SQL_DYNAMICRULES_OPT | SQL_DYNAMICRULES_RUN |
DYNAMICRULES DEFINE | SQL_DYNAMICRULES_OPT | SQL_DYNAMICRULES_DEFINE |
DYNAMICRULES INVOKE | SQL_DYNAMICRULES_OPT | SQL_DYNAMICRULES_INVOKE |
EXPLAIN NO | SQL_EXPLAIN_OPT | SQL_EXPLAIN_NO |
EXPLAIN YES | SQL_EXPLAIN_OPT | SQL_EXPLAIN_YES |
EXPLAIN ALL | SQL_EXPLAIN_OPT | SQL_EXPLAIN_ALL
Not supported by DRDA. |
EXPLSNAP NO | SQL_EXPLSNAP_OPT | SQL_EXPLSNAP_NO |
EXPLSNAP YES | SQL_EXPLSNAP_OPT | SQL_EXPLSNAP_YES |
EXPLSNAP ALL | SQL_EXPLSNAP_OPT | SQL_EXPLSNAP_ALL |
FUNCPATH | SQL_FUNCTION_PATH | sqlchar structure |
GENERIC | SQL_GENERIC_OPT | sqlchar structure |
INSERT BUF | SQL_INSERT_OPT | SQL_INSERT_BUF |
INSERT DEF | SQL_INSERT_OPT | SQL_INSERT_DEF |
ISOLATION RS | SQL_ISO_OPT | SQL_READ_STAB |
ISOLATION NC | SQL_ISO_OPT | SQL_NO_COMMIT |
ISOLATION CS | SQL_ISO_OPT | SQL_CURSOR_STAB |
ISOLATION RR | SQL_ISO_OPT | SQL_REP_READ |
ISOLATION UR | SQL_ISO_OPT | SQL_UNCOM_READ |
LANGLEVEL SAA1 | SQL_STANDARDS_OPT | SQL_SAA_COMP |
LANGLEVEL MIA | SQL_STANDARDS_OPT | SQL_MIA_COMP |
LANGLEVEL SQL92E | SQL_STANDARDS_OPT | SQL_SQL92E_COMP |
LEVEL levelname | SQL_LEVEL_OPT | sqlchar structure |
LONGERROR NO | SQL_LONGERROR_OPT | SQL_LONGERROR_NO |
LONGERROR YES | SQL_LONGERROR_OPT | SQL_LONGERROR_YES |
NOLINEMACRO | SQL_LINEMACRO_OPT | SQL_NO_LINE_MACROS |
(default) | SQL_LINEMACRO_OPT | SQL_LINE_MACROS |
OPTLEVEL 0 | SQL_OPTIM_OPT | SQL_DONT_OPTIMIZE |
OPTLEVEL 1 | SQL_OPTIM_OPT | SQL_OPTIMIZE |
OUTPUT filename | SQL_PREP_OUTPUT_OPT | sqlchar structure |
OWNER | SQL_OWNER_OPT | sqlchar structure |
PACKAGE | SQL_PKG_OPT | Null |
PACKAGE pkgname | SQL_PKG_OPT | sqlchar structure |
PREPROCESSOR "preprocessor-command" | SQL_PREPROCESSOR_OPT | sqlchar structure |
QUALIFIER | SQL_QUALIFIER_OPT | sqlchar structure |
QUERYOPT | SQL_QUERYOPT_OPT | SQL_QUERYOPT_0,1,2,3,5,7,9 |
RELEASE COMMIT | SQL_RELEASE_OPT | SQL_RELEASE_COMMIT |
RELEASE DEALLOCATE | SQL_RELEASE_OPT | SQL_RELEASE_DEALLOCATE |
REPLVER versn-str | SQL_REPLVER_OPT | sqlchar structure |
RETAIN NO | SQL_RETAIN_OPT | SQL_RETAIN_NO |
RETAIN YES | SQL_RETAIN_OPT | SQL_RETAIN_YES |
SQLCA SAA | SQL_SAA_OPT | SQL_SAA_YES |
SQLCA NONE | SQL_SAA_OPT | SQL_SAA_NO |
SQLERROR CHECK | SQL_SQLERROR_OPT | SQL_SQLERROR_CHECK |
SQLERROR CONTINUE | SQL_SQLERROR_OPT | SQL_SQLERROR_CONTINUE |
SQLERROR NOPACKAGE | SQL_SQLERROR_OPT | SQL_SQLERROR_NOPACKAGE |
SQLFLAG SQL92E SYNTAX | SQL_FLAG_OPT | SQL_SQL92E_SYNTAX |
SQLFLAG MVSDB2V23 SYNTAX | SQL_FLAG_OPT | SQL_MVSDB2V23_SYNTAX |
SQLFLAG MVSDB2V31 SYNTAX | SQL_FLAG_OPT | SQL_MVSDB2V31_SYNTAX |
SQLFLAG MVSDB2V41 SYNTAX | SQL_FLAG_OPT | SQL_MVSDB2V41_SYNTAX |
SQLRULES DB2 | SQL_RULES_OPT | SQL_RULES_DB2 |
SQLRULES STD | SQL_RULES_OPT | SQL_RULES_STD |
SQLWARN NO | SQL_SQLWARN_OPT | SQL_SQLWARN_NO |
SQLWARN YES | SQL_SQLWARN_OPT | SQL_SQLWARN_YES |
STRDEL APOSTROPHE | SQL_STRDEL_OPT | SQL_STRDEL_APOSTROPHE |
STRDEL QUOTE | SQL_STRDEL_OPT | SQL_STRDEL_QUOTE |
SYNCPOINT ONEPHASE | SQL_SYNCPOINT_OPT | SQL_SYNC_ONEPHASE |
SYNCPOINT TWOPHASE | SQL_SYNCPOINT_OPT | SQL_SYNC_TWOPHASE |
SYNCPOINT NONE | SQL_SYNCPOINT_OPT | SQL_SYNC_NONE |
SYNTAX | SQL_SYNTAX_OPT | SQL_SYNTAX_CHECK |
(default) | SQL_SYNTAX_OPT | SQL_NO_SYNTAX_CHECK |
TARGET compiler | SQL_TARGET_OPT | sqlchar structure |
TEXT text-str | SQL_TEXT_OPT | sqlchar structure |
TRANSFORM GROUP | SQL_TRANSFORMGROUP_OPT | sqlchar structure |
VALIDATE BIND | SQL_VALIDATE_OPT | SQL_VALIDATE_BIND |
VALIDATE RUN | SQL_VALIDATE_OPT | SQL_VALIDATE_RUN |
VERSION versn-str | SQL_VERSION_OPT | sqlchar structure |
WCHARTYPE CONVERT | SQL_WCHAR_OPT | SQL_WCHAR_CONVERT |
WCHARTYPE NOCONVERT | SQL_WCHAR_OPT | SQL_WCHAR_NOCONVERT |
(none) | SQL_NO_OPT | (none) |
See Also