The assembler preprocessor puts all the variables and structures it generates within a DSECT named SQLDSECT. The preprocessor also generates a fullword variable called SQLDSIZ, which contains the length of the SQLDSECT DSECT in bytes. Thus, for all assembler programs, you must provide an area of size SQLDSIZ, set the area to zero, and provide addressability to the SQLDSECT DSECT.
Figure 100 shows DB2 Server for VSE sample code that does just that for VSE batch and ICCF applications:
Figure 100. Acquiring the SQLDSECT Area for VSE Batch and ICCF Applications - (DB2 Server for VSE)
TESTNAME CSECT STM 14,12,12(13) BALR regx,0 USING *,regx L 0,SQLDSIZ GETVIS ADDRESS=(1),LENGTH=(0) LR regy,1 USING SQLDSECT,regy (add code to zero the area) . . . END This area is needed only until the program is finished executing all SQL |
DB2 Server for VM |
---|
Use CMSSTOR OBTAIN macros to acquire storage. If you want to use CMS OS or DOS simulation, you can use the following macros:
Note that SQLDSIZ is in bytes, and that you need the length in doublewords for the CMSSTOR macro. |
Figure 101 shows sample DB2 Server for VM pseudocode that can be used to acquire the SQLDSECT area.
Figure 101. Acquiring a Dynamic SQLDSECT Area - DB2 Server for VM
TESTNAME CSECT STM 14,12,12(13) BALR regx,0 USING *,regx LA regy,7(0,0) A regy,SQLDSIZ SRL regy,3 (save computed doubleword length for CMSSTOR RELEASE) LR 0,regy CMSSTOR OBTAIN,DWORDS=(0) LR regz,1 USING SQLDSECT,regz (add code to zero the area) . . . (add code to free storage by CMSSTOR RELEASE) END This area is needed only until the program is finished executing all SQL |
If you know the approximate size of the SQLDSECT that will be generated in your program, you can define an area (AREA DS CLxxxx) within your program and use this as your SQLDSECT area. Your program will not be re-entrant if you use this method.
The preprocessor generates the code to calculate SQLDSIZ directly in front of the last statement in the source program. Make the last statement an END statement.
If the assembler preprocessor is run with the CHECK option, SQLDSECT and SQLDSIZ are not generated. Errors occur if you attempt to assemble the output generated by the preprocessor when the CHECK option is specified. See Chapter 4, Preprocessing and Running a DB2 Server for VM Program or Chapter 5, Preprocessing and Running a DB2 Server for VSE Program for more information about preprocessor parameters.
For DB2 Server for VSE CICS/VSE transactions, Figure 100 does not apply. Figure 102 is a CICS/VSE example.
Figure 102. Acquiring the SQLDSECT Area for CICS/VSE Applications - DB2 Server for VSE
label1 EQU regx EXEC CICS GETMAIN SET(label1) LENGTH(SQLDSIZ+2) INITIMG(00) USING SQLDSECT,regx |
Note: | You must provide a save area for all assembler programs. |