/* Result Sets Interface */ #ifndef SQL_CRSR # define SQL_CRSR struct sql_cursor { unsigned int curocn; void *ptr1; void *ptr2; unsigned int magic; }; typedef struct sql_cursor sql_cursor; typedef struct sql_cursor SQL_CURSOR; #endif /* SQL_CRSR */ /* Thread Safety */ typedef void * sql_context; typedef void * SQL_CONTEXT; /* File name & Package Name */ struct sqlcxp { unsigned short fillen; char filnam[43]; }; static const struct sqlcxp sqlfpn = { 42, "c:\\forms\\newsoft\\software\\ch30\\filename.pc" }; static const unsigned long sqlctx = 900882260; static struct sqlexd { unsigned long sqlvsn; unsigned long arrsiz; unsigned long iters; unsigned short offset; unsigned short selerr; unsigned short sqlety; unsigned short unused; const short *cud; unsigned char *sqlest; const char *stmt; unsigned char * *sqphsv; unsigned long *sqphsl; short * *sqpind; unsigned long *sqparm; unsigned long * *sqparc; unsigned char *sqhstv[2]; unsigned long sqhstl[2]; short *sqindv[2]; unsigned long sqharm[2]; unsigned long *sqharc[2]; } sqlstm = {8,2}; /* Prototypes */ extern void sqlcxt (void **, const unsigned long *, struct sqlexd *, const struct sqlcxp *); extern void sqlcx2t(void **, const unsigned long *, struct sqlexd *, const struct sqlcxp *); extern void sqlbuft(void **, char *); extern void sqlgs2t(void **, char *); extern void sqlorat(void **, const unsigned long *, void *); /* Forms Interface */ static const int IAPSUCC = 0; static const int IAPFAIL = 1403; static const int IAPFTL = 535; extern void sqliem(char *, unsigned long *); typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR; typedef struct { unsigned short len; unsigned char arr[1]; } varchar; /* cud (compilation unit data) array */ static const short sqlcud0[] = {8,4130, 2,0,0,1,0,0,52,94,0,2,1,0,1,0,1,9,0,0,2,9,0,0, }; #include #include #include #include #include "ueerror.h" int GetFileName ( LPSTR szBuffer ) { HWND hParentWin; OPENFILENAME ofn; char szDirName[256], szFile[256], szFileTitle[256]; UINT i, cbString; char chReplace, /* string separator for szFilter */ szFilter[256] = "All Files (*.*)|*.*|", dialogTitle[80] = "Get File Name\0"; /* Get the system directory name, and store in szDirName */ GetSystemDirectory(szDirName, sizeof(szDirName)); szFile[0] = '\0'; cbString = lstrlen(szFilter); chReplace = szFilter[cbString - 1]; /* retrieve wildcard */ for (i = 0; szFilter[i] != '\0'; i++) { /* Replace wildcard with '\0' */ if (szFilter[i] == chReplace) szFilter[i] = '\0'; } hParentWin = GetActiveWindow(); /* Set all structure members to zero. */ memset(&ofn, 0, sizeof(OPENFILENAME)); /* Initialize structure members. */ ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hParentWin; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = szDirName; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; ofn.lpstrTitle = dialogTitle; if (GetOpenFileName(&ofn)) lstrcpy (szBuffer,ofn.lpstrFile); else { *szBuffer=0; return FATAL_ERR; } return SUCCESS; } /* ** USER_EXIT ('ReturnFileName ITEM=BLOCK.ITEM); ** Assigns the name of the selected file to item BLOCK.ITEM." */ int ReturnFileName(inputArgs) char *inputArgs; { char *Parameter, szBuffer[256], *itemName, errorTitle[80] = "Error in User Exit RetrieveFileName\0", invalidItemParameter[80] = "Invalid Parameter. ITEM was expected.\0", errorMsg[80] = "Cannot invoke the Get File Name dialog box.\0"; /* 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. If the symbol SQLCA_NONE is defined, then the SQLCA variable will not be defined at all. The symbol SQLCA_NONE should not be defined in source modules that have embedded SQL. However, source modules that have no embedded SQL, but need to manipulate a sqlca struct passed in as a parameter, can set the SQLCA_NONE symbol to avoid creation of an extraneous sqlca variable. */ #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]; }; #ifndef SQLCA_NONE #ifdef SQLCA_STORAGE_CLASS SQLCA_STORAGE_CLASS struct sqlca sqlca #else struct sqlca sqlca #endif # 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 #endif /* end SQLCA */ /* EXEC SQL BEGIN DECLARE SECTION; */ /* VARCHAR fileName[256]; */ struct { unsigned short len; unsigned char arr[256]; } fileName; /* VARCHAR FormsItemName[256]; */ struct { unsigned short len; unsigned char arr[256]; } FormsItemName; /* EXEC SQL END DECLARE SECTION; */ Parameter = strtok(inputArgs," "); Parameter = strtok(NULL,"="); if ( strcmp(strupr(Parameter),"ITEM")==0 ) itemName = strtok(NULL," "); else { UEError(errorTitle, invalidItemParameter); return FATAL_ERR; } if ( GetFileName ( szBuffer ) == SUCCESS ) { strcpy(FormsItemName.arr, itemName); FormsItemName.len = strlen( itemName ); strcpy(fileName.arr, szBuffer); fileName.len = strlen( szBuffer ); /* EXEC TOOLS SET :FormsItemName VALUES (:fileName); */ { struct sqlexd sqlstm; sqlstm.sqlvsn = 8; sqlstm.arrsiz = 2; sqlstm.stmt = ""; sqlstm.iters = (unsigned long )1; sqlstm.offset = (unsigned short)2; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&sqlca; sqlstm.sqlety = (unsigned short)0; sqlstm.sqhstv[0] = (unsigned char *)&FormsItemName; sqlstm.sqhstl[0] = (unsigned long )258; sqlstm.sqindv[0] = ( short *)0; sqlstm.sqharm[0] = (unsigned long )0; sqlstm.sqhstv[1] = (unsigned char *)&fileName; sqlstm.sqhstl[1] = (unsigned long )258; 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; sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn); } } else { UEError(errorTitle, errorMsg); return FATAL_ERR; } return SUCCESS; } /* ReturnFileName */