Intelligent Enterprises of the 21st Century
|
DB2 UDB for iSeries supports two basic types of procedures:
External procedures are programs or service programs written in a language such as C or COBOL. The supported languages are C, C++, CL, COBOL, COBOLLE, FORTRAN, Java, PLI, REXX, RPG, and RPGLE. The CREATE PROCEDURE statement corresponding to an external procedure is used basically to name the procedures, identify the parameters used by the procedures and their corresponding data types, and the location of where to find the compiled program. The statement will not compile the program for you. SQL procedures are written entirely in SQL. SQL procedures are the focus of this book, and hence this section focuses on building SQL procedures. SQL is not just used for writing SQL procedures; it is also used to write functions and triggers. Although these routines (SQL procedures, functions, and triggers) are written entirely in SQL, when the CREATE statement for a SQL routine is issued a temporary C source file with embedded SQL statements is created. The source file is then prepared and compiled. All of this is done automatically for you. The iSeries integrated operating environment is packaged with an internal C compiler; hence, automatic compilation via the CREATE statement is possible. The SET OPTION clause of the CREATE PROCEDURE statement (Chapter 2, "Basic SQL Procedure Structure") is used to specify processing options used to create the SQL procedure. Figure C.2 shows a syntax diagram of all the valid SET OPTION processing options when creating SQL procedures. Figure C.2. Simplified SET OPTION statement syntax diagram.
.-,------------------------------------. V | >>-SET OPTION----+-ALWBLK = --alwblk-option---------+-+-------->< +-ALWCPYDTA = --alwcpydta-option---+ +-COMPILEOPT = --compile-option----+ +-COMMIT = --commit-option---------+ +-DATFMT = --datfmt-option---------+ * +-DATSEP = --datsep-option---------+ * +-DBGVIEW = --dbgview-option-------+ +-DECMPT = --decmpt-option---------+ +-DECRESULT = --decresult-option---+ +-DLYPRP = --dlyprp-option---------+ +-DYNUSRPRF = --dynusrprf-option---+ +-EVENTF = --eventf-option---------+ +-LANGID = --langid-option---------+ +-OPTLOB = --optlob-option---------+ +-OUTPUT = --output-option---------+ +-RDBCNNMTH = --rdbcnnmth-option---+ +-SQLCA = --sqlca-option-----------+ +-SQLCURRULE = --sqlcurrule-option-+ +-SQLPATH = --sqlpath-option-------+ +-SRTSEQ = --srtseq-option---------+ +-TGTRLS = --tgtrls-option---------+ +-TIMFMT = --timfmt-option---------+ * +-TIMSEP = --timsep-option---------+ * '-USRPRF = --usrprf-option---------'
Note Refer to the CREATE PROCEDURE and SET OPTION statements in the DB2 UDB for iSeries SQL Reference for a detailed description on each of the options. Some of the more commonly used ones are described here.
The options shown in Table C.2 are also valid for SQL user-defined functions and triggers, although with triggers, the DATFMT, DATSEP, TIMFMT, and TIMSEP options cannot be specified.
If you have the DB2 CLP installed and remote access to a DB2 UDB iSeries database through DB2 CONNECT, you can use the CLP to issue commands against the database as described in he previous section. For other methods of issuing SQLfor example, the CREATE PROCEDURE statementssee Appendix A, "Getting Started with DB2." |
|