static char sqh000[] = "APPCTX_1"; static char sqh001[] = "APPCTX_2"; static char sqh002[] = "APPCTX_1"; static char sqh003[] = "APPCTX_1"; static char sqh004[] = "APPCTX_2"; static char sqh005[] = "BVNUM1"; static char sqh006[] = "BVNUM2"; static char sqh007[] = "39"; static char sqh008[] = "BVNUM1"; static char sqh009[] = "BVNUM2"; static char sqh010[] = "BVCHAR1"; static char sqh011[] = "BVCHAR2"; static char sqh012[] = "char bind variable 2"; static char sqh013[] = "BVCHAR1"; static char sqh014[] = "BVCHAR2"; static char sqh015[] = "BVDATE1"; static char sqh016[] = "BVDATE2"; static char sqh017[] = "01-JAN-90"; static char sqh018[] = "BVDATE1"; static char sqh019[] = "BVDATE2"; static char sqh020[] = "First message"; static char sqh021[] = "Second message"; static char sqh022[] = "101"; /* File name & Package Name */ struct sqlcxp { unsigned short fillen; char filnam[13]; }; static struct sqlcxp sqlfpn = { 12, ".\\ue_samp.pc" }; static unsigned long sqlctx = 0; static struct sqlexd { unsigned long sqlvsn; unsigned short arrsiz; unsigned short iters; unsigned short offset; unsigned short selerr; unsigned short sqlety; unsigned short unused; short *cud; unsigned char *sqlest; char *stmt; unsigned char * *sqphsv; unsigned long *sqphsl; short * *sqpind; unsigned long *sqparm; unsigned long * *sqparc; unsigned char *sqhstv[4]; unsigned long sqhstl[4]; short *sqindv[4]; unsigned long sqharm[4]; unsigned long *sqharc[4]; } sqlstm = {4,4}; extern sqlcx2(/*_ unsigned long *, struct sqlexd *, struct sqlcxp * _*/); extern sqlcte(/*_ unsigned long *, struct sqlexd *, struct sqlcxp * _*/); extern sqlbuf(/*_ char * _*/); extern sqlora(/*_ long *, void * _*/); static int IAPSUCC = 0; static int IAPFAIL = 1403; static int IAPFTL = 535; extern sqliem(); /* cud (compilation unit data) array */ static short sqlcud0[] = {4,34, 2,8,0,0,47,0,37,53,117,27803,0,0,55,97,2,1,0,1,0,1,1,14557,13979,2,1,-26998,-28208, 29,8,0,0,47,0,37,53,117,27803,0,0,55,101,2,1,0,1,0,1,1,14557,13979,2,1,-26998,-28208, 56,8,0,0,47,0,37,53,117,27803,0,0,55,107,2,1,0,1,0,1,1,14557,13979,2,1,-26998,-28208, 83,8,0,0,47,0,37,53,117,27803,0,0,54,113,2,1,0,1,0,1,1,14557,13979,2,1,-26998,-28208, 110,8,0,0,47,0,37,53,117,27803,0,0,54,114,2,1,0,1,0,1,1,14557,13979,2,1,-26998,-28208, 137,8,0,0,47,0,37,53,117,27803,0,0,52,139,4,2,0,1,0,1,1,14557,13979,1,1,-26998,-28208,2,3,3218,26580,2,1,16849,-7453, 172,8,0,0,47,0,37,53,117,27803,0,0,51,145,4,2,0,1,0,1,1,14557,13979,1,1,-26998,-28208,2,3,3218,26580,2,3,16849,-7453, 207,8,0,0,47,0,37,53,117,27803,0,0,52,161,4,2,0,1,0,1,1,14557,13979,1,1,-26998,-28208,2,1,3218,26580,2,1,16849,-7453, 242,8,0,0,47,0,37,53,117,27803,0,0,51,166,4,2,0,1,0,1,1,14557,13979,1,1,-26998,-28208,2,1,3218,26580,2,1,16849,-7453, 277,8,0,0,47,0,37,53,117,27803,0,0,52,182,4,2,0,1,0,1,1,14557,13979,1,1,-26998,-28208,2,1,3218,26580,2,1,16849,-7453, 312,8,0,0,47,0,37,53,117,27803,0,0,51,185,4,2,0,1,0,1,1,14557,13979,1,1,-26998,-28208,2,1,3218,26580,2,1,16849,-7453, 347,8,0,0,47,0,37,53,117,27803,0,0,53,207,1,0,0,1,0,2,1,14557,13979, 370,8,0,0,47,0,37,53,117,27803,0,0,53,213,2,0,0,1,0,2,1,14557,13979,2,1,-26998,-28208, }; #ifdef RCSID static char *RCSid = "$Header: /og/v2/go/RCS/testexit.pc,v 1.2 1993/11/18 23:43:14 jrhee Exp $ "; #endif /* RCSID */ /* NAME testexit.c - TEST user EXIT DESCRIPTION This file contains a PCC user exit that exercises EXEC TOOLS functionality. PUBLIC FUNCTION(S) testexit - TEST user EXIT PRIVATE FUNCTION(S) None. RETURNS See individual functions. NOTES None. MODIFIED (MM/DD/YY) jrhee 04/02/93 - Creation */ /* Define some local variables to be used in the testexit routine below. */ /* SQL stmt #1 EXEC SQL BEGIN DECLARE SECTION; */ int ihv1; int ihv2; int ihv3; char chv1[60]; char chv2[60]; char chv3[60]; char dhv1[60]; char dhv2[60]; char dhv3[60]; char my_context[60]; char my_context2[60]; char my_context3[60]; char *pctx; char *pctx2; /* SQL stmt #2 EXEC SQL END DECLARE SECTION; */ /* SQL stmt #3 EXEC SQL INCLUDE SQLCA; */ /* Copyright (c) 1985,1986 by Oracle Corporation. */ /* NAME SQLCA : SQL Communications Area. FUNCTION Contains no code. Oracle fills in the SQLCA with status info during the execution of a SQL stmt. NOTES If the symbol SQLCA_STORAGE_CLASS is defined, then the SQLCA will be defined to have this storage class. For example: #define SQLCA_STORAGE_CLASS extern will define the SQLCA as an extern. If the symbol SQLCA_INIT is defined, then the SQLCA will be statically initialized. Although this is not necessary in order to use the SQLCA, it is a good pgming practice not to have unitialized variables. However, some C compilers/OS's don't allow automatic variables to be init'd in this manner. Therefore, if you are INCLUDE'ing the SQLCA in a place where it would be an automatic AND your C compiler/OS doesn't allow this style of initialization, then SQLCA_INIT should be left undefined -- all others can define SQLCA_INIT if they wish. New rules for defining SQLCA_INIT, SQLCA_STORAGE_CLASS, and DLL in OS/2: Users should not define SQLCA_STORAGE_CLASS if defining DLL. SQLCA_STORAGE_CLASS is primarily used for single-threaded programs and for internal development. MODIFIED Okamura 08/15/89 - OS/2: users must define SQLMT for multi-threaded case Okamura 06/23/89 - OS/2: modify for multi-threaded case Clare 12/06/84 - Ch SQLCA to not be an extern. Clare 10/21/85 - Add initialization. Bradbury 01/05/86 - Only initialize when SQLCA_INIT set Clare 06/12/86 - Add SQLCA_STORAGE_CLASS option. */ #ifndef SQLCA #define SQLCA 1 struct sqlca { /* ub1 */ char sqlcaid[8]; /* b4 */ long sqlabc; /* b4 */ long sqlcode; struct { /* ub2 */ unsigned short sqlerrml; /* ub1 */ char sqlerrmc[70]; } sqlerrm; /* ub1 */ char sqlerrp[8]; /* b4 */ long sqlerrd[6]; /* ub1 */ char sqlwarn[8]; /* ub1 */ char sqlext[8]; }; #ifdef SQLMT extern struct sqlca *sqlcamt(); /* For multi-threaded version */ # define sqlca (*sqlcamt()) #else /* SQLMT */ #ifdef SQLCA_STORAGE_CLASS SQLCA_STORAGE_CLASS struct sqlca sqlca # ifdef SQLCA_INIT = { {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '}, sizeof(struct sqlca), 0, { 0, {0}}, {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0} } # endif /* SQLCA_INIT */ ; #else /* SQLCA_STORAGE_CLASS */ struct sqlca sqlca /* For single-threaded version */ # ifdef SQLCA_INIT = { {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '}, sizeof(struct sqlca), 0, { 0, {0}}, {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0} } # endif /* SQLCA_INIT */ ; #endif /* SQLCA_STORAGE_CLASS */ #endif /* SQLMT */ /* end SQLCA */ #endif /* SQLCA */ /* testexit: --------- This is a PCC user exit that is meant to demonstrate on a very simple level the interaction between a PCC user exit and an Oracle Graphics document. It demonstrates the following functionality: * setting named application contexts * getting named application contexts * setting bind variable values * getting bind variable values * sending messages The only assumptions it makes are that it is called from an Oracle Graphics document having the following bind variables: bvnum1 NUMBER bvnum2 NUMBER bvchar1 CHAR bvchar2 CHAR bvdate1 DATE bvdate2 DATE The routine is divided into subsections with each subsection commented fairly thoroughly. Please reference the Oracle Graphics Reference Manual for additional information. */ int testexit(cmdlin, cmdlinl) char *cmdlin; /* command line */ int *cmdlinl; /* command line length */ { /* Print out the command line and its length */ #ifdef GODEBUG printf("Command line: %s\n", cmdlin); printf("Command line length: %d\n\n", *cmdlinl); #endif /********************************************************************* * The following section demonstrates setting and getting named * * application contexts. * ********************************************************************* */ /* Set the application context named 'appctx_1' to contain the value of the pointer 'my_context'. Named application contexts are just ways of stashing away named pointer entities in an Oracle Graphics document and then being able to retrieve them later. So, here I am just stashing away the value of the pointer 'my_context' under the name 'appctx_1'. */ strcpy(my_context ,"application context 1"); /* SQL stmt #4 EXEC TOOLS SET CONTEXT :my_context BY appctx_1; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)2; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh000; sqlstm.sqhstl[0] = (unsigned long)8; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)my_context; sqlstm.sqhstl[1] = (unsigned long)60; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Do similar operation for 'my_context2' pointer and name it 'appctx_2'. */ strcpy(my_context2, "application context 2"); /* SQL stmt #5 EXEC TOOLS SET CONTEXT :my_context2 BY appctx_2; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)29; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh001; sqlstm.sqhstl[0] = (unsigned long)8; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)my_context2; sqlstm.sqhstl[1] = (unsigned long)60; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Now, I want to reset the value of the pointer named by 'appctx_1' to be the value of the pointer 'my_context3'. */ strcpy(my_context3, "application context 1 reset"); /* SQL stmt #6 EXEC TOOLS SET CONTEXT :my_context3 BY appctx_1; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)56; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh002; sqlstm.sqhstl[0] = (unsigned long)8; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)my_context3; sqlstm.sqhstl[1] = (unsigned long)60; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Now, let's retrieve the pointers that were stored away under the names 'appctx_1' and 'appctx_2' and let's put the pointer values into the local variables 'pctx' and 'pctx2'. */ /* SQL stmt #7 EXEC TOOLS GET CONTEXT appctx_1 INTO :pctx; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)83; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh003; sqlstm.sqhstl[0] = (unsigned long)8; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)&pctx; sqlstm.sqhstl[1] = (unsigned long)0; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* SQL stmt #8 EXEC TOOLS GET CONTEXT appctx_2 INTO :pctx2; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)110; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh004; sqlstm.sqhstl[0] = (unsigned long)8; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)&pctx2; sqlstm.sqhstl[1] = (unsigned long)0; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Print out the retrieved context values (the context pointers were just char pointers so we can just print out the string values appropriately) to make sure we got back the right values */ #ifdef GODEBUG printf("App Context 1 (expecting 'application context 1 reset'): '%s'\n", pctx); printf("App Context 2 (expecting 'application context 2'): '%s'\n", pctx2); #endif /********************************************************************* * The next section demonstrates setting and getting values * * of bind variables. * ********************************************************************* */ /* First, we set the values of the NUMBER bind variables 'bvnum1' and 'bvnum2' (which reside in the calling Oracle Graphics document) to be the values 29 and 39 respectively using a local variable for the value 29 and a constant for the value 39. */ ihv1 = 29; /* SQL stmt #9 EXEC TOOLS SET bvnum1, bvnum2 VALUES (:ihv1, 39); */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)137; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh005; sqlstm.sqhstl[0] = (unsigned long)6; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)sqh006; sqlstm.sqhstl[1] = (unsigned long)6; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqhstv[2] = (unsigned char *)&ihv1; sqlstm.sqhstl[2] = (unsigned long)2; sqlstm.sqindv[2] = (short *)0; sqlstm.sqharm[2] = (unsigned long)0; sqlstm.sqhstv[3] = (unsigned char *)sqh007; sqlstm.sqhstl[3] = (unsigned long)2; sqlstm.sqindv[3] = (short *)0; sqlstm.sqharm[3] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Now, let's get the values of 'bvnum1' and 'bvnum2' to make sure they were set correctly. We put the values into the local variables 'ihv2' and 'ihv3'. */ /* SQL stmt #10 EXEC TOOLS GET bvnum1, bvnum2 INTO :ihv2, :ihv3; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)172; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh008; sqlstm.sqhstl[0] = (unsigned long)6; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)sqh009; sqlstm.sqhstl[1] = (unsigned long)6; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqhstv[2] = (unsigned char *)&ihv2; sqlstm.sqhstl[2] = (unsigned long)2; sqlstm.sqindv[2] = (short *)0; sqlstm.sqharm[2] = (unsigned long)0; sqlstm.sqhstv[3] = (unsigned char *)&ihv3; sqlstm.sqhstl[3] = (unsigned long)2; sqlstm.sqindv[3] = (short *)0; sqlstm.sqharm[3] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Print out the values of 'ihv2' and 'ihv3' to make sure that they were successfully retrieved */ #ifdef GODEBUG printf("Numeric bind variable 1 (expecting '29'): '%d'\n", ihv2); printf("Numeric bind variable 2 (expecting '39'): '%d'\n", ihv3); #endif /* Next, let's set the values of the CHAR bind variables 'bvchar1' and 'bvchar2' in a similar manner to which we set the 'bvnum1' and 'bvnum2' bind variables above (i.e., use one local variable and one constant as the value mechanism) */ strcpy(chv1, "char bind variable 1"); /* SQL stmt #11 EXEC TOOLS SET bvchar1, bvchar2 VALUES (:chv1, 'char bind variable 2'); */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)207; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh010; sqlstm.sqhstl[0] = (unsigned long)7; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)sqh011; sqlstm.sqhstl[1] = (unsigned long)7; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqhstv[2] = (unsigned char *)chv1; sqlstm.sqhstl[2] = (unsigned long)60; sqlstm.sqindv[2] = (short *)0; sqlstm.sqharm[2] = (unsigned long)0; sqlstm.sqhstv[3] = (unsigned char *)sqh012; sqlstm.sqhstl[3] = (unsigned long)20; sqlstm.sqindv[3] = (short *)0; sqlstm.sqharm[3] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Retrieve 'bvchar1' and 'bvchar2' into the local variables 'chv2' and 'chv3'. */ /* SQL stmt #12 EXEC TOOLS GET bvchar1, bvchar2 INTO :chv2, :chv3; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)242; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh013; sqlstm.sqhstl[0] = (unsigned long)7; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)sqh014; sqlstm.sqhstl[1] = (unsigned long)7; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqhstv[2] = (unsigned char *)chv2; sqlstm.sqhstl[2] = (unsigned long)60; sqlstm.sqindv[2] = (short *)0; sqlstm.sqharm[2] = (unsigned long)0; sqlstm.sqhstv[3] = (unsigned char *)chv3; sqlstm.sqhstl[3] = (unsigned long)60; sqlstm.sqindv[3] = (short *)0; sqlstm.sqharm[3] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Now, print out 'chv2' and 'chv3' to make sure they were retrieved correctly. */ #ifdef GODEBUG printf("Char bind variable 1 (expecting 'char bind variable 1'): '%s'\n", chv2); printf("Char bind variable 2 (expecting 'char bind variable 2'): '%s'\n", chv3); #endif /* Do set operations for the DATE bind variables 'bvdate1' and 'bvdate2'. */ strcpy(dhv1, "05-NOV-92"); /* SQL stmt #13 EXEC TOOLS SET bvdate1, bvdate2 VALUES (:dhv1, '01-JAN-90'); */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)277; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh015; sqlstm.sqhstl[0] = (unsigned long)7; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)sqh016; sqlstm.sqhstl[1] = (unsigned long)7; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqhstv[2] = (unsigned char *)dhv1; sqlstm.sqhstl[2] = (unsigned long)60; sqlstm.sqindv[2] = (short *)0; sqlstm.sqharm[2] = (unsigned long)0; sqlstm.sqhstv[3] = (unsigned char *)sqh017; sqlstm.sqhstl[3] = (unsigned long)9; sqlstm.sqindv[3] = (short *)0; sqlstm.sqharm[3] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Retrieve the values back into local variables 'dhv2' and 'dhv3'. */ /* SQL stmt #14 EXEC TOOLS GET bvdate1, bvdate2 INTO :dhv2, :dhv3; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)312; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh018; sqlstm.sqhstl[0] = (unsigned long)7; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)sqh019; sqlstm.sqhstl[1] = (unsigned long)7; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqhstv[2] = (unsigned char *)dhv2; sqlstm.sqhstl[2] = (unsigned long)60; sqlstm.sqindv[2] = (short *)0; sqlstm.sqharm[2] = (unsigned long)0; sqlstm.sqhstv[3] = (unsigned char *)dhv3; sqlstm.sqhstl[3] = (unsigned long)60; sqlstm.sqindv[3] = (short *)0; sqlstm.sqharm[3] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Print out 'dhv2' and 'dhv3' to make sure they were retrieved correctly. */ #ifdef GODEBUG printf("Date bind variable 1 (expecting '05-NOV-92'): '%s'\n", dhv2); printf("Date bind variable 2 (expecting '01-JAN-90'): '%s'\n", dhv3); #endif /********************************************************************* * The last section demonstrates sending messages back to Oracle * * Graphics. * ********************************************************************* */ /* Send a message with no numeric code (the message gets displayed in an alert in Oracle Graphics) */ /* SQL stmt #15 EXEC TOOLS MESSAGE 'First message'; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)347; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh020; sqlstm.sqhstl[0] = (unsigned long)13; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Now, try sending a message with a numeric error code of 101 (again, the message with its associated numeric code will get displayed in an alert in Oracle Graphics) */ /* SQL stmt #16 EXEC TOOLS MESSAGE 'Second message' 101; */ { sqlstm.stmt = ""; sqlstm.iters = (unsigned short)1; sqlstm.offset = (unsigned short)370; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)sqh021; sqlstm.sqhstl[0] = (unsigned long)14; sqlstm.sqindv[0] = (short *)0; sqlstm.sqharm[0] = (unsigned long)0; sqlstm.sqhstv[1] = (unsigned char *)sqh022; sqlstm.sqhstl[1] = (unsigned long)3; sqlstm.sqindv[1] = (short *)0; sqlstm.sqharm[1] = (unsigned long)0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlcte(&sqlctx, &sqlstm, &sqlfpn); } /* Return success */ return(0); } /* end testexit */