DB2 Server for VSE & VM: Application Programming


Preprocessing the Program

Preprocessing does two things:

The preprocessor replaces all the SQL statements in the program with host language code that invokes the new package. The new version of the program also contains the SQL statements in comment form. The package contains information to carry out the SQL requests made by the program. The database manager follows the best access path to the data for each SQL statement in the program, using available indexes and data statistics of which the system keeps track.

When the program is run, the new code calls the system to handle each SQL statement. It also links the program to the application server and translates messages and statements between the two.

Using the SQLPREP EXEC Procedure

The SQLPREP EXEC is used in both single and multiple user mode to preprocess application programs.

The preprocessors supplied with the database manager have the following program names:

ASM
Assembler Preprocessor

C
C Preprocessor

COBOL
COBOL Preprocessor

FORTRAN
FORTRAN Preprocessor

PLI
PL/I Preprocessor

The preprocessor takes source program input from SYSIN, and produces a modified source program, a source listing, and a package in the database. The modified source program output is sent to SYSPUNCH, and the source listing to SYSPRINT. Using the SQLPREP EXEC, you can direct SYSIN, SYSPUNCH, and SYSPRINT to various virtual devices and CMS files.

The syntax diagram on page DB2 Server for VM Program Preparation Parameters lists all the parameters for the SQLPREP EXEC. An explanation of each parameter follows the figure.

Executing the SQLPREP EXEC in Single User Mode

In single user mode, the SQLPREP EXEC is executed on the database machine. (The DBname parameter indicates that you are in single user mode, and identifies the application server that you want to access.) The SQLPREP EXEC then issues an SQLSTART and passes the DBname parameter. If the preprocessor encounters no errors (warnings are permissible), a package is created or replaced on the specified application server.

Executing the SQLPREP EXEC in Multiple User Mode

Use the SQLPREP EXEC in multiple user mode to preprocess an application program on one or more application servers. Use the SQLINIT EXEC to establish the default application server. If you want to preprocess your application program on other application servers, use the DBList or DBFile parameter to specify the other application servers on which you want to preprocess your application. Either of these parameters temporarily overrides the application server specified by the SQLINIT EXEC.

For each application server specified, the SQLPREP EXEC:

  1. Establishes a link to the application server
  2. Preprocesses the application program against the application server
  3. Displays summary messages showing the results for this preprocessing step.

A package is created for each application server on which the program was successfully preprocessed. If an error is encountered during preprocessing on one of these application servers, and the ERROR parameter was not specified, a package is not created for that application server. See page *** for a discussion of the ERROR option.

When the SQLPREP EXEC is used for more than one application server, only one copy of the modified source program output is retained (the PUNCH parameter), but all the source listings (the PRINT parameter) are appended to produce a single source listing. The NOPUNCH and NOPRINT parameters may be used to suppress modified source program output and source listings, respectively.

DB2 Server for VM Program Preparation Parameters

The following are parameters for all DB2 Server for VM preprocessors unless otherwise noted.

>>-SQLPREP----+-ASM-----+--PrepParm----------------------------->
              +-C-------+
              +-COBol---+
              +-FORTran-+
              '-PLI-----'
 
>----(--PREPname=--+----------------+--package_id--------------->
                   '-collection_id.-'
 
>-----+----------------------------------+---------------------->
      +-,PrepFile=--(--| fileparms |--)--+
      '-| prepparms |--------------------'
 
>-----+----------------------------------------+--)------------->
      '-,USERid=--authorization_name/password--'
 
>-----+----------------------------------+---------------------->
      '-sysIN--(--+-| fileparms |-+---)--'
                  '-Reader--------'
 
>-----+-------------------------------------+------------------->
      '-sysPRint--(--+-| fileparms |-+---)--'
                     +-Printer-------+
                     '-Terminal------'
 
>-----+-------------------------------------+------------------->
      '-sysPUnch--(--+-| fileparms |-+---)--'
                     '-Punch---------'
 
                                     (2)  (1)
>-----+-| multiple-user-mode-parms |-----------+---------------><
      |                            (1)         |
      '-| single-user-mode-parms |-------------'
 

Notes:

  1. Valid for DB2 Server for VM only.

  2. Optional for multiple-user-mode.

 
fileparms
 
|--filename----+-------------------------+----------------------|
               '-filetype--+----------+--'
                           '-filemode-'
 

 
prepparms
 
   .-,APOST------.   .-,NOBLocK-----.
|--+-------------+---+--------------+--------------------------->
   |        (1)  |   +-,BLocK-------+
   '-,Quote------'   |         (2)  |
                     '-,SBLocK------'
 
>-----+---------------------------+----------------------------->
      '-,CCSIDGraphic--(integer)--'
 
>-----+-------------------------+---+------------------------+-->
      '-,CCSIDMixed--(integer)--'   '-,CCSIDSbcs--(integer)--'
 
                                         .-,NOCHECK--.
>-----+------------------------------+---+-----------+---------->
      '-,CHARSUB--(--+-Sbcs--+---)---'   +-,CHECK----+
                     +-Mixed-+           '-,ERROR----'
                     '-Bit---'
 
                                  (1)
>----+------------+---+--------+-------------------------------->
     |       (1)  |   '-,COBRC-'
     '-,COB2------'
 
      .-,CTOKEN--(NO)------------.
>-----+--------------------------+------------------------------>
      '-,CTOKEN--(--+-NO--+---)--'
                    '-YES-'
 
                                     .-,NOEXIST--.
>-----+--------------------------+---+-----------+-------------->
      '-,DATE--(--+-EUR---+---)--'   '-,EXIST----'
                  +-ISO---+
                  +-JIS---+
                  +-LOCAL-+
                  '-USA---'
 
      .-,EXPLAIN--(NO)------------.
>-----+---------------------------+--+-------------+------------>
      '-,EXPLAIN--(--+-NO--+---)--'  |        (3)  |
                     '-YES-'         '-,NOFOR------'
 
>----+--------------+-------------------------------------------|
     |         (4)  |
     '-,DYNALC------'
 

Notes:

  1. COBOL only (DB2 Server for VM only).

  2. Not meaningful for DB2 Server for VSE; (DB2 Server for VM only).

  3. Implied if STDSQL(89) is specified for DB2 Server for VM.

  4. COBOL, PL/I, C, and Assember only.

 
prepparms (continued)
 
   .-,NOGRaphic----.   .-,ISOLation--(RR)----------------.
|--+---------------+---+---------------------------------+------>
   |          (1)  |   '-,ISOLation--(--+-CS------+---)--'
   '-,GRaphic------'                    +-RR------+
                                        |    (2)  |
                                        +-RS------+
                                        +-UR------+
                                        '-USER----'
 
      .-,KEEP---.
>-----+---------+---+-----------------------+------------------->
      '-,REVOKE-'   '-,LABEL--(label_text)--'
 
      .-,LineCount--(60)------.
>-----+-----------------------+--------------------------------->
      '-,LineCount--(integer)-'
 
                                               .-,PERiod-----.
>-----+------------------------------------+---+-------------+-->
      |                             (2)    |   |        (2)  |
      '-,OWner--(authorization_name-----)--'   '-,COMma------'
 
      .-,PRint---.   .-,PUnch---.
>-----+----------+---+----------+------------------------------->
      '-,NOPRint-'   '-,NOPUnch-'
 
>-----+-----------------------------------+--------------------->
      |                            (2)    |
      '-,QUALifier--(collection_id-----)--'
 
      .-,RELease--(COMMIT)--------------------.   .-,REPLACE--.
>-----+---------------------------------------+---+-----------+->
      '-,RELease--(--+-COMMIT----------+---)--'   '-,NEW------'
                     |            (2)  |
                     '-DEALLOCATE------'
 
      .-,SEQuence--------.   .-,SQLApost-----------.
>-----+------------------+---+---------------------+------------>
      |             (3)  |   |           (2)  (4)  |
      '-,NOSEQuence------'   '-,SQLQuote-----------'
 
>----+---------------+------------------------------------------>
     |          (5)  |
     '-,NOSQLCA------'
 
>-----+--------------------------------------------+------------>
      '-,SQLFLAG--(--+-SAA-----------------+---)---'
                     '-89--+------------+--'
                           '-(COMPLETE)-'
 
      .-,STDSQL--(NO)----------------.
>-----+------------------------------+-------------------------->
      '-,STDSQL--(--+-NO------+---)--'
                    |    (6)  |
                    '-89------'
 
>-----+---------------------------+-----------------------------|
      '-,TIME--(--+-EUR---+---)---'
                  +-ISO---+
                  +-JIS---+
                  +-LOCAL-+
                  '-USA---'
 

Notes:

  1. COBOL and PL/I only (DB2 Server for VM only).

  2. Only meaningful for a non-DB2 Server for VM or -DB2 Server for VSE application server.

  3. C only.

  4. COBOL only.

  5. Implied if STDSQL(89) is specified.

  6. 86 is a synonym for 89.

 
multiple-user-mode-parms
 
|--+------------------------------------+-----------------------|
   +-DBFile--(--| fileparms |--)--------+
   |            .----------------.      |
   |            V                |      |
   '-DBList--(-----server_name---+---)--'
 
single-user-mode-parms
 
|---Dbname----(server_name)---+--------------------+------------>
                              '-dcssID--(dcss_id)--'
 
>-----+---------------------------------------------------+-----|
      '-LOGmode--(--+-A-+---)----+---------------------+--'
                    +-L-+        '-PARMID--(filename)--'
                    +-N-+
                    '-Y-'
 

Parameters for SQLPREP EXEC for Single and Multiple User Modes

The parameters for the SQLPREP EXEC that apply to both single and multiple user mode are described below. When choosing names within any of these parameters, avoid whatever line-end-delimiter character (normally #) is being used in your installation.

ASM

C

COBol

FORTran

PLI
This parameter identifies to the EXEC the preprocessor to be executed. This parameter is required, and must be specified first. The order in which you specify the other keywords is not important.

PREPname=package_id

PREPname=collection_id.package-id

The collection_id.package_id is the name by which the database manager identifies the package. The collection_id portion is optional, and fully qualifies the package_id and any unqualified objects referenced within the package.

If collection_id is not specified, it defaults to the user's authorization ID at the application requester site. In the database manager, however, an object's collection_id must be the same as the user's authorization ID at the application server site. If the collection_id does not match the application server authorization ID, a preprocessing error results. This restriction does not apply if the application server authorization ID has DBA authority.

The authorization ID at the application requester and application server sites is the authorization_name specified on the USERid parameter. If the USERid parameter is not specified, the authorization ID is the VM logon ID at the application requester site. In some situations, the VM logon ID is converted before it is received at the application server site. If the authorization ID is the VM logon ID, the conversion can cause the authorization IDs at each site to differ.

To avoid a situation in which the collection_id does not match the application server authorization ID, explicitly state the collection_id equal to the application server authorization ID.

For information on how to determine the authorization ID at the application server site, refer to the DB2 Server for VM System Administration and the Distributed Relational Database Connectivity Guide manuals.

USERid=authorization_name/password

The authorization_name is the name by which the application server identifies the owner of a package. The password should agree with the one established for this authorization_name by a DB2 Server for VM GRANT CONNECT statement. This information is used when executing a CONNECT statement to gain access to the application server, which determines whether proper authorization exists for the static SQL statements in the program.

If the USERid option is not specified, the VM logon user ID will be implicitly connected to the application server. All the static SQL statements in the program will have their authorization checked against the implicitly connected userid.

The USERid parameter is not supported when you are using DRDA protocol.

PrepFile=(filename)

PrepFile=(filename filetype)

PrepFile=(filename filetype filemode)

The PrepFile parameter identifies the file name (and optionally the file type and file mode) of the CMS (or SFS) file containing the list of preprocessor parameters. If filetype is not specified, PREPPP is used as the default. If filemode is not specified, A is used as the default and the first file found with the default file name and file type are used. For a detailed discussion of the options file, see Using the Preprocessor Option File.

The following parameters can be specified in the PrepFile or on the command line.

PrepParm

These parameters specify the preprocessor options.

APOST

Quote (COBOL preprocessor only)
You must include the Quote preprocessor parameter whenever you use the Quote parameter in the COBOL compiler.

Quote causes the preprocessor to use double quotation marks (") as constant delimiters in the VALUE clauses of the declarations it generates. If you do not specify this parameter, the COBOL preprocessor defaults to APOST and generates single quotation mark (') delimiters for its internal source declarations.

The use of a single or double quotation marks in SQL statements is not affected by this parameter.

NOBLocK

BLocK

SBLocK
When the BLocK parameter is specified, all eligible query cursors return results in groups of rows, and all eligible insert cursors process inserts in groups of rows. This improves the performance of programs running in multiple user mode, where many rows are inserted or retrieved. For a discussion of eligible cursors, see Using the Blocking Option to Process Rows in Groups.

When NOBLocK is specified, rows are not grouped.

SBLocK is primarily for use with application servers that support the FOR FETCH ONLY clause on the DECLARE CURSOR statement. Application servers do not support this clause, but application requesters can connect to application servers that do support FOR FETCH ONLY.

Following is a comparison of the BLocK and SBLocK options as they apply to the DB2 Server for VM preprocessors:

  • If there are COMMIT, ROLLBACK, or dynamically defined statements in a program, then:
    • With BLocK, all eligible cursors are blocked (that is, the data on which the cursor operates is transferred in groups of rows).
    • With SBLocK, the FOR FETCH ONLY clause of the DECLARE CURSOR statement can be used to select the cursors that are to be blocked. Cursors without this clause are not blocked.
  • If there are no COMMIT, ROLLBACK, or dynamically defined statements in a program, the effects of BLocK and SBLocK are the same: all eligible cursors are blocked.

Note:Only the DB2 Server for VM preprocessors turn off SBLocK blocking because of the presence of COMMIT and ROLLBACK statements. In non-DB2 Server for VM preprocessors, only the presence of dynamically defined statements has this effect.

If you want to change the BLocK option, you must recompile (or reassemble) and relink your program after preprocessing it. Preprocessing alone does not change the BLocK setting.

The blocking of FETCH statements is supported when you use the DRDA protocol, but blocking of INSERT statements is not. The blocking of INSERT statements is only supported when you use SQLDS protocol. See Using the Blocking Option to Process Rows in Groups for guidelines on deciding the programs for which to specify blocking.

CCSIDGraphic (integer)
This parameter specifies the default CCSID attribute to be used for graphic columns created in the package, if an explicit CCSID is not specified on the CREATE or ALTER statements in the package. If this parameter is not specified, the target application server uses the system default.

CCSIDMixed (integer)
This parameter specifies the default CCSID attribute to be used for character columns created with the mixed subtype in the package, if an explicit CCSID is not specified on the CREATE or ALTER statements in the package. If this parameter is not specified, the target application server uses the system default.

CCSIDSbcs (integer)
This parameter specifies the default CCSID attribute to be used for character columns created with the SBCS subtype in the package, if an explicit CCSID is not specified on the CREATE or ALTER statements in the package. If this parameter is not specified, the target application server uses the system default.

CHARSUB (Sbcs)

CHARSUB (Mixed)

CHARSUB (Bit)
This parameter specifies the character subtype attribute to be used for character columns created in the package, if an explicit subtype or CCSID is not specified. If you do not specify this parameter, the target application server uses the system default.

NOCHECK

CHECK

ERROR
If you specify the NOCHECK parameter, the preprocessor executes normally; that is, it generates modified source code and performs package functions. NOCHECK is the default.

If you specify the CHECK parameter, the preprocessor checks all SQL statements for validity and generates error messages if necessary, but does not generate a package or modified source code.

If you specify ERROR, the preprocessor executes normally except that most statement-parsing errors are tolerated; that is, it generates modified source code and performs package functions. When one of these errors is detected, the preprocessor generates an error message in the output listing and the modified source code in commented form, and continues processing. The program can be compiled and executed, but the erroneous statement cannot be executed. Use this option when you are preprocessing against multiple application servers, where at least one statement in the program is specific to an unlike application server. This option lets you successfully preprocess on each application server regardless of the presence of statements which that application server does not allow. In some situations, the ERROR option is overridden and a severe error condition results. Refer to Checking Warnings and Errors at Preprocessor Time for a discussion on debugging your SQL statements when using the ERROR option.

COB2 (COBOL preprocessor only)
This parameter enables you to use certain COBOL II functions that are supported by the COBOL II Release 3 compiler and later. Refer to Using the COB2 Parameter (DB2 Server for VM) for a list of those functions.

COBRC (COBOL preprocessor only)
If this parameter is specified, the preprocessor will generate the statement 'MOVE ZEROS TO RETURN-CODE' after it generates a call to ARIPRDI. For more information,

see Using the COBRC Parameter

CTOKEN (NO)

CTOKEN (YES)
This parameter causes the preprocessor to store a consistency token in the modified source code and the package. At run time, consistency tokens in the program's load module and package must match before the application server executes the package. CTOKEN(NO) is the default. If CTOKEN(YES) is specified, the consistency token generated by the preprocessor will be an 8-byte 390 Time-of-Day (TOD) clock value. If CTOKEN(NO) is specified, the consistency token will be 8 blanks. For a more detailed discussion of consistency tokens, see Using a Consistency Token.

DATE (EUR)

DATE (ISO)

DATE (JIS)

DATE (LOCAL)

DATE (USA)
If this parameter is specified, the output date format chosen overrides the default format specified at installation time; otherwise, all dates will be returned in the default format specified at installation time. (See the DB2 Server for VSE & VM SQL Reference manual for a description of these formats.)

NOEXIST

EXIST
If the EXIST parameter is specified, the preprocessor executes normally; that is, it generates modified source code and performs package functions. An error will be generated if objects (such as tables) referenced in statements in the program do not exist or if proper authorization does not exist.

If the NOEXIST parameter is specified, object and authorization existence is not required, and if not found, a warning will be issued. NOEXIST is the default.

EXPLAIN(NO)

EXPLAIN(YES)
This parameter specifies whether explanatory information for all explainable SQL statements in a package should be produced. EXPLAIN(NO) is the default.

If EXPLAIN(YES) is specified, each explainable SQL statement in the program is explained during preprocessing. If you specify EXPLAIN(YES), an EXPLAIN ALL is executed. The complete set of explanation tables must, therefore, be available. If they are not available, you receive an SQLCODE -649 (SQLSTATE = 42704) and preprocessing is not successful. To interpret the explanation tables, refer to the DB2 Server for VSE & VM Performance Tuning Handbook manual.

NOFOR
This parameter enables you to omit the FOR UPDATE OF clause in the static cursor query statement, and execute positioned updates to any column in the result table for which you have UPDATE authority. It is referred to in this manual as NOFOR support.
Note:This option is also implied if the STDSQL (89) or STDSQL (86) parameter is specified.

DYNALC
This parameter enables you to preprocess an application program containing FETCH statements for a cursor that is allocated by a dynamic ALLOCATE CURSOR statement.

Note:This option is only accepted by the COBOL, PL/I, C, and Assembler preprocessors.

NOGRaphic

GRaphic (COBOL and PL/I preprocessors only)
The GRaphic parameter indicates to the preprocessor whether graphic constants can be used in SQL statements and whether DBCS string format should

be validated. NOGRaphic is the default.

If GRaphic is specified, the preprocessor accepts SQL statements containing graphic constants, and checks that all strings of DBCS characters are correctly formatted.

If NOGRaphic is specified, the preprocessor does not allow graphic constants in SQL statements, and does not verify the format of strings of DBCS characters.
Note:If the DBCS parameter of the SQLINIT EXEC is specified as YES, the graphic option is not used and preprocessing occurs as though GRaphic had been specified. Refer to Initializing the User Machine for a discussion of the SQLINIT EXEC.

ISOLation (RR)

ISOLation (CS)

ISOLation (RS)

ISOLation (UR)

ISOLation (USER)
This parameter lets you specify one of the following isolation levels at which your program runs:
  • Specify RR (repeatable read) to have the database manager hold a lock on all data read by the program in the current logical unit of work. This is the default.
  • Specify CS (cursor stability) to have the database manager hold a lock only on the row or page of data pointed to by a cursor.
  • Specify UR (uncommitted read) to have the database manager allow applications to read data without locking, including uncommitted changes made by other applications.
  • RS (read stability) is not supported by application servers. For a description of RS, see the IBM SQL Reference manual.
  • Specify USER to have the application program control its isolation level.

    You cannot specify the USER option when you are using DRDA protocol (if you do, it is ignored and the isolation level defaults to CS).

See Selecting the Isolation Level to Lock Data for guidelines on choosing the isolation level for your program.
Note:If you want to change the ISOLation option, you must recompile (or reassemble) and relink your program after preprocessing it. Preprocessing alone does not change the ISOLation setting.

KEEP

REVOKE

These parameters are applicable if the program has previously been preprocessed, and the owner has granted the RUN privilege on the resulting package to some other users. Specify the KEEP parameter to have these grants of the RUN privilege remain in effect when the preprocessor produces the new package. Specify the REVOKE parameter to remove all existing grants of the RUN privilege. (These grants will also be removed if the owner of the program is not entitled to grant all the privileges embodied in the program.)

KEEP is the default.

LABEL (label_text)
This parameter specifies a label for the package. Label_text can be up to 30 characters in length; the default is spaces.

LineCount (integer)
The parameter determines how many lines per page are to be printed in the output listing. The value integer specifies the number of lines per page. The valid range for this value is 10 to 32 767. If no value is specified, or if there is an error in the specification of the LineCount parameter, then the default value of 60 is used.

OWner (authorization_name)
This parameter specifies the authorization_name of the owner of the package being created. The OWner parameter is to be used when you are preprocessing against a non-DB2 Server for VM application server. However, if you specify this parameter when preprocessing against an application server, the authorization_name must be the same as the application server authorization ID. If this parameter is not specified, the application server selects the default.

See the section on PREPname on page *** for a discussion on application server and application requester authorization IDs.

PERiod

COMma
This parameter specifies the character that delimits decimals in SQL statements. PERiod is the default.

For an application server, the only acceptable decimal delimiter is a period.

PRint

NOPRint
The PRint parameter specifies that the entire preprocessor modified source listing output is produced. The NOPRint parameter specifies that the preprocessor listing output is suppressed, except for the summary messages that are normally printed at the end. PRint is the default.

PUnch

NOPUnch
The PUnch parameter specifies that the preprocessor modified source output is produced. The NOPUnch parameter specifies that the preprocessor modified source output is suppressed.

QUALifier (collection_id)
This parameter specifies the default collection_id to be used within the package to resolve unqualified object names in static SQL statements.

The QUALifier parameter is meant to be used when preprocessing against a non-DB2 Server for VM application server. If you specify this parameter when preprocessing against an application server, the collection_id must be the same as the application server authorization ID. If you do not specify this parameter, the default is selected by the application server.

RELease (COMMIT)

RELease (DEALLOCATE)
This parameter specifies when the application server releases the package execution resources and any associated locks.

For an application server, the only acceptable action is RELEASE(COMMIT), which releases resources at the end of a logical unit of work.

REPLACE

NEW
This parameter specifies whether the package being created is new or whether it will replace an existing package that has the same name. If REPLACE is specified and no previous package exists with the same name, no error or warning is issued, and the package is created. REPLACE is the default. If NEW is specified, an error will occur if the package already exists with the same name.
Note:If NEW is specified along with KEEP or REVOKE, an error will occur.

SEQuence

NOSEQuence (C preprocessor only)

If SEQuence is specified, the preprocessor searches only columns 1 through 72 of the source file. When NOSEQuence is specified, the preprocessor assumes there are no sequence numbers in the input file and it accepts input from columns 1 to 80. SEQuence is the default.
Note:In the latter case, you must use the NOSEQ and MARGINS (1,80) C compiler options when compiling the modified source.

SQLApost

SQLQuote (COBOL preprocessor only)
This parameter specifies the character that delimits strings (quoted literals) in SQL statements. SQLApost and SQLQuote are optional parameters. SQLApost is the default.

For an application server, the only acceptable string delimiter is a single quotation mark.

NOSQLCA
This parameter allows you to declare an SQLCODE without declaring all of the SQLCA structure. It is referred to as NOSQLCA support in this manual.

If you request NOSQLCA support, it is your responsibility to make sure that there are no explicit declarations of the SQLCA in your application program. For more information on using SQLCODE without the SQLCA, refer to Using the Automatic Error-Handling Facilities.
Note:This option is also implied if the STDSQL(89) or STDSQL (86) parameter is specified.

SQLFLAG (SAA)

SQLFLAG (89)

SQLFLAG (89(COMPLETE))
This parameter invokes Flagger, a function that flags those static SQL statements that do not conform to the SQL-89 standard or IBM's Systems Application Architecture* (SAA*) standard on an SQL dialect. If you specify SAA, it provides syntax checking against the SAA Database Level 1 standard. If you specify 89, it will provide syntax checking against the SQL-89 standard. If you specify 89(COMPLETE), it will provide both syntax and semantics checking against the SQL-89 standard. Note that you cannot check both SAA and SQL-89 in the same preprocessor run.

See Using the Flagger at Preprocessor Time for more details on this facility, including an explanation of the SQL-89 standard.

STDSQL (NO)

STDSQL (89)
STDSQL refers to the SQL Standard that has been implemented in the user's application program. If NO is specified or the STDSQL parameter is not used, the preprocessor uses DB2 Server for VM standards. If 89 is specified, functions specific to ANS SQL standard 89 are also provided by the preprocessor. STDSQL(NO) is the default. These functions consist of the following support:
  • NOSQLCA
  • NOFOR

Note:STDSQL(86) is a synonym for STDSQL(89).

TIME (EUR)

TIME (ISO)

TIME (JIS)

TIME (LOCAL)

TIME (USA)
If this parameter is specified, the output time format chosen overrides the default format specified during installation. If it is not specified, all times will be returned in the default format that was specified during installation. (See the DB2 Server for VSE & VM SQL Reference manual for a description of these formats.)

sysIN
Two choices exist:
  1. sysIN( filename)

    sysIN( filename filetype )

    sysIN( filename filetype filemode )

    This optional parameter identifies the filename (fn), and optionally the filetype (ft) and filemode (fm), of the CMS file containing the preprocessor source input. The filetype specification defaults to the following:

    ASM
    ASMSQL

    C
    CSQL

    COBOL
    COBSQL

    FORTRAN
    FORTSQL

    PL/I
    PLISQL

    The file mode specification will default to A.

    The following CMS FILEDEF command is issued for the preprocessor source input file:

    FILEDEF SYSIN DISK fn ft fm (RECFM FB LRECL 80 BLOCK 800)
    
  2. sysIN( Reader )

    This specification of the sysIN optional parameter identifies that the preprocessor source input file is a virtual reader file. The following CMS FILEDEF command is issued for the preprocessor source input file:

    FILEDEF SYSIN READER (RECFM F LRECL 80)
    

Note:If the sysIN parameter is not specified, you must enter a CMS FILEDEF command for the preprocessor source input (ddname=SYSIN) before issuing the SQLPREP EXEC.

sysPRint
Five choices exist:
  1. sysPRint( filename)

    sysPRint( filename filetype )

    sysPRint( filename filetype filemode )

    This optional parameter identifies the filename (fn) and optionally the filetype (ft) and filemode (fm) of the CMS file containing the preprocessor source output listing. The filetype specification defaults to LISTPREP, and the filemode specification to A.

    If this form of the sysPRint parameter is supplied, the following CMS FILEDEF command is issued for the preprocessor source output listing file:

    FILEDEF SYSPRINT DISK fn ft fm . . .
                (RECFM FBA LRECL 121 BLOCK 1210 DISP MOD)
    
  2. sysPRint( Printer )

    This specification of the sysPRint optional parameter identifies that the preprocessor source output listing file is directed to a virtual printer file. If sysPRint(Printer) is specified, the following CMS FILEDEF command is issued for the preprocessor source output listing file:

    FILEDEF SYSPRINT PRINTER (RECFM FA LRECL 121)
    
  3. sysPRint( Terminal )

    This specification of the sysPRint optional parameter identifies that the preprocessor source output listing file is directed to the console terminal. If sysPRint(Terminal) is specified, the following CMS FILEDEF command is issued for the preprocessor source output listing file:

    FILEDEF SYSPRINT TERM (RECFM FA LRECL 121)
    
  4. If the sysPRint parameter is not specified and the preprocessor source input file was assigned to the virtual reader, then the preprocessor source output listing file is assigned to the virtual printer by the CMS FILEDEF command described in item 2 above.
  5. If the sysPRint parameter is not specified and the preprocessor source input file was assigned to a CMS file, then the following default CMS FILEDEF command is issued for the preprocessor source output listing file:
    FILEDEF SYSPRINT DISK fn LISTPREP A . . .
                (RECFM FBA LRECL 121 BLOCK 1210 DISP MOD)
    

    In this example, fn is the file name specification used for the preprocessor SYSIN file, and file mode is defaulted to A.

Note:If sysPRint and sysIN information is not specified, then the user must issue a CMS FILEDEF command for the preprocessor source output listing file (ddname=SYSPRINT) before issuing the SQLPREP EXEC.

sysPUnch
Four choices exist:
  1. sysPUnch( filename)

    sysPUnch( filename filetype )

    sysPUnch( filename filetype filemode )

    This optional parameter identifies the filename (fn) and optionally the filetype (ft) and filemode (fm) of the CMS file containing the preprocessor modified source output. The file type specification will default to a value based on the preprocessor invoked as follows:

    ASM
    ASSEMBLE

    C
    C

    COBOL
    COBOL

    FORTRAN
    FORTRAN

    PL/I
    PLIOPT

    The file mode specification will default to A.

    If this form of the sysPUnch parameter is supplied, the following CMS FILEDEF command is issued for the preprocessor modified source output file:

    FILEDEF SYSPUNCH DISK fn ft fm . . .
                (RECFM FB LRECL 80 BLOCK 800)
    
  2. sysPUnch( Punch )

    This specification of the sysPUnch optional parameter identifies that the preprocessor modified source output file is directed to a virtual punch file. If sysPUnch(Punch) is specified, the following CMS FILEDEF command is issued for the preprocessor modified source output file:

    FILEDEF SYSPUNCH PUNCH (RECFM F LRECL 80)
    
  3. If the sysPUnch parameter is not specified and the preprocessor source input file was assigned to the virtual reader, then the preprocessor modified source output file is assigned to the virtual punch with the CMS FILEDEF command described above in item 2 above.
  4. If the sysPUnch parameter is not specified and the preprocessor source input file is assigned to a CMS file, then the following default CMS FILEDEF command is issued for the preprocessor modified source output file:
    FILEDEF SYSPUNCH DISK fn ft A . . .
                (RECFM FB LRECL 80 BLOCK 800)
    

    In this example, fn is the file name specification used for the preprocessor source input file, and file mode is defaulted to A. ft is the default file type as determined by the previously mentioned method.

Note:If sysPUnch and sysIN information is not specified, then the user must issue a CMS FILEDEF command for the preprocessor modified source output file (ddname=SYSPUNCH) before issuing the SQLPREP EXEC.

Parameters for SQLPREP EXEC for Single User Mode Only

The parameters for the SQLPREP EXEC that apply only to single user mode are:

DBname(dbname)
This mandatory parameter identifies the name of the application server to be accessed by the SQL statements in the preprocessor source input file.

This parameter is used as the DBname parameter for the SQLSTART EXEC that is executed when the database manager is started in single user mode. The system initialization parameters SYSMODE=S and PROGNAME=progname (where progname varies according to which preprocessor is being invoked) will also be supplied in the PARM parameter of the SQLSTART EXEC.

dcssID(dcssid)
This parameter identifies the method by which all DB2 Server for VM modules will be loaded for execution. If this parameter is specified, it will be used as the dcssID parameter for the SQLSTART EXEC. If this parameter is omitted, the dcssID parameter will not be passed to the SQLSTART EXEC.

Refer to the DB2 Server for VM System Administration manual for more information.

LOGmode (Y)

LOGmode (A)

LOGmode (N)

LOGmode (L)
This parameter identifies the value to be used for the DB2 Server for VM initialization LOGmode parameter when the database manager is started in single user mode. If this parameter is omitted, the LOGmode parameter will not be supplied as an initialization parameter to the SQLSTART EXEC.

Refer to the DB2 Server for VM System Administration manual for more information.

PARMID (filename)
This parameter identifies the file name of a CMS file that contains DB2 Server for VM initialization parameters. If this parameter is omitted, the PARMID parameter will not be passed as a parameter to the SQLSTART EXEC.

Refer to the DB2 Server for VM System Administration manual for more information.

Parameters for SQLPREP EXEC in Multiple User Mode Only

The parameters for the SQLPREP EXEC that apply only to multiple user mode are:

DBFile (filename)

DBFile (filename filetype)

DBFile (filename filetype filemode)
This optional parameter specifies the file name, the file type, and optionally the file mode of a CMS file containing a list of application servers on which the program will be preprocessed. If filetype is not specified, PREPDB will be used as the default file type. If filemode is not specified, the first file with the given filename and filetype will be used.

The rules governing the format of the CMS file are as follows:

|DBList (server_name)
|This optional parameter specifies a list of application servers on which |the program will be preprocessed.

|Note that this parameter and the DBFile |

| | parameter are mutually exclusive.

Preprocessing with an Unlike Application Server

The SQLPREP EXEC accepts only those parameters and options which are listed in this manual. Some of those options are only meaningful to one or more of the other IBM relational database server or servers. The SQLPREP EXEC does not filter out options that are not applicable to an application server before sending them to that application server.

Equivalent parameters and options for IBM relational database products are given in the IBM SQL Reference manual. For example, the VALIDATE(BIND) parameter in the DB2 product for MVS and the EXIST parameter for the DB2 Server for VM product are equivalent preprocessing parameters.

When the DB2 Server for VM system acts as an application server and receives an unsupported preprocessing parameter value, it returns an error message to the application requester.

Using the Preprocessor Option File

Instead of specifying all the preprocessing parameters (found in PrepParm) in the SQLPREP EXEC you can use an options file. Maintaining a set of standard options files has several advantages: they can save you time; they can ensure consistent use of preprocessing parameters; and the number of parameters that you can use is not limited by the number of positions on the command line.

You can use a preprocessor options file by including the PrepFile parameter when you issue the PREP command. The file itself can contain only one preprocessor parameter per line. If more are found an error message is returned. Blank lines are ignored, and parameters may be in either upper or lower case. Comments may be inserted into the options file by placing an asterisk (*) to the left of the comment. Everything to the right of the asterisk is ignored. The file must be fixed blocked and must have a record length of 80 bytes. Figure 40 is an example of a preprocessor option file.

Figure 40. An Example of a Preprocessor Option File

* prep parameters for program SAMPLE
      ISOL(CS)          *cursor stability isolation level
      TIME(ISO)
      BLOCK             *indicate inserts and retrieves in groups

Using the Flagger at Preprocessor Time

The Flagger is invoked at preprocessor time by the optional parameter SQLFLAG It provides an auditing function on the static SQL statements in the host program. This function is independent of the other preprocessor functions, and has no bearing on whether the preprocessor run will complete satisfactorily.

The audit compares the static SQL statements with the SAA standard or the SQL-89 standard. SQL-89 is a collective term that implies support of SQL as defined by the Federal Information Processing Standards (FIPS) 127-1. It includes:

In addition to basic syntax checking against SQL-89, Flagger optionally performs semantics checking against SQL-89. This includes some integrity checking between the SQL statements and the database. For example, it checks:

Any statements that do not conform to the standards are flagged in the form of information messages in the preprocessor output listing. Flagger, however, does not force you to comply with the standards. The purpose of Flagger is to provide guidance for those users who want to conform to these standards, so that they can have SQL consistency across operating environments.
Note:The DB2 Server for VM product is a superset of the SQL-89 standard without the Integrity Enhancement feature. For example, the datetime data types are not part of SQL-89 and the CONNECT statement is not part of SQL-89. The use of extensions such as these will generate information messages for deviations from the standard specified in the SQLFLAG parameter.

The Flagger messages generated at preprocessor time range from ARI5500 to ARI5599, and are further classified as follows:

  1. ARI5500-ARI5539 and ARI5570-ARI5599 are information messages that indicate that an extension to the SQL-89 standard (nonconformance) has been found. These start with "FLAGGER message."
  2. ARI5540-ARI5569 are warning messages that indicate a failure on the part of Flagger itself.

    In this event, SQL-89 semantics checking will be turned off and its syntax checking may or may not be turned off, depending on the nature of the failure. However, the preprocessor run itself will continue, and any inconsistencies discovered by Flagger prior to the failure will be included in the output listing of the run.

Improving Performance Using Preprocessing Parameters

When preprocessing your program, you can specify two performance parameters, the SBLocK/BLocK/NOBLocK option, and the ISOLation level option. The format and use of these options within the SQLPREP EXEC was discussed under Preprocessing the Program. The next section discusses when you would want to specify each of these options.

(Other performance considerations are discussed in the DB2 Server for VSE & VM Database Administration manual.)

Selecting the Isolation Level to Lock Data

The database manager puts locks on data that your program works with, to keep other users from reading or changing that data. You can specify either to lock all the data that the current logical unit of work (LUW) has read, to lock just the row or page of data that a cursor is currently pointing to, or to not lock any data being read. This is called specifying the isolation level of the lock.

The isolation level used by an application is set using the ISOLation preprocessing parameter. On SELECT, SELECT INTO, INSERT, searched UPDATE, and DELETE statements, the WITH clause may be specified to override the value specified on the preprocessing parameter.

If you choose to put a lock on all the data that your program's current LUW has read, this is called specifying isolation level repeatable read.

Repeatable read locks are held until the end of the LUW. If you choose to put a lock on just the row or page of data that your cursor is pointing to, then you are specifying isolation level cursor stability. With cursor stability locking, when the cursor moves, the system frees all the data previously read by the program that was held by the lock. If you choose not to lock the data that your program will read, this is called specifying isolation level uncommitted read. With uncommitted read, no locks are held on the data being read, and as a result, the data can be changed by other applications.

Both repeatable read and cursor stability provide you with the following data isolation from other concurrent users:

In addition to the above, repeatable read locking provides you with the following data isolation from other concurrent users:

This extra isolation has its drawbacks, however. When you specify repeatable read for data in public dbspaces with PAGE or ROW level locking, you reduce the concurrency of the data. This means that other users may be locked out from the data for a long time, causing delays in their programs' executions.

If you specify cursor stability instead, you reduce these locking problems by making the data more available. With this isolation level, the system does not hold the locks as long. After a cursor has moved past a row or page of data, the lock on that data is dropped. This increases concurrency so that other users can access data faster.

Cursor stability can, however, cause some data inconsistencies. For instance:

  1. If a user's LUW reads data twice, it can get different results. This could happen if another user modifies the data and commits the changes between read operations.
  2. A modification based on a prior reading can be incorrect. This can occur if another LUW modifies the rows that a user has read and commits the changes before that user can do the modification. (Note that when the user is retrieving data in application programs, the only row that is safe from modification is the one that is currently being pointed to by a cursor.)
  3. If an SQL statement in the user's LUW is traversing a table by way of an index, the user might find the same row twice. (This case applies to FETCH cursors, searched INSERT by way of subselect, and searched UPDATE with subselect that traverse a table by way of an index.) This can occur because, after the user's statement reads the row the first time, another user can update the column value that is indexed and commit the change. The change could cause the committed row to be ahead of the row currently being retrieved by the statement. The first user's statement would then find the row again with its updated index column value.
  4. If an SQL statement in the LUW is traversing a table by way of an index, it can fail to find a row (or rows) even if the row meets the selection criteria. (This situation applies to FETCH cursors, Searched DELETE, Searched INSERT by way of the subselect, and Searched UPDATE by way of the subselect that traverse a table by way of an index.) This can occur because while the LUW is reading, another user modifies the indexed column in the row and commits the change (as above). The change could cause the committed row to be behind the row the user's statement is currently reading. Thus, the statement would not find the row, even if the row met the selection criteria.
  5. If you enter a SELECT statement to retrieve a single row, a cursor is opened when the system processes the statement and is closed when the row is returned. All PAGE and ROW level locks are released when the cursor is closed; therefore, no locks are held after the row is returned. For single-row processing using a SELECT statement with a fully qualified unique index, a cursor is not opened and again no locks are held once the row has been returned. As a result, applications which update a selected column based on the values retrieved may have unexpected results because the lock was not held for the duration of the LUW. For example:
    HOST_EMPNO = '000250'
    EXEC SQL  SELECT SALARY                /* HOST_SALARY is 19180           */
                INTO :HOST_SALARY
                FROM EMPLOYEE
                WHERE EMPNO = :HOST_EMPNO;
    HOST_SALARY = HOST_SALARY + 1000;      /* HOST_SALARY increased to 20180 */
     
    EXEC SQL  UPDATE EMPLOYEE              /* UPDATE SALARY in EMPLOYEE      */
                SET SALARY = :HOST_SALARY; /* TABLE with HOST_SALARY   */
                WHERE EMPNO = :HOST_EMPNO;
    EXEC SQL  SELECT SALARY                /* HOST_SALARY may not be 20180   */
                INTO :HOST_SALARY          /* because lock was not held for*/
                FROM EMPLOYEE             /* the duration of the LUW        */
                WHERE EMPNO = :HOST_EMPNO;
    COMMIT WORK;
    

    In the previous example, it is possible that two or more users could read the salary column with the same value at approximately the same time. They would then each increment the number and issue the UPDATE statement. The second user would wait for the first user's update to finish, and then overwrite it with the same number.

Unlike RR or CS, uncommitted read does not provide any data isolation from other concurrent users. Like CS though, concurrency is improved, although at the risk of data inconsistency. UR can cause similar data inconsistencies as those described for CS and should only be used when it is not necessary that the data you are reading be committed.

An application using isolation level UR is still restricted to access only data for which it has authorization. However, because it will be able to read uncommited changes, it will be able to read additional rows which an application, with the same authorization but using RR or CS, could not. This is illustrated by the following example.

Rows of table:
A
B
C
<---D
E

Scenario: 1
U1 reads (using UR) A B
U2 inserts D
U1 continues reading C D E
U2 rolls back
-- U1 has read a non-existent row

   

 

Scenario: 2
U1 reads (using CS) A B
U2 inserts D
U1 continues reading C, must wait to read D
U2 rolls back
U1 continues reading E


 

Note:In scenario 1, U1 has read an extra row which U1 in scenario 2 could not.

 


 

When should each of these options be chosen for your program? Usually, you should specify repeatable read locking. Only use cursor stability if your program causes or will cause locking problems. For instance, you would probably want to use cursor stability for transactions that perform terminal reads without performing a COMMIT or ROLLBACK, or programs that do bulk reading, because it is handy for programs that browse through large amounts of data. For programs that perform commits or rollbacks before issuing terminal reads, you should use repeatable read locking, because they probably will not cause locking problems. Also, any application that needs to protect itself against updates should also use repeatable read locking. For programs where concurrency is wanted, for example, data being queried simultaneous to being updated, you would use uncommitted read locking. Of course, this would be for applications where data integrity was not important because the data being read may not necessarily have been committed. For single row processing (UPDATE and DELETE, for example) by way of unique indexes, cursor stability performs no better, and may perform worse, than repeatable read isolation.

One additional isolation level exists in DRDA protocol: Read Stability (RS). RS is not supported by a DB2 Server for VSE & VM application server, but it is recognized as a valid preprocessing option by the database manager. For more information on this option, refer to the DB2 Server for VSE & VM SQL Reference manual.

Upon receiving a request for the RS isolation level, an application server escalates it to RR and proceeds without indicating the escalation to the application requester.

You can also mix isolation levels,

to have your program set, change, and control its own isolation level as it is running.

You can specify mixed isolation level with the USER option of the ISOLation preprocessor parameter, as detailed under Preprocessing the Program.

If you choose this option, your program must pass the isolation level value to the application server by a program variable. It must declare a one-character program variable and must set this variable to the desired isolation level value before executing SQL statements. For repeatable read, your program should set this variable to R; for cursor stability, the variable should be set to C; and for uncommitted read, the variable should be set to U. The program can change the variable at any time so that subsequent SQL statements are executed at the new isolation level value. However, if your program changes the isolation level while a cursor is OPEN, the change does not take effect for operations on that cursor until it has been closed and opened again. That is, until the cursor is closed all operations on that cursor are executed at the isolation level value that was in effect when the cursor was opened. Note that the changed isolation level will be used (without error) for SQL statements not referencing the opened cursor.

If the program sets the isolation level variable to a value other than C, R or U, or if it fails to initialize the variable, the system stops execution and returns an error code in the SQLCA.

Figure 41 shows the isolation level variable name for each of the host languages.

Figure 41. Variable Names for Specifying Mixed Isolation Levels
Host Language Variable Name Example
assembler SQLISL SQLISL DS CL1
C SQLISL char SQLISL;
COBOL SQL-ISL 01 SQL-ISL PIC X(1).
FORTRAN SQLISL CHARACTER SQLISL
PL/I SQLISL DCL SQLISL CHAR(1);
Note:If you forget to declare the isolation level variable in a PL/I program, the PL/I compiler issues an informational message which can, in some environments, be suppressed.

If you preprocess using DRDA protocol, the USER isolation level option is not supported. In DRDA protocol, the application requester changes any USER isolation level request to CS. If you preprocess using SQLDS protocol but later invoke the package using DRDA protocol, the application server defaults to the CS isolation level at run time. If a package is preprocessed and invoked using SQLDS protocol, the isolation level setting is not affected.

Isolation level cursor stability or uncommitted read only has meaning for data in public dbspaces with ROW or PAGE level locking. Data in private dbspaces or in public dbspaces with DBSPACE level locking always uses repeatable read isolation. However, programs which access such data and do not require repeatable read should be preprocessed with cursor stability or uncommitted read. The data concurrency requirements might change and cause the data to be moved to a public dbspace with PAGE or ROW level locking. In this case, the program would not need to be repreprocessed to run at isolation level cursor stability or uncommitted read.

To use the features of CS or UR, data must reside in public dbspaces with PAGE or ROW level locking. DML statements against private dbspaces or public dbspaces with PAGE or ROW level locking under isolation level CS or UR are handled the same as if isolation level RR were used.

When the system uses a dbspace scan (that is, does not use an index) to access a table in a dbspace with ROW level locking using isolation level cursor stability, the effect is the same as repeatable read. That is, no other LUW can update the table until the logical unit of work performing the dbspace scan ends. Also, if an LUW is updating a table, another LUW (using cursor stability) cannot access that table with a dbspace scan until the updating LUW ends. This reduced concurrency for dbspace scans does not apply to tables in dbspaces with PAGE level locking, or to accessing tables through indexes. Because most database accesses will typically use indexes, the reduced concurrency caused by dbspace scans should not occur frequently.

The isolation level specification affects UPDATE and DELETE processing as well as SELECT processing. For UPDATE and DELETE processing, the system acquires UPDATE locks. UPDATE locks can be acquired for both cursor stability and repeatable read isolation level settings. If the user actually wants to update or delete the data, the UPDATE lock is changed to an EXCLUSIVE lock; otherwise, the UPDATE lock is changed to a SHARE lock.

Note the following about UPDATE LOCKS:

Internally generated SELECT, UPDATE, or DELETE statements use cursor stability locking no matter what the isolation level is set to. (See Enforcing Referential Integrity for information on these statements). Conversely, data definition statements such as CREATE, ACQUIRE, or GRANT, use repeatable read locking no matter what the isolation level is set to. These statements, therefore, should not play a role in your choice of isolation level.
Note:Catalog access for SQL statement preprocessing is also always done with repeatable read locking.

Using the Blocking Option to Process Rows in Groups

You can insert and retrieve rows in groups or blocks, instead of one at a time. This is called specifying the blocking option. Specifying one of the blocking options (SBLock or BLock), improves performance for DB2 Server for VM application programs that:

You can specify the blocking option as a DB2 Server for VM preprocessor parameter, or as an option on the CREATE PACKAGE statement. After a program has been preprocessed with the blocking option, all eligible cursor SELECTs and all eligible cursor INSERTs within the program are blocked. You do not have to specify a block size or block factor.

When using DRDA protocol, you can specify the block size by using the SQLINIT EXEC. Performance is closely related to block size when using DRDA protocol.

The programs that would benefit the most from blocking are those that do multiple-row inserts (with PUT statements) or multiple-row SELECTs (with FETCH statements). In both cases, a cursor must be defined. (See Retrieving or Inserting Multiple Rows; for more information on cursors.) Thus, a general rule for blocking is USE BLOCKING FOR PROGRAMS THAT DECLARE CURSORS.

A program can use either PUT or FETCH statements without being sensitive to whether the system is blocking. These statements work regardless of whether you specified the blocking option. What information is returned in the SQLCA after each PUT or FETCH, however, depends on whether blocking is in effect or not.

Remember that when you preprocess a program with the blocking option, all eligible INSERT and SELECT cursors are blocked. You cannot specify blocking for just INSERTs or for just SELECTs. If you specify the blocking option, it automatically applies to both.

When are INSERT or SELECT statements not eligible for blocking? The database manager sometimes overrides blocking for a particular cursor because of storage limitations in the virtual machine, or because of SQL statement ineligibility. The following SQL statements are ineligible for blocking and cause blocking to be overridden automatically for the cursors they refer to:

The system also disqualifies blocking if it cannot fit at least two rows into a block. (The number of rows that fit into a block may differ from one PUT/FETCH statement to the next, even when such statements operate on the same table.)

The system does not halt the program when it overrides blocking. Instead, in each of the above cases, it sets a warning flag in the SQLCA. The warning can be detected by using WHENEVER SQLWARNING in the program. See Using the Automatic Error-Handling Facilities for more information on the SQLCA and the SQL WHENEVER declarative statement.
Note:The DECLARE CURSOR... statement can also be written without the FOR UPDATE OF clause, even though positioned updating is subsequently done. (This is allowed when NOFOR support is invoked at preprocessor time.) In this case, blocking is also ineligible.

The system also overrides blocking for all programs running in single user mode. In this instance, the system does not usually return a warning to the SQLCA. A warning is returned to the SQLCA for programs running in single user mode if:

The DBS Utility may get blocking ineligible warnings when it is run in single user mode because it is preprocessed with the BLocK option, but uses PREPARE to process SELECT statements.
Note:Always CLOSE a cursor before issuing a COMMIT statement, especially when blocking. If you commit changes before closing an insert cursor that is being blocked, you receive an error. If you are using DRDA protocol and if the HOLD option is in effect, your application does not have to close the cursor before committing the LUW.

Imposing Blocking Restrictions
  1. The length of host variables in the SQLDA or host_variable_list cannot be changed after the first FETCH or PUT when blocking.
  2. The data type of host variables in the SQLDA or host_variable_list cannot be changed after the first FETCH or PUT when blocking.
  3. The number of data elements in the host_variable_list or SQLDA cannot be changed after the first FETCH or PUT when blocking.
  4. If a COMMIT is issued while a blocking PUT cursor is open, an error occurs.

When blocking is active, a single SQLCA is returned with each block of rows. This SQLCA is returned to the application program with the last row in the block. However, for the final block of rows, the FETCH that returns the "not found" condition (SQLCODE = +100 and SQLSTATE='02000') will return the SQLCA. (For more information on SQLCA refer to Using the SQLCA). This has the following implications for application programming:

Using the Blocking Option in DRDA Protocol

When the database manager is acting as an application requester in DRDA protocol, no blocking is provided on a PUT statement. Each PUT statement results in the execution of an INSERT statement. Blocking of inserts is not supported when your application is accessing a remote application server using DRDA protocol. If you are loading a large amount of data while using DRDA protocol, transfer the data through some other means, and then use the local utility to load it into the application server.

In DRDA protocol, the block size for FETCH statements is determined by the QRYBLKSIZE parameter in SQLINIT. For information on SQLINIT, refer to the DB2 Server for VSE & VM Database Administration manual.

Using the INCLUDE Statement

Including External Source Files

The inclusion of external source files is indicated to the DB2 Server for VM preprocessor by an embedded SQL statement, the INCLUDE statement, in the user's source code. This statement can appear anywhere that an SQL statement can appear, and indicates within the source code where the external source is to be placed. The syntax for the INCLUDE statement is as follows:



>>-INCLUDE--text_file_name-------------------------------------><
 

where text_file_name is a 1- to 8-character identifier that identifies the file name of the external source file. Text_file_name cannot be delimited by double quotation marks. The first character must be a letter (A-Z), $, #, or @; the remaining characters must be letters, digits (0-9), $, #, @, or underscore (_), unless further restricted by the operating system. Also, text_file_name cannot be SQLCA or SQLDA, because these are special INCLUDE keywords.

Including Secondary Input

You can use the INCLUDE statement to obtain secondary input from a CMS file. If a source program input to a DB2 Server for VM preprocessor uses the INCLUDE facility, any files to be used as secondary input must be accessed by the user. A search of all accessed CMS mini-disks for the file name and file type is conducted in standard CMS search order and the first match determines the file mode. This filename, filetype, and filemode are used as the secondary input or external source. The CMS file containing the secondary input statements must be fixed-length, 80-character records.

The INCLUDE statement causes input to be read from the specified file name until the end of the file, at which time the SYSIN input resumes. The file to be included must have an appropriate file type:

ASMCOPY
assembler

CCOPY
C

COBCOPY
COBOL

FORTCOPY
FORTRAN

PLICOPY
PL/I

The file mode is determined by the search of the virtual machine's accessed minidisks. If the INCLUDE statement specifies a file name that is not located on any user-accessed CMS mini-disk, an error will result.

Secondary input must not contain preprocessor INCLUDE statements other than INCLUDE SQLDA or INCLUDE SQLCA, although it may contain both host language and SQL statements. If an INCLUDE statement is encountered, an error will result.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]