gtpa3m0p | Application Requester User's Guide |
The DBRM consists of the SQL statements and variables pertaining to a particular program. The DB2 system uses the DBRM to optimize application program interaction. If the DBRM is bound by DB2 before running the application, the DBRM is considered statically bound. The DBRM can be bound at run time when it is combined with its ISO-C program by the postprocessor before the program is compiled. When the application runs, the DBRM is sent to the DB2 system to be bound.
The contents of the DBRM represent the variables, framework, and generated SQL calls required by the DB2 system when processing the SQL commands sent from the TPF system. The dbrm_array is a large character array that carries the variable portion and is added to the program source by the postprocessor. SQL statements bound by /***$$$ and $$$***/ are from the application program. They are followed by generated statements to use at run time. Each application that contains SQL statements must include the SQLCA and identify EXEC SQL INCLUDE SQLCA and EXEC SQL BEGIN DECLARE SECTION variable declarations.
static const char dbrm_array[] = { '\xC4','\xC2','\xD9','\xD4','\x00','\x00','\x00','\xA0', DBRM '\xC2','\xD9','\xC1','\xD1','\x40','\x40','\x40','\x40', BRAJ '\xD8','\xE7','\xD4','\xC1','\xD9','\xC6','\x40','\x40', QXMARF '\x15','\xB5','\x7E','\x06','\x02','\x85','\x14','\x80', '\x07','\x00','\xC4','\x00','\x00','\x02','\x00','\x00', '\x00','\x00','\x00','\x00','\x00','\x00','\x00','\x00', '\x00','\x00','\x00','\x00','\x00','\x00','\x00','\x00',
·
·
·
'\xC4','\xC5','\xC3','\xD3','\xC1','\xD9','\xC5','\x40', DECLARE '\xC3','\xF2','\x40','\xC3','\xE4','\xD9','\xE2','\xD6', C2 CURSO: '\xD9','\x40','\xC6','\xD6','\xD9','\x40','\xE2','\xC5', R FOR SE '\xD3','\xC5','\xC3','\xE3','\x40','\xC3','\xE4','\xE2', LECT CUS '\xE3','\xD5','\xD6','\x40','\x6B','\x40','\xD5','\xC1', T,N O NA '\xD4','\xC5','\x40','\x6B','\x40','\xD7','\xC2','\xC1', ME , PBA '\xD3','\x40','\x6B','\x40','\xD4','\xC1','\xE7','\xC2', L , MAXB '\xC1','\xD3','\x40','\xC6','\xD9','\xD6','\xD4','\x40', AL FROM '\xE2','\xC1','\xC1','\xC9','\xC4','\x40','\x4B','\x40', SAAID . '\xE2','\xC1','\xF1','\xC3','\xE4','\xE2','\xE3','\x40', SA1CUST '\xE6','\xC8','\xC5','\xD9','\xC5','\x40','\xD4','\xC1', WHERE MA '\xE7','\xC2','\xC1','\xD3','\x40','\xD5','\xD6','\xE3', XBAL NOT '\x40','\xC2','\xC5','\xE3','\xE6','\xC5','\xC5','\xD5', BETWEEN '\x40','\xF2','\xF0','\xF0','\xF0','\xF0','\x4B','\xF0', 20000.0 '\x40','\xC1','\xD5','\xC4','\x40','\xF1','\xF0','\xF0', AND 100 '\xF0','\xF0','\xF0','\xF0','\x4B','\xF0','\x40','\xD6', 0000.0 O '\xD9','\xC4','\xC5','\xD9','\x40','\xC2','\xE8','\x40', ORDER BY '\xD7','\xC2','\xC1','\xD3','\x40','\xC1','\xE2','\xC3', PBAL ASC '\x40','\x00','\x00','\x00','\x00','\x40','\x40','\x40',
·
·
·
'\x40','\x40','\x40','\x40','\x40','\x40','\x40','\x40', '\xC4','\xC2','\xD9','\xD4','\x00','\x00','\x00','\x24', DBRM '\x00','\x01','\x00','\x00','\x00','\x00','\x00','\x9E', '\x00','\x00','\x00','\x14','\x00','\x00','\x00','\x08', '\xD6','\xD7','\xC5','\xD5','\x40','\xC3','\xF2','\x40', OPEN C2 '\x00','\x00','\x00','\x00','\x40','\x40','\x40','\x40', '\x40','\x40','\x40','\x40','\x40','\x40','\x40','\x40',
·
·
·
'\x40','\x40','\x40','\x40','\x40','\x40','\x40','\x40', '\x40','\x40','\x40','\x40','\x40','\x40','\x40','\x40', '\x40','\x40','\x40','\x40','\x40','\x40','\x40','\x40', }; /********************************************************************* ** THIS PRODUCT CONTAINS "RESTRICTED MATERIALS OF IBM" ** COPYRIGHT = 5748-T13 (C) COPYRIGHT IBM CORP 1979,1989 ** LICENSED MATERIAL - PROGRAM PROPERTY OF IBM ** REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083 ********************************************************************** ** ** FUNCTION NAME...qxma_saamdc10 ** SEGMENT NAME....QXMA ** ** * ** Load module name: QXOZ * ** * ** **********************************************************************
·
·
·
** ** EXTERNAL REFERENCES...printf, qxo2_check, qxo3_check ** ** ** HEADER FILES #INCLUDED...c$artst0 */ #ifdef _TARGET_TPF #error This segment cannot be compiled using TARGET(TPF) #endif /*******************************************************************/ /* */ /* TESTCASE NAME: SAAMDC10 MEMBER: D011YNN */ /* */ /* TESTCASE DESCRIPTION: Queries and Predicates */ /* */ /* CREATION DATE: 5/5/1989 */ /* */ /* SPECIAL TESTING NOTES: None */ /* */ /* TERMINATION STATUS: Cond code 0 */ /* */ /*******************************************************************/ typedef struct { short SQLPLLEN; short SQLFLAGS; short SQLCTYPE; char SQLPROGN[8]; short SQLTIMES[4]; short SQLSECTN; char *SQLCODEP; char *SQLVPARM; char *SQLAPARM; short SQLSTNUM; short SQLSTYPE; char SQLPKISL[2]; const char *DBRM_PTR; long DBRM_SIZE; } SQLPLIST; typedef struct { short SQLTYPE; short SQLLEN; char *SQLADDR; char *SQLIND; } SQLELTS; typedef SQLELTS *SQLELTS_PTR; static char SQLTEMP??(19??) ; struct SQLVTAG { char *VERSPRE ; char *VERSSTR ; } ; static struct SQLVTAG SQLVERS = { "VER.", "RF"}; static char DSNPNM??(57??) ; /***$$$ EXEC SQL INCLUDE SQLCA $$$***/ #ifndef SQLCODE struct sqlca { unsigned char sqlcaid[8]; long sqlcabc; long sqlcode; short sqlerrml; unsigned char sqlerrmc[70]; unsigned char sqlerrp[8]; long sqlerrd[6]; unsigned char sqlwarn[11]; unsigned char sqlstate[5]; } ; #define SQLCODE sqlca.sqlcode #define SQLWARN0 sqlca.sqlwarn[0] #define SQLWARN1 sqlca.sqlwarn[1] #define SQLWARN2 sqlca.sqlwarn[2] #define SQLWARN3 sqlca.sqlwarn[3] #define SQLWARN4 sqlca.sqlwarn[4] #define SQLWARN5 sqlca.sqlwarn[5] #define SQLWARN6 sqlca.sqlwarn[6] #define SQLWARN7 sqlca.sqlwarn[7] #define SQLWARN8 sqlca.sqlwarn[8] #define SQLWARN9 sqlca.sqlwarn[9] #define SQLWARNA sqlca.sqlwarn[10] #define SQLSTATE sqlca.sqlstate #endif static struct sqlca sqlca ; #include <c$artst0.h> /* The following macros are defined to check if two given values of various types are equivalent and print out their differences. * static char d_tmp1[20], d_tmp2[20]; #define Str_Comp(X, Y) (strncmp(X, Y, strlen(Y)) == 0) #define Dou_Comp(X, Y) ( \ sprintf(d_tmp1, "%e\0", X), \ sprintf(d_tmp2, "%e\0", Y), \ (strcmp(d_tmp1, d_tmp2) == 0)) #define PDiff_s(X, Y) if (!(Str_Comp(X, Y))) \ printf(#X " : %s\nexpected : %s\n", X, Y) #define PDiff_g(X, Y) if (!(Dou_Comp(X, Y))) \ printf(#X " : %g expected : %g\n", X, Y) #define PDiff_d(X, Y) if (X != Y) \ printf(#X " : %d expected : %d\n", X, Y) extern void qxma_saamdc10( long *return_ptr, /* No. of Errors encountered */ long *warning_ptr /* No. of Warnings encountered */ ) { int warn = 0; long return_code; long warning_code; /***$$$ EXEC SQL BEGIN DECLARE SECTION $$$***/ char host1[7], host2[40]; double host8, host9; /***$$$ EXEC SQL END DECLARE SECTION $$$***/ return_code=*return_ptr; warning_code=*warning_ptr; /************************************************************* DECLARE CURSOR C2 *************************************************************/ /***$$$ EXEC SQL DECLARE C2 CURSOR FOR SELECT CUSTNO, NAME, PBAL, MAXBAL FROM SAAID.SA1CUST WHERE MAXBAL NOT BETWEEN 20000.0 AND 1000000.0 ORDER BY PBAL ASC $$$***/ qxo2_check("DECLARE CURSOR C2",&sqlca,&return_code); /************************************************************* OPEN CURSOR C2 *************************************************************/ /***$$$ EXEC SQL OPEN C2 $$$***/ { SQLPLIST SQLPLIST2 = {40, 0, 50, "QXMARF ", 0, 0, 0 ,0, 1, 0, 0, 0, 158, 3}; SQLELTS_PTR SQLELTS_PTR2; SQLPLIST2.SQLCODEP = (char *) &sqlca; SQLPLIST2.SQLTIMES[0] = 0x15B5; SQLPLIST2.SQLTIMES[1] = 0x8055; SQLPLIST2.SQLTIMES[2] = 0x15B9; SQLPLIST2.SQLTIMES[3] = 0xE240; SQLPLIST2.SQLPKISL[0] = 0x24; SQLPLIST2.SQLPKISL[1] = 0x42; SQLPLIST2.DBRM_PTR = dbrm_array; SQLPLIST2.DBRM_SIZE = sizeof(dbrm_array); SQLPLIST2.SQLFLAGS = SQLPLIST2.SQLFLAGS | 0x1; DSNHLI ( (unsigned int * ) &SQLPLIST2); } qxo2_check("OPEN CURSOR C2",&sqlca,&return_code); /************************************************************* TEST FETCH CURSOR C2 *************************************************************/
·
·
·
}