INFO.C
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:100k
源码类别:

Windows编程

开发平台:

Visual C++

  1. //*---------------------------------------------------------------------------------
  2. //|  ODBC System Administrator
  3. //|
  4. //|  This code is furnished on an as-is basis as part of the ODBC SDK and is
  5. //|  intended for example purposes only.
  6. //|
  7. //|   Title:   INFO.C
  8. //|      This module contains the functions which handle the Info menu items.
  9. //|         This module relies on RESULTS and EXECUTE to 
  10. //|      This file contains the actual code to execute SQL Statements and
  11. //|         display them.  This file is dependent on the SA Tool data structures
  12. //|         and the independent module RESULTS.
  13. //|
  14. //|      NOTE:  Due to the timing of this sample, only the 1.0 GetInfo constants
  15. //|         are shown.  To see all GetInfo constants for a 2.0 driver, use the
  16. //|         ODBC Test Tool which comes with this SDK.
  17. //*---------------------------------------------------------------------------------
  18. #include "info.h"
  19. #include "ini.h"
  20. #include "sql.h"
  21. #include "sqlext.h"
  22. #include "stdlib.h"
  23. #include "strings.h"
  24. VSZFile;
  25. //*---------------------------------------------------------------------------------
  26. //|   Defines and macros
  27. //*---------------------------------------------------------------------------------
  28. #define MAXNAME            35
  29. #define MAXPARMS           18
  30. #define MAXSQL             300
  31. #define szCOMMA            ","
  32. #define szBLANK            " "
  33. typedef struct tagNEWPIPE {
  34.    HWND        hwnd;
  35.    HINSTANCE   hInst;
  36.    char        szName[MAXNAME];
  37.    BOOL        fSuccess;
  38. } NEWPIPE;
  39. //*---------------------------------------------------------------------------------
  40. //|   Local Function Prototypes
  41. //*---------------------------------------------------------------------------------
  42. BOOL EXTFUN EditPipeWndProc(HWND hDlg, unsigned msg, WPARAM wParam, LPARAM lParam);
  43. void NewPipe(NEWPIPE FAR * np);
  44. BOOL EXTFUN NewPipeWndProc(HWND hDlg, unsigned msg, WPARAM wParam, LPARAM lParam);
  45. BOOL EXTFUN DoPipeWndProc(HWND hDlg, unsigned msg, WPARAM wParam, LPARAM lParam);
  46. void DoPipe(RESULTSSET FAR * rs, CHILDINFO FAR * ci, LPSTR szPipeName,
  47.          int FAR xPipes[], int cbCnt);
  48. void DoPipeByValue(RESULTSSET FAR * rs, CHILDINFO FAR * ci, LPSTR sqlpsql,
  49.       LPSTR szparms, int FAR xPipes[], int cbCnt, LPSTR szPipeName);
  50. void PrepareParmList(LPSTR str);
  51. SDWORD RefreshList(HWND hDlg, RESULTSSET FAR * rs, CHILDINFO FAR * ci, int state, 
  52.          LPSTR szQual, LPSTR szOwner, LPSTR szName, int cbCols);
  53. SDWORD RefreshPipeList(HWND hDlg);
  54. //*---------------------------------------------------------------------------------
  55. //|   Global variables
  56. //*---------------------------------------------------------------------------------
  57. extern dCSEG(char) szMSSansSerif[];
  58. extern dCSEG(char) szPIPES[];
  59. extern dCSEG(char) szFONT[];
  60. extern char        OutStr[MAXBUFF];
  61. extern dCSEG(char) szVALUE[];
  62. dCSEG(char) szISO92[]            =  "ISO 92";
  63. dCSEG(char) szXOpen[]            =  "X/Open";
  64. dCSEG(char) szODBC[]             =  "ODBC";
  65. dCSEG(char) szDepr[]             =  "Deprecated";
  66. dCSEG(char) szCore[]             =  "Core";
  67. dCSEG(char) szLvl1[]             =  "Level 1";
  68. dCSEG(char) szLvl2[]             =  "Level 2";
  69. dCSEG(char) szYes[]              =  "Yes";
  70. dCSEG(char) szNo[]               =  "No";
  71. dCSEG(char) szODBCFunctions[]    =  "Functions";
  72. dCSEG(char) szODBCDataSources[]  =  "Data Sources";
  73. dCSEG(char) szODBCDataTypes[]    =  "Data Types";
  74. dCSEG(char) szGetInfoTitle[]     =  "Get Info";
  75. dCSEG(char) szQualifier[]        =  "Qualifier";
  76. dCSEG(char) szOwner[]            =  "Owner";
  77. dCSEG(char) szName[]             =  "Name";
  78. dCSEG(char) szType[]             =  "Type";
  79. dCSEG(char) szSQL[]              =  "Sql";
  80. dCSEG(char) szPARMS[]            =  "Parms";
  81. dCSEG(char) szPARMOPT[]          =  "ParmOpt";
  82. dCSEG(char) szDELETEOPT[]        =  "Delete";
  83. dCSEG(char) szBothTypes[]        =  "'%s','%s'";
  84. dCSEG(char) szOneType[]          =  "'%s'";
  85. dCSEG(char) szBlank[]            =  " ";
  86. dCSEG(char) szTABLETYPE[]        =  "TABLE";
  87. dCSEG(char) szVIEWTYPE[]         =  "VIEW";
  88. dCSEG(char) szVALUE[]            =  "value";
  89. dCSEG(char) szADDRESS[]          =  "address";
  90. dCSEG(char) szDeletePipe[]       =  "Delete pipe %s?";
  91. dCSEG(char) szEditPipe[]         =  "Edit Pipe";
  92. dCSEG(char) szDuplicatePipe[]    =  "Pipe already exists";
  93. dCSEG(char) szInstalled[]        =  "Installed";
  94. dCSEG(char) szDROPPROCSEMI[]     =  "Drop Procedure (with semi-colon)";
  95. static char szErrorMsgTitle[]    =  "Error";
  96. struct {
  97.    UWORD          fFunction;                 // Identifier for SQLGetFunctions
  98.    LPSTR          szLevel;                   // Conformance Level
  99.    int            idFunction;                // String table identifier for function name
  100.    } ODBCFunctions[] = {
  101. // fFunction                        szLevel           idFunction
  102. // -------------------------------  ---------------   --------------------------------
  103. // ---- ISO 92 Conformance -----------------------------------
  104.    {SQL_API_SQLALLOCHANDLE,          (LPSTR)szISO92,    idsSQLAllocHandle},
  105.    {SQL_API_SQLBINDCOL,              (LPSTR)szISO92,    idsSQLBindCol},
  106.    {SQL_API_SQLCANCEL,               (LPSTR)szISO92,    idsSQLCancel},
  107.    {SQL_API_SQLCLOSECURSOR,          (LPSTR)szISO92,    idsSQLCloseCursor},
  108.    {SQL_API_SQLCOLATTRIBUTE,         (LPSTR)szISO92,    idsSQLColAttribute},
  109.    {SQL_API_SQLCONNECT,              (LPSTR)szISO92,    idsSQLConnect},
  110.    {SQL_API_SQLCOPYDESC,             (LPSTR)szISO92,    idsSQLCopyDesc},
  111.    {SQL_API_SQLDATASOURCES,          (LPSTR)szISO92,    idsSQLDataSources},
  112.    {SQL_API_SQLDESCRIBECOL,          (LPSTR)szISO92,    idsSQLDescribeCol},
  113.    {SQL_API_SQLDISCONNECT,           (LPSTR)szISO92,    idsSQLDisconnect},
  114.    {SQL_API_SQLENDTRAN,              (LPSTR)szISO92,    idsSQLEndTran},
  115.    {SQL_API_SQLEXECDIRECT,           (LPSTR)szISO92,    idsSQLExecDirect},
  116.    {SQL_API_SQLEXECUTE,              (LPSTR)szISO92,    idsSQLExecute},
  117.    {SQL_API_SQLFETCH,                (LPSTR)szISO92,    idsSQLFetch},
  118.    {SQL_API_SQLFETCHSCROLL,          (LPSTR)szISO92,    idsSQLFetchScroll},
  119.    {SQL_API_SQLFREEHANDLE,           (LPSTR)szISO92,    idsSQLFreeHandle},
  120.    {SQL_API_SQLFREESTMT,             (LPSTR)szISO92,    idsSQLFreeStmt},
  121.    {SQL_API_SQLGETCONNECTATTR,       (LPSTR)szISO92,    idsSQLGetConnectAttr},
  122.    {SQL_API_SQLGETCURSORNAME,        (LPSTR)szISO92,    idsSQLGetCursorName},
  123.    {SQL_API_SQLGETDATA,              (LPSTR)szISO92,    idsSQLGetData},
  124.    {SQL_API_SQLGETDESCFIELD,         (LPSTR)szISO92,    idsSQLGetDescField},
  125.    {SQL_API_SQLGETDESCREC,           (LPSTR)szISO92,    idsSQLGetDescRec},
  126.    {SQL_API_SQLGETDIAGFIELD,         (LPSTR)szISO92,    idsSQLGetDiagField},
  127.    {SQL_API_SQLGETDIAGREC,           (LPSTR)szISO92,    idsSQLGetDiagRec},
  128.    {SQL_API_SQLGETFUNCTIONS,         (LPSTR)szISO92,    idsSQLGetFunctions},
  129.    {SQL_API_SQLGETINFO,              (LPSTR)szISO92,    idsSQLGetInfo},
  130.    {SQL_API_SQLGETSTMTATTR,          (LPSTR)szISO92,    idsSQLGetStmtAttr},
  131.    {SQL_API_SQLGETTYPEINFO,          (LPSTR)szISO92,    idsSQLGetTypeInfo},
  132.    {SQL_API_SQLGETSTMTATTR,          (LPSTR)szISO92,    idsSQLGetStmtAttr},
  133.    {SQL_API_SQLNUMRESULTCOLS,        (LPSTR)szISO92,    idsSQLNumResultCols},
  134.    {SQL_API_SQLPREPARE,              (LPSTR)szISO92,    idsSQLPrepare},
  135.    {SQL_API_SQLPUTDATA,              (LPSTR)szISO92,    idsSQLPutData},
  136.    {SQL_API_SQLROWCOUNT,             (LPSTR)szISO92,    idsSQLRowCount},
  137.    {SQL_API_SQLSETCONNECTATTR,       (LPSTR)szISO92,    idsSQLGetConnectAttr},
  138.    {SQL_API_SQLSETCURSORNAME,        (LPSTR)szISO92,    idsSQLSetCursorName},
  139.    {SQL_API_SQLSETDESCFIELD,         (LPSTR)szISO92,    idsSQLSetDescField},
  140.    {SQL_API_SQLSETDESCREC,           (LPSTR)szISO92,    idsSQLSetDescRec},
  141.    {SQL_API_SQLSETENVATTR,           (LPSTR)szISO92,    idsSQLSetEnvAttr},
  142.    {SQL_API_SQLSETSTMTATTR,          (LPSTR)szISO92,    idsSQLSetStmtAttr},
  143.    //---- X/Open Conformance -----------------------------------  
  144.    {SQL_API_SQLCOLUMNS,              (LPSTR)szXOpen,   idsSQLColumns},
  145.    {SQL_API_SQLGETENVATTR,           (LPSTR)szXOpen,   idsSQLGetEnvAttr},
  146.    {SQL_API_SQLSPECIALCOLUMNS,       (LPSTR)szXOpen,   idsSQLSpecialColumns},
  147.    {SQL_API_SQLSTATISTICS,           (LPSTR)szXOpen,   idsSQLStatistics},
  148.    {SQL_API_SQLTABLES,               (LPSTR)szXOpen,   idsSQLTables},
  149.    //---- ODBC Conformance -------------------------------------
  150.    {SQL_API_SQLBINDPARAMETER,        (LPSTR)szODBC,    idsSQLBindParameter},
  151.    {SQL_API_SQLBROWSECONNECT,        (LPSTR)szODBC,    idsSQLBrowseConnect},
  152.    {SQL_API_SQLBULKOPERATIONS,       (LPSTR)szODBC,    idsSQLBulkOperations},
  153.    {SQL_API_SQLCOLUMNPRIVILEGES,     (LPSTR)szODBC,    idsSQLColumnPrivileges},
  154.    {SQL_API_SQLDESCRIBEPARAM,        (LPSTR)szODBC,    idsSQLDescribeParam},
  155.    {SQL_API_SQLDRIVERCONNECT,        (LPSTR)szODBC,    idsSQLDriverConnect},
  156.    {SQL_API_SQLFOREIGNKEYS,          (LPSTR)szODBC,    idsSQLForeignKeys},
  157.    {SQL_API_SQLMORERESULTS,          (LPSTR)szODBC,    idsSQLMoreResults},
  158.    {SQL_API_SQLNATIVESQL,            (LPSTR)szODBC,    idsSQLNativeSQL},
  159.    {SQL_API_SQLNUMPARAMS,            (LPSTR)szODBC,    idsSQLNumParams},
  160.    {SQL_API_SQLPRIMARYKEYS,          (LPSTR)szODBC,    idsSQLPrimaryKeys},
  161.    {SQL_API_SQLPROCEDURECOLUMNS,     (LPSTR)szODBC,    idsSQLProcedureColumns},
  162.    {SQL_API_SQLPROCEDURES,           (LPSTR)szODBC,    idsSQLProcedures},
  163.    {SQL_API_SQLSETPOS,               (LPSTR)szODBC,    idsSQLSetPos},
  164.    {SQL_API_SQLTABLEPRIVILEGES,      (LPSTR)szODBC,    idsSQLTablePrivileges},
  165.    //---- Deprecated ----------------------------------------
  166.    {SQL_API_SQLALLOCCONNECT,         (LPSTR)szDepr,    idsSQLAllocConnect},
  167.    {SQL_API_SQLALLOCENV,             (LPSTR)szDepr,    idsSQLAllocEnv},
  168.    {SQL_API_SQLALLOCSTMT,            (LPSTR)szDepr,    idsSQLAllocStmt},
  169.    {SQL_API_SQLBINDPARAM,            (LPSTR)szDepr,    idsSQLBindParam},
  170.    {SQL_API_SQLCOLATTRIBUTES,        (LPSTR)szDepr,    idsSQLColAttributes},
  171.    {SQL_API_SQLERROR,                (LPSTR)szDepr,    idsSQLError},
  172.    {SQL_API_SQLEXTENDEDFETCH,        (LPSTR)szDepr,    idsSQLExtendedFetch},
  173.    {SQL_API_SQLFREECONNECT,          (LPSTR)szDepr,    idsSQLFreeConnect},
  174.    {SQL_API_SQLFREEENV,              (LPSTR)szDepr,    idsSQLFreeEnv},
  175.    {SQL_API_SQLGETCONNECTOPTION,     (LPSTR)szDepr,    idsSQLGetConnectOption},
  176.    {SQL_API_SQLGETSTMTOPTION,        (LPSTR)szDepr,    idsSQLGetStmtOption},
  177.    {SQL_API_SQLPARAMOPTIONS,         (LPSTR)szDepr,    idsSQLParamOptions},
  178.    {SQL_API_SQLSETCONNECTOPTION,     (LPSTR)szDepr,    idsSQLSetConnectOption},
  179.    {SQL_API_SQLSETPARAM,             (LPSTR)szDepr,    idsSQLSetParam},
  180.    {SQL_API_SQLSETSCROLLOPTIONS,     (LPSTR)szDepr,    idsSQLSetScrollOptions},
  181.    {SQL_API_SQLSETSTMTOPTION,        (LPSTR)szDepr,    idsSQLSetStmtOption},
  182.    {SQL_API_SQLTRANSACT,             (LPSTR)szDepr,    idsSQLTransact},
  183.    };
  184. //
  185. // Generic prototype for bitmap and value lists
  186. // 
  187. // This structure is used for to locate both bitmap and enumeration values.
  188. // Values may appear in the list in any order.  If a value is aliased, the
  189. // second value in an enumeration list will not be found; however, a bitmap
  190. // entry would show both aliases as being set.
  191. //
  192. typedef struct tagINFOSTRUCT {
  193.    UDWORD         fVal;                      // Which constant
  194.    LPSTR          szStr;                     // Print String
  195.    } INFOSTRUCT;
  196. typedef INFOSTRUCT FAR * lpINFOSTRUCT;
  197. //
  198. // This macro is used to build rows of the INFOSTRUCT arrays
  199. // guaranteeing that the "print" string is the same as the
  200. // INFO manifest constant.
  201. //
  202. #define INFO_VALUE_ROW(tag) {tag, #tag}
  203. //
  204. // Structure for SQL_ALTER_DOMAIN
  205. //
  206. static INFOSTRUCT GetInfoAlterDomain[] = {
  207. INFO_VALUE_ROW( SQL_AD_ADD_DOMAIN_CONSTRAINT               ),
  208. INFO_VALUE_ROW( SQL_AD_DROP_DOMAIN_CONSTRAINT              ),
  209. INFO_VALUE_ROW( SQL_AD_ADD_DOMAIN_DEFAULT                  ),
  210. INFO_VALUE_ROW( SQL_AD_DROP_DOMAIN_DEFAULT                 ),
  211. INFO_VALUE_ROW( SQL_AD_ADD_CONSTRAINT_INITIALLY_DEFERRED   ),
  212. INFO_VALUE_ROW( SQL_AD_ADD_CONSTRAINT_INITIALLY_IMMEDIATE  ),
  213. INFO_VALUE_ROW( SQL_AD_ADD_CONSTRAINT_DEFERRABLE           ),
  214. INFO_VALUE_ROW( SQL_AD_ADD_CONSTRAINT_NON_DEFERRABLE       ),
  215. };
  216. //
  217. // Structure for SQL_ALTER_TABLE
  218. //
  219. static INFOSTRUCT GetInfoAlterTable[] = {
  220. INFO_VALUE_ROW( SQL_AT_ADD_COLUMN_SINGLE                   ),
  221. INFO_VALUE_ROW( SQL_AT_ADD_CONSTRAINT                      ),
  222. INFO_VALUE_ROW( SQL_AT_ADD_COLUMN_DEFAULT                  ),
  223. INFO_VALUE_ROW( SQL_AT_ADD_COLUMN_COLLATION                ),
  224. INFO_VALUE_ROW( SQL_AT_SET_COLUMN_DEFAULT                  ),
  225. INFO_VALUE_ROW( SQL_AT_DROP_COLUMN_DEFAULT                 ),
  226. INFO_VALUE_ROW( SQL_AT_DROP_COLUMN_CASCADE                 ),
  227. INFO_VALUE_ROW( SQL_AT_DROP_COLUMN_RESTRICT                ),
  228. INFO_VALUE_ROW( SQL_AT_ADD_TABLE_CONSTRAINT                ),
  229. INFO_VALUE_ROW( SQL_AT_DROP_TABLE_CONSTRAINT_CASCADE       ),
  230. INFO_VALUE_ROW( SQL_AT_DROP_TABLE_CONSTRAINT_RESTRICT      ),
  231. INFO_VALUE_ROW( SQL_AT_CONSTRAINT_NAME_DEFINITION          ),
  232. INFO_VALUE_ROW( SQL_AT_CONSTRAINT_INITIALLY_DEFERRED       ),
  233. INFO_VALUE_ROW( SQL_AT_CONSTRAINT_INITIALLY_IMMEDIATE      ),
  234. INFO_VALUE_ROW( SQL_AT_CONSTRAINT_DEFERRABLE               ),
  235. INFO_VALUE_ROW( SQL_AT_CONSTRAINT_NON_DEFERRABLE           ),
  236. };
  237. //
  238. // Structure for SQL_ANSI_ASYNC_MODE
  239. //
  240. static INFOSTRUCT GetInfoAsyncMode[] = {
  241. INFO_VALUE_ROW( SQL_AM_NONE                                ),
  242. INFO_VALUE_ROW( SQL_AM_CONNECTION                          ),
  243. INFO_VALUE_ROW( SQL_AM_STATEMENT                           ),
  244. };
  245. //
  246. // Structure for SQL_BATCH_ROW_COUNT
  247. //
  248. static INFOSTRUCT GetInfoBatchRowCount[] = {
  249. INFO_VALUE_ROW( SQL_BRC_ROLLED_UP                          ),
  250. INFO_VALUE_ROW( SQL_BRC_PROCEDURES                         ),
  251. INFO_VALUE_ROW( SQL_BRC_EXPLICIT                           ),
  252. };
  253. //
  254. // Structure for SQL_BATCH_SUPPORT
  255. //
  256. static INFOSTRUCT GetInfoBatchSupport[] = {
  257. INFO_VALUE_ROW( SQL_BS_SELECT_EXPLICIT                     ),
  258. INFO_VALUE_ROW( SQL_BS_ROW_COUNT_EXPLICIT                  ),
  259. INFO_VALUE_ROW( SQL_BS_SELECT_PROC                         ),
  260. INFO_VALUE_ROW( SQL_BS_ROW_COUNT_PROC                      ),
  261. };
  262. //
  263. // Structure for SQL_BOOKMARK_PERSISTENCE
  264. //
  265. static INFOSTRUCT GetInfoBookmarkPersist[] = {
  266. INFO_VALUE_ROW( SQL_BP_CLOSE                               ),
  267. INFO_VALUE_ROW( SQL_BP_DELETE                              ),
  268. INFO_VALUE_ROW( SQL_BP_DROP                                ),
  269. INFO_VALUE_ROW( SQL_BP_TRANSACTION                         ),
  270. INFO_VALUE_ROW( SQL_BP_UPDATE                              ),
  271. INFO_VALUE_ROW( SQL_BP_OTHER_HSTMT                         ),
  272. };
  273. //
  274. // Structure for SQL_CATALOG_LOCATION
  275. //
  276. static INFOSTRUCT GetInfoCatLocation[] = {
  277. INFO_VALUE_ROW( SQL_CL_START                               ),
  278. INFO_VALUE_ROW( SQL_CL_END                                 ),
  279. };
  280. //
  281. // Structure for SQL_CATALOG_USAGE
  282. //
  283. static INFOSTRUCT GetInfoCatUsage[] = {
  284. INFO_VALUE_ROW( SQL_CU_DML_STATEMENTS                      ),
  285. INFO_VALUE_ROW( SQL_CU_PROCEDURE_INVOCATION                ),
  286. INFO_VALUE_ROW( SQL_CU_TABLE_DEFINITION                    ),
  287. INFO_VALUE_ROW( SQL_CU_INDEX_DEFINITION                    ),
  288. INFO_VALUE_ROW( SQL_CU_PRIVILEGE_DEFINITION                ),
  289. };
  290. //
  291. // Structure for SQL_CONCAT_NULL_BEHAVIOR
  292. //
  293. static INFOSTRUCT GetInfoConcat[] = {
  294. INFO_VALUE_ROW( SQL_CB_NULL                                ),
  295. INFO_VALUE_ROW( SQL_CB_NON_NULL                            ),
  296. };
  297. //
  298. // Structure for SQL_CONVERT_xxxx
  299. //
  300. static INFOSTRUCT GetInfoConvertTypes[] = {
  301. INFO_VALUE_ROW( SQL_CVT_BIGINT                             ),
  302. INFO_VALUE_ROW( SQL_CVT_BINARY                             ),
  303. INFO_VALUE_ROW( SQL_CVT_BIT                                ),
  304. INFO_VALUE_ROW( SQL_CVT_CHAR                               ),
  305. INFO_VALUE_ROW( SQL_CVT_DATE                               ),
  306. INFO_VALUE_ROW( SQL_CVT_DECIMAL                            ),
  307. INFO_VALUE_ROW( SQL_CVT_DOUBLE                             ),
  308. INFO_VALUE_ROW( SQL_CVT_FLOAT                              ),
  309. INFO_VALUE_ROW( SQL_CVT_INTEGER                            ),
  310. INFO_VALUE_ROW( SQL_CVT_INTERVAL_YEAR_MONTH                ),
  311. INFO_VALUE_ROW( SQL_CVT_INTERVAL_DAY_TIME                  ),
  312. INFO_VALUE_ROW( SQL_CVT_LONGVARBINARY                      ),
  313. INFO_VALUE_ROW( SQL_CVT_LONGVARCHAR                        ),
  314. INFO_VALUE_ROW( SQL_CVT_NUMERIC                            ),
  315. INFO_VALUE_ROW( SQL_CVT_REAL                               ),
  316. INFO_VALUE_ROW( SQL_CVT_SMALLINT                           ),
  317. INFO_VALUE_ROW( SQL_CVT_TIME                               ),
  318. INFO_VALUE_ROW( SQL_CVT_TIMESTAMP                          ),
  319. INFO_VALUE_ROW( SQL_CVT_TINYINT                            ),
  320. INFO_VALUE_ROW( SQL_CVT_VARBINARY                          ),
  321. INFO_VALUE_ROW( SQL_CVT_VARCHAR                            ),
  322. INFO_VALUE_ROW( SQL_CVT_WCHAR                              ),
  323. INFO_VALUE_ROW( SQL_CVT_WLONGVARCHAR                       ),
  324. INFO_VALUE_ROW( SQL_CVT_WVARCHAR                           ),
  325. };
  326. //
  327. // Structure for SQL_CONVERT_FUNCTIONS
  328. //
  329. static INFOSTRUCT GetInfoConvertFunctions[] = {
  330. INFO_VALUE_ROW( SQL_FN_CVT_CAST                            ),
  331. INFO_VALUE_ROW( SQL_FN_CVT_CONVERT                         ),
  332. };
  333. //
  334. // Structure for SQL_CORRELATION_NAME
  335. //
  336. static INFOSTRUCT GetInfoCorrelationName[] = {
  337. INFO_VALUE_ROW( SQL_CN_NONE                                ),
  338. INFO_VALUE_ROW( SQL_CN_DIFFERENT                           ),
  339. INFO_VALUE_ROW( SQL_CN_ANY                                 ),
  340. };
  341. //
  342. // Structure for SQL_CREATE_ASSERTION
  343. //
  344. static INFOSTRUCT GetInfoCreateAssertion[] = {
  345. INFO_VALUE_ROW( SQL_CA_CREATE_ASSERTION                    ),
  346. INFO_VALUE_ROW( SQL_CA_CONSTRAINT_INITIALLY_DEFERRED       ),
  347. INFO_VALUE_ROW( SQL_CA_CONSTRAINT_INITIALLY_IMMEDIATE      ),
  348. INFO_VALUE_ROW( SQL_CA_CONSTRAINT_DEFERRABLE               ),
  349. INFO_VALUE_ROW( SQL_CA_CONSTRAINT_NON_DEFERRABLE           ),
  350. };
  351. //
  352. // Structure for SQL_CREATE_CHARACTER_SET
  353. //
  354. static INFOSTRUCT GetInfoCreateCharset[] = {
  355. INFO_VALUE_ROW( SQL_CCS_CREATE_CHARACTER_SET               ),
  356. INFO_VALUE_ROW( SQL_CCS_COLLATE_CLAUSE                     ),
  357. INFO_VALUE_ROW( SQL_CCS_LIMITED_COLLATION                  ),
  358. };
  359. //
  360. // Structure for SQL_CREATE_COLLATION
  361. //
  362. static INFOSTRUCT GetInfoCreateCollation[] = {
  363. INFO_VALUE_ROW( SQL_CCOL_CREATE_COLLATION                  ),
  364. };
  365. //
  366. // Structure for SQL_CREATE_DOMAIN
  367. //
  368. static INFOSTRUCT GetInfoCreateDomain[] = {
  369. INFO_VALUE_ROW( SQL_CDO_CREATE_DOMAIN                      ),
  370. INFO_VALUE_ROW( SQL_CDO_CONSTRAINT                         ),
  371. INFO_VALUE_ROW( SQL_CDO_DEFAULT                            ),
  372. INFO_VALUE_ROW( SQL_CDO_COLLATION                          ),
  373. INFO_VALUE_ROW( SQL_CDO_CONSTRAINT_NAME_DEFINITION         ),
  374. INFO_VALUE_ROW( SQL_CDO_CONSTRAINT_INITIALLY_DEFERRED      ),
  375. INFO_VALUE_ROW( SQL_CDO_CONSTRAINT_INITIALLY_IMMEDIATE     ),
  376. INFO_VALUE_ROW( SQL_CDO_CONSTRAINT_DEFERRABLE              ),
  377. INFO_VALUE_ROW( SQL_CDO_CONSTRAINT_NON_DEFERRABLE          ),
  378. };
  379. //
  380. // Structure for SQL_CREATE_SCHEMA
  381. //
  382. static INFOSTRUCT GetInfoCreateSchema[] = {
  383. INFO_VALUE_ROW( SQL_CS_CREATE_SCHEMA                       ),
  384. INFO_VALUE_ROW( SQL_CS_AUTHORIZATION                       ),
  385. INFO_VALUE_ROW( SQL_CS_DEFAULT_CHARACTER_SET               ),
  386. };
  387. //
  388. // Structure for SQL_CREATE_TABLE
  389. //
  390. static INFOSTRUCT GetInfoCreateTable[] = {
  391. INFO_VALUE_ROW( SQL_CT_COMMIT_PRESERVE                     ),
  392. INFO_VALUE_ROW( SQL_CT_COMMIT_DELETE                       ),
  393. INFO_VALUE_ROW( SQL_CT_GLOBAL_TEMPORARY                    ),
  394. INFO_VALUE_ROW( SQL_CT_LOCAL_TEMPORARY                     ),
  395. INFO_VALUE_ROW( SQL_CT_CONSTRAINT_INITIALLY_DEFERRED       ),
  396. INFO_VALUE_ROW( SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE      ),
  397. INFO_VALUE_ROW( SQL_CT_CONSTRAINT_DEFERRABLE               ),
  398. INFO_VALUE_ROW( SQL_CT_CONSTRAINT_NON_DEFERRABLE           ),
  399. };
  400. //
  401. // Structure for SQL_CREATE_TRANSLATION
  402. //
  403. static INFOSTRUCT GetInfoCreateXlation[] = {
  404. INFO_VALUE_ROW( SQL_CTR_CREATE_TRANSLATION                 ),
  405. };
  406. //
  407. // Structure for SQL_CREATE_VIEW
  408. //
  409. static INFOSTRUCT GetInfoCreateView[] = {
  410. INFO_VALUE_ROW( SQL_CV_CREATE_VIEW                         ),
  411. INFO_VALUE_ROW( SQL_CV_CHECK_OPTION                        ),
  412. INFO_VALUE_ROW( SQL_CV_CASCADED                            ),
  413. INFO_VALUE_ROW( SQL_CV_LOCAL                               ),
  414. };
  415. //
  416. // Structure for SQL_CURSOR_COMMIT_BEHAVIOR,
  417. //               SQL_CURSOR_ROLLBACK_BEHAVIOR
  418. //
  419. static INFOSTRUCT GetInfoCommit[] = {
  420. INFO_VALUE_ROW( SQL_CB_DELETE                              ),
  421. INFO_VALUE_ROW( SQL_CB_CLOSE                               ),
  422. INFO_VALUE_ROW( SQL_CB_PRESERVE                            ),
  423. };
  424. //
  425. // Structure for SQL_CURSOR_SENSITIVITY
  426. //
  427. static INFOSTRUCT GetInfoCursorSensitiv[] = {
  428. INFO_VALUE_ROW( SQL_INSENSITIVE                            ),
  429. INFO_VALUE_ROW( SQL_UNSPECIFIED                            ),
  430. INFO_VALUE_ROW( SQL_SENSITIVE                              ),
  431. };
  432. //
  433. // Structure for SQL_DEFAULT_TXN_ISOLATION
  434. //
  435. static INFOSTRUCT GetInfoTXNIsolation[] = {
  436. INFO_VALUE_ROW( SQL_TXN_READ_UNCOMMITTED                   ),
  437. INFO_VALUE_ROW( SQL_TXN_READ_COMMITTED                     ),
  438. INFO_VALUE_ROW( SQL_TXN_REPEATABLE_READ                    ),
  439. INFO_VALUE_ROW( SQL_TXN_SERIALIZABLE                       ),
  440. };
  441. //
  442. // Structure for SQL_*_CURSOR_ATTRIBUTES1
  443. //
  444. static INFOSTRUCT GetInfoCurAttrs1[] = {
  445. INFO_VALUE_ROW( SQL_CA1_NEXT                               ),
  446. INFO_VALUE_ROW( SQL_CA1_ABSOLUTE                           ),
  447. INFO_VALUE_ROW( SQL_CA1_RELATIVE                           ),
  448. INFO_VALUE_ROW( SQL_CA1_BOOKMARK                           ),
  449. INFO_VALUE_ROW( SQL_CA1_LOCK_NO_CHANGE                     ),
  450. INFO_VALUE_ROW( SQL_CA1_LOCK_UNLOCK                        ),
  451. INFO_VALUE_ROW( SQL_CA1_POS_POSITION                       ),
  452. INFO_VALUE_ROW( SQL_CA1_POS_UPDATE                         ),
  453. INFO_VALUE_ROW( SQL_CA1_POS_DELETE                         ),
  454. INFO_VALUE_ROW( SQL_CA1_POS_REFRESH                        ),
  455. INFO_VALUE_ROW( SQL_CA1_POSITIONED_UPDATE                  ),
  456. INFO_VALUE_ROW( SQL_CA1_POSITIONED_DELETE                  ),
  457. INFO_VALUE_ROW( SQL_CA1_SELECT_FOR_UPDATE                  ),
  458. INFO_VALUE_ROW( SQL_CA1_BULK_ADD                           ),
  459. INFO_VALUE_ROW( SQL_CA1_BULK_UPDATE_BY_BOOKMARK            ),
  460. INFO_VALUE_ROW( SQL_CA1_BULK_DELETE_BY_BOOKMARK            ),
  461. INFO_VALUE_ROW( SQL_CA1_BULK_FETCH_BY_BOOKMARK             ),
  462. };
  463. //
  464. // Structure for SQL_*_CURSOR_ATTRIBUTES2
  465. //
  466. static INFOSTRUCT GetInfoCurAttrs2[] = {
  467. INFO_VALUE_ROW( SQL_CA2_READ_ONLY_CONCURRENCY              ),
  468. INFO_VALUE_ROW( SQL_CA2_LOCK_CONCURRENCY                   ),
  469. INFO_VALUE_ROW( SQL_CA2_OPT_ROWVER_CONCURRENCY             ),
  470. INFO_VALUE_ROW( SQL_CA2_OPT_VALUES_CONCURRENCY             ),
  471. INFO_VALUE_ROW( SQL_CA2_SENSITIVITY_ADDITIONS              ),
  472. INFO_VALUE_ROW( SQL_CA2_SENSITIVITY_DELETIONS              ),
  473. INFO_VALUE_ROW( SQL_CA2_SENSITIVITY_UPDATES                ),
  474. INFO_VALUE_ROW( SQL_CA2_MAX_ROWS_SELECT                    ),
  475. INFO_VALUE_ROW( SQL_CA2_MAX_ROWS_INSERT                    ),
  476. INFO_VALUE_ROW( SQL_CA2_MAX_ROWS_UPDATE                    ),
  477. INFO_VALUE_ROW( SQL_CA2_MAX_ROWS_DELETE                    ),
  478. INFO_VALUE_ROW( SQL_CA2_MAX_ROWS_CATALOG                   ),
  479. INFO_VALUE_ROW( SQL_CA2_MAX_ROWS_AFFECTS_ALL               ),
  480. INFO_VALUE_ROW( SQL_CA2_CRC_EXACT                          ),
  481. INFO_VALUE_ROW( SQL_CA2_CRC_APPROXIMATE                    ),
  482. INFO_VALUE_ROW( SQL_CA2_SIMULATE_NON_UNIQUE                ),
  483. INFO_VALUE_ROW( SQL_CA2_SIMULATE_TRY_UNIQUE                ),
  484. INFO_VALUE_ROW( SQL_CA2_SIMULATE_UNIQUE                    ),
  485. };
  486. //
  487. // Structure for SQL_DATETIME_LITERALS
  488. //
  489. static INFOSTRUCT GetInfoSQLDateLit[] = {
  490. INFO_VALUE_ROW( SQL_DL_SQL92_DATE                          ),
  491. INFO_VALUE_ROW( SQL_DL_SQL92_TIME                          ),
  492. INFO_VALUE_ROW( SQL_DL_SQL92_TIMESTAMP                     ),
  493. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_YEAR                 ),
  494. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_MONTH                ),
  495. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_DAY                  ),
  496. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_HOUR                 ),
  497. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_MINUTE               ),
  498. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_SECOND               ),
  499. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH        ),
  500. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR          ),
  501. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE        ),
  502. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND        ),
  503. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE       ),
  504. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND       ),
  505. INFO_VALUE_ROW( SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND     ),
  506. };
  507. //
  508. // Structure for SQL_DROP_ASSERTION
  509. //
  510. static INFOSTRUCT GetInfoDropAssertion[] = {
  511. INFO_VALUE_ROW( SQL_DA_DROP_ASSERTION                      ),
  512. };
  513. //
  514. // Structure for SQL_DROP_CHARACTER_SET
  515. //
  516. static INFOSTRUCT GetInfoDropCharset[] = {
  517. INFO_VALUE_ROW( SQL_DCS_DROP_CHARACTER_SET                 ),
  518. };
  519. //
  520. // Structure for SQL_DROP_COLLATION
  521. //
  522. static INFOSTRUCT GetInfoDropCollation[] = {
  523. INFO_VALUE_ROW( SQL_DC_DROP_COLLATION                      ),
  524. };
  525. //
  526. // Structure for SQL_DROP_DOMAIN
  527. //
  528. static INFOSTRUCT GetInfoDropDomain[] = {
  529. INFO_VALUE_ROW( SQL_DD_DROP_DOMAIN                         ),
  530. INFO_VALUE_ROW( SQL_DD_CASCADE                             ),
  531. INFO_VALUE_ROW( SQL_DD_RESTRICT                            ),
  532. };
  533. //
  534. // Structure for SQL_DROP_SCHEMA
  535. //
  536. static INFOSTRUCT GetInfoDropSchema[] = {
  537. INFO_VALUE_ROW( SQL_DS_DROP_SCHEMA                         ),
  538. INFO_VALUE_ROW( SQL_DS_CASCADE                             ),
  539. INFO_VALUE_ROW( SQL_DS_RESTRICT                            ),
  540. };
  541. //
  542. // Structure for SQL_DROP_TABLE
  543. //
  544. static INFOSTRUCT GetInfoDropTable[] = {
  545. INFO_VALUE_ROW( SQL_DT_DROP_TABLE                          ),
  546. INFO_VALUE_ROW( SQL_DT_CASCADE                             ),
  547. INFO_VALUE_ROW( SQL_DT_RESTRICT                            ),
  548. };
  549. //
  550. // Structure for SQL_DROP_TRANSLATION
  551. //
  552. static INFOSTRUCT GetInfoDropXlation[] = {
  553. INFO_VALUE_ROW( SQL_DTR_DROP_TRANSLATION                   ),
  554. };
  555. //
  556. // Structure for SQL_DROP_VIEW
  557. //
  558. static INFOSTRUCT GetInfoDropView[] = {
  559. INFO_VALUE_ROW( SQL_DV_DROP_VIEW                           ),
  560. INFO_VALUE_ROW( SQL_DV_CASCADE                             ),
  561. INFO_VALUE_ROW( SQL_DV_RESTRICT                            ),
  562. };
  563. //
  564. // Structure for SQL_FILE_USAGE
  565. //
  566. static INFOSTRUCT GetInfoFileUsage[] = {
  567. INFO_VALUE_ROW( SQL_FILE_NOT_SUPPORTED                     ),
  568. INFO_VALUE_ROW( SQL_FILE_TABLE                             ),
  569. INFO_VALUE_ROW( SQL_FILE_CATALOG                           ),
  570. };
  571. //
  572. // Structure for SQL_GETDATA_EXTENSIONS
  573. //
  574. static INFOSTRUCT GetInfoGetdataExt[] = {
  575. INFO_VALUE_ROW( SQL_GD_ANY_COLUMN                          ),
  576. INFO_VALUE_ROW( SQL_GD_ANY_ORDER                           ),
  577. INFO_VALUE_ROW( SQL_GD_BLOCK                               ),
  578. INFO_VALUE_ROW( SQL_GD_BOUND                               ),
  579. };
  580. //
  581. // Structure for SQL_GROUP_BY
  582. //
  583. static INFOSTRUCT GetInfoGroupBy[] = {
  584. INFO_VALUE_ROW( SQL_GB_NOT_SUPPORTED                       ),
  585. INFO_VALUE_ROW( SQL_GB_GROUP_BY_EQUALS_SELECT              ),
  586. INFO_VALUE_ROW( SQL_GB_GROUP_BY_CONTAINS_SELECT            ),
  587. INFO_VALUE_ROW( SQL_GB_NO_RELATION                         ),
  588. INFO_VALUE_ROW( SQL_GB_COLLATE                             ),
  589. };
  590. //
  591. // Structure for SQL_INDEX_KEYWORDS
  592. //
  593. static INFOSTRUCT GetInfoIndexKeywords[] = {
  594. INFO_VALUE_ROW( SQL_IK_NONE                                ),
  595. INFO_VALUE_ROW( SQL_IK_ASC                                 ),
  596. INFO_VALUE_ROW( SQL_IK_DESC                                ),
  597. INFO_VALUE_ROW( SQL_IK_ALL                                 ),
  598. };
  599. //
  600. // Structure for SQL_INFO_SCHEMA_VIEWS
  601. //
  602. static INFOSTRUCT GetInfoInfoSchemaViews[] = {
  603. INFO_VALUE_ROW( SQL_ISV_ASSERTIONS                         ),
  604. INFO_VALUE_ROW( SQL_ISV_CHARACTER_SETS                     ),
  605. INFO_VALUE_ROW( SQL_ISV_CHECK_CONSTRAINTS                  ),
  606. INFO_VALUE_ROW( SQL_ISV_COLLATIONS                         ),
  607. INFO_VALUE_ROW( SQL_ISV_COLUMN_DOMAIN_USAGE                ),
  608. INFO_VALUE_ROW( SQL_ISV_COLUMN_PRIVILEGES                  ),
  609. INFO_VALUE_ROW( SQL_ISV_COLUMNS                            ),
  610. INFO_VALUE_ROW( SQL_ISV_CONSTRAINT_COLUMN_USAGE            ),
  611. INFO_VALUE_ROW( SQL_ISV_CONSTRAINT_TABLE_USAGE             ),
  612. INFO_VALUE_ROW( SQL_ISV_ASSERTIONS                         ),
  613. INFO_VALUE_ROW( SQL_ISV_DOMAIN_CONSTRAINTS                 ),
  614. INFO_VALUE_ROW( SQL_ISV_DOMAINS                            ),
  615. INFO_VALUE_ROW( SQL_ISV_KEY_COLUMN_USAGE                   ),
  616. INFO_VALUE_ROW( SQL_ISV_REFERENTIAL_CONSTRAINTS            ),
  617. INFO_VALUE_ROW( SQL_ISV_SQL_LANGUAGES                      ),
  618. INFO_VALUE_ROW( SQL_ISV_TABLE_CONSTRAINTS                  ),
  619. INFO_VALUE_ROW( SQL_ISV_TABLE_PRIVILEGES                   ),
  620. INFO_VALUE_ROW( SQL_ISV_TABLES                             ),
  621. INFO_VALUE_ROW( SQL_ISV_TRANSLATIONS                       ),
  622. INFO_VALUE_ROW( SQL_ISV_USAGE_PRIVILEGES                   ),
  623. INFO_VALUE_ROW( SQL_ISV_VIEW_COLUMN_USAGE                  ),
  624. INFO_VALUE_ROW( SQL_ISV_VIEW_TABLE_USAGE                   ),
  625. INFO_VALUE_ROW( SQL_ISV_VIEWS                              ),
  626. };
  627. //
  628. // Structure for SQL_NON_NULLABLE_COLUMNS
  629. //
  630. static INFOSTRUCT GetInfoNonNullCols[] = {
  631. INFO_VALUE_ROW( SQL_NNC_NULL                               ),
  632. INFO_VALUE_ROW( SQL_NNC_NON_NULL                           ),
  633. };
  634. //
  635. // Structure for SQL_NULL_COLLATION
  636. //
  637. static INFOSTRUCT GetInfoNullCollation[] = {
  638. INFO_VALUE_ROW( SQL_NC_END                                 ),
  639. INFO_VALUE_ROW( SQL_NC_HIGH                                ),
  640. INFO_VALUE_ROW( SQL_NC_LOW                                 ),
  641. INFO_VALUE_ROW( SQL_NC_START                               ),
  642. };
  643. //
  644. // Structure for SQL_PARAM_ARRAY_ROW_COUNTS
  645. //
  646. static INFOSTRUCT GetInfoParamRowCounts[] = {
  647. INFO_VALUE_ROW( SQL_PARC_BATCH                             ),
  648. INFO_VALUE_ROW( SQL_PARC_NO_BATCH                          ),
  649. };
  650. //
  651. // Structure for SQL_PARAM_ARRAY_SELECTS
  652. //
  653. static INFOSTRUCT GetInfoParamSelects[] = {
  654. INFO_VALUE_ROW( SQL_PAS_BATCH                              ),
  655. INFO_VALUE_ROW( SQL_PAS_NO_BATCH                           ),
  656. INFO_VALUE_ROW( SQL_PAS_NO_SELECT                          ),
  657. };
  658. //
  659. // Structure for SQL_SCHEMA_USAGE
  660. //
  661. static INFOSTRUCT GetInfoSchemaUsage[] = {
  662. INFO_VALUE_ROW( SQL_SU_DML_STATEMENTS                      ),
  663. INFO_VALUE_ROW( SQL_SU_PROCEDURE_INVOCATION                ),
  664. INFO_VALUE_ROW( SQL_SU_TABLE_DEFINITION                    ),
  665. INFO_VALUE_ROW( SQL_SU_INDEX_DEFINITION                    ),
  666. INFO_VALUE_ROW( SQL_SU_PRIVILEGE_DEFINITION                ),
  667. };
  668. //
  669. // Structure for SQL_SCROLL_OPTIONS
  670. //
  671. static INFOSTRUCT GetInfoScrollOptions[] = {
  672. INFO_VALUE_ROW( SQL_SO_FORWARD_ONLY                        ),
  673. INFO_VALUE_ROW( SQL_SO_KEYSET_DRIVEN                       ),
  674. INFO_VALUE_ROW( SQL_SO_DYNAMIC                             ),
  675. INFO_VALUE_ROW( SQL_SO_MIXED                               ),
  676. };
  677. //
  678. // Structure for SQL_SQL_CONFORMANCE
  679. //
  680. static INFOSTRUCT GetInfoSQLConform[] = {
  681. INFO_VALUE_ROW( SQL_SC_SQL92_ENTRY                         ),
  682. INFO_VALUE_ROW( SQL_SC_FIPS127_2_TRANSITIONAL              ),
  683. INFO_VALUE_ROW( SQL_SC_SQL92_FULL                          ),
  684. INFO_VALUE_ROW( SQL_SC_SQL92_INTERMEDIATE                  ),
  685. };
  686. //
  687. // Structure for SQL_SQL92_DATETIME_FUNCTIONS
  688. //
  689. static INFOSTRUCT GetInfoS92DatetimeFns[] = {
  690. INFO_VALUE_ROW( SQL_SDF_CURRENT_DATE                       ),
  691. INFO_VALUE_ROW( SQL_SDF_CURRENT_TIME                       ),
  692. INFO_VALUE_ROW( SQL_SDF_CURRENT_TIMESTAMP                  ),
  693. };
  694. //
  695. // Structure for SQL_SQL92_FOREIGN_KEY_DELETE_RULE
  696. //
  697. static INFOSTRUCT GetInfoS92FKeyDelRule[] = {
  698. INFO_VALUE_ROW( SQL_SFKD_CASCADE                           ),
  699. INFO_VALUE_ROW( SQL_SFKD_NO_ACTION                         ),
  700. INFO_VALUE_ROW( SQL_SFKD_SET_DEFAULT                       ),
  701. INFO_VALUE_ROW( SQL_SFKD_SET_NULL                          ),
  702. };
  703. //
  704. // Structure for SQL_SQL92_FOREIGN_KEY_UPDATE_RULE
  705. //
  706. static INFOSTRUCT GetInfoS92FKeyUpdRule[] = {
  707. INFO_VALUE_ROW( SQL_SFKU_CASCADE                           ),
  708. INFO_VALUE_ROW( SQL_SFKU_NO_ACTION                         ),
  709. INFO_VALUE_ROW( SQL_SFKU_SET_DEFAULT                       ),
  710. INFO_VALUE_ROW( SQL_SFKU_SET_NULL                          ),
  711. };
  712. //
  713. // Structure for SQL_SQL92_GRANT
  714. //
  715. static INFOSTRUCT GetInfoS92Grant[] = {
  716. INFO_VALUE_ROW( SQL_SG_USAGE_ON_DOMAIN                     ),
  717. INFO_VALUE_ROW( SQL_SG_USAGE_ON_CHARACTER_SET              ),
  718. INFO_VALUE_ROW( SQL_SG_USAGE_ON_COLLATION                  ),
  719. INFO_VALUE_ROW( SQL_SG_USAGE_ON_TRANSLATION                ),
  720. INFO_VALUE_ROW( SQL_SG_WITH_GRANT_OPTION                   ),
  721. };
  722. //
  723. // Structure for SQL_NUMERIC_FUNCTIONS
  724. //
  725. static INFOSTRUCT GetInfoNumeric[] = {
  726. INFO_VALUE_ROW( SQL_FN_NUM_ABS                             ),
  727. INFO_VALUE_ROW( SQL_FN_NUM_ACOS                            ),
  728. INFO_VALUE_ROW( SQL_FN_NUM_ASIN                            ),
  729. INFO_VALUE_ROW( SQL_FN_NUM_ATAN                            ),
  730. INFO_VALUE_ROW( SQL_FN_NUM_ATAN2                           ),
  731. INFO_VALUE_ROW( SQL_FN_NUM_CEILING                         ),
  732. INFO_VALUE_ROW( SQL_FN_NUM_COS                             ),
  733. INFO_VALUE_ROW( SQL_FN_NUM_COT                             ),
  734. INFO_VALUE_ROW( SQL_FN_NUM_EXP                             ),
  735. INFO_VALUE_ROW( SQL_FN_NUM_FLOOR                           ),
  736. INFO_VALUE_ROW( SQL_FN_NUM_LOG                             ),
  737. INFO_VALUE_ROW( SQL_FN_NUM_MOD                             ),
  738. INFO_VALUE_ROW( SQL_FN_NUM_RAND                            ),
  739. INFO_VALUE_ROW( SQL_FN_NUM_PI                              ),
  740. INFO_VALUE_ROW( SQL_FN_NUM_SIGN                            ),
  741. INFO_VALUE_ROW( SQL_FN_NUM_SIN                             ),
  742. INFO_VALUE_ROW( SQL_FN_NUM_SQRT                            ),
  743. INFO_VALUE_ROW( SQL_FN_NUM_TAN                             ),
  744. };
  745. //
  746. // Structure for SQL_SQL92_NUMERIC_VALUE_FUNCTIONS
  747. //
  748. static INFOSTRUCT GetInfoS92NumValFns[] = {
  749. INFO_VALUE_ROW( SQL_SNVF_BIT_LENGTH                        ),
  750. INFO_VALUE_ROW( SQL_SNVF_CHAR_LENGTH                       ),
  751. INFO_VALUE_ROW( SQL_SNVF_CHARACTER_LENGTH                  ),
  752. INFO_VALUE_ROW( SQL_SNVF_EXTRACT                           ),
  753. INFO_VALUE_ROW( SQL_SNVF_OCTET_LENGTH                      ),
  754. INFO_VALUE_ROW( SQL_SNVF_POSITION                          ),
  755. };
  756. //
  757. // Structure for SQL_SQL92_PREDICATES
  758. //
  759. static INFOSTRUCT GetInfoS92Predicates[] = {
  760. INFO_VALUE_ROW( SQL_SP_EXISTS                              ),
  761. INFO_VALUE_ROW( SQL_SP_ISNOTNULL                           ),
  762. INFO_VALUE_ROW( SQL_SP_ISNULL                              ),
  763. INFO_VALUE_ROW( SQL_SP_MATCH_FULL                          ),
  764. INFO_VALUE_ROW( SQL_SP_MATCH_PARTIAL                       ),
  765. INFO_VALUE_ROW( SQL_SP_MATCH_UNIQUE_FULL                   ),
  766. INFO_VALUE_ROW( SQL_SP_MATCH_UNIQUE_PARTIAL                ),
  767. INFO_VALUE_ROW( SQL_SP_OVERLAPS                            ),
  768. INFO_VALUE_ROW( SQL_SP_UNIQUE                              ),
  769. INFO_VALUE_ROW( SQL_SP_LIKE                                ),
  770. INFO_VALUE_ROW( SQL_SP_IN                                  ),
  771. INFO_VALUE_ROW( SQL_SP_BETWEEN                             ),
  772. INFO_VALUE_ROW( SQL_SP_COMPARISON                          ),
  773. INFO_VALUE_ROW( SQL_SP_QUANTIFIED_COMPARISON               ),
  774. };
  775. //
  776. // Structure for SQL_SQL92_RELATIONAL_JOIN_OPERATORS
  777. //
  778. static INFOSTRUCT GetInfoS92RelJoinOps[] = {
  779. INFO_VALUE_ROW( SQL_SRJO_CORRESPONDING_CLAUSE              ),
  780. INFO_VALUE_ROW( SQL_SRJO_CROSS_JOIN                        ),
  781. INFO_VALUE_ROW( SQL_SRJO_EXCEPT_JOIN                       ),
  782. INFO_VALUE_ROW( SQL_SRJO_FULL_OUTER_JOIN                   ),
  783. INFO_VALUE_ROW( SQL_SRJO_INNER_JOIN                        ),
  784. INFO_VALUE_ROW( SQL_SRJO_INTERSECT_JOIN                    ),
  785. INFO_VALUE_ROW( SQL_SRJO_LEFT_OUTER_JOIN                   ),
  786. INFO_VALUE_ROW( SQL_SRJO_NATURAL_JOIN                      ),
  787. INFO_VALUE_ROW( SQL_SRJO_RIGHT_OUTER_JOIN                  ),
  788. INFO_VALUE_ROW( SQL_SRJO_UNION_JOIN                        ),
  789. };
  790. //
  791. // Structure for SQL_SQL92_REVOKE
  792. //
  793. static INFOSTRUCT GetInfoS92Revoke[] = {
  794. INFO_VALUE_ROW( SQL_SR_USAGE_ON_DOMAIN                     ),
  795. INFO_VALUE_ROW( SQL_SR_USAGE_ON_CHARACTER_SET              ),
  796. INFO_VALUE_ROW( SQL_SR_USAGE_ON_COLLATION                  ),
  797. INFO_VALUE_ROW( SQL_SR_USAGE_ON_TRANSLATION                ),
  798. INFO_VALUE_ROW( SQL_SR_GRANT_OPTION_FOR                    ),
  799. };
  800. //
  801. // Structure for SQL_SQL92_ROW_VALUE_CONSTRUCTOR
  802. //
  803. static INFOSTRUCT GetInfoS92RowValConstr[] = {
  804. INFO_VALUE_ROW( SQL_SRVC_VALUE_EXPRESSION                  ),
  805. INFO_VALUE_ROW( SQL_SRVC_NULL                              ),
  806. INFO_VALUE_ROW( SQL_SRVC_DEFAULT                           ),
  807. INFO_VALUE_ROW( SQL_SRVC_ROW_SUBQUERY                      ),
  808. };
  809. //
  810. // Structure for SQL_SQL92_STRING_FUNCTIONS
  811. //
  812. static INFOSTRUCT GetInfoS92StringFns[] = {
  813. INFO_VALUE_ROW( SQL_SSF_CONVERT                            ),
  814. INFO_VALUE_ROW( SQL_SSF_LOWER                              ),
  815. INFO_VALUE_ROW( SQL_SSF_UPPER                              ),
  816. INFO_VALUE_ROW( SQL_SSF_SUBSTRING                          ),
  817. INFO_VALUE_ROW( SQL_SSF_TRANSLATE                          ),
  818. INFO_VALUE_ROW( SQL_SSF_TRIM_BOTH                          ),
  819. INFO_VALUE_ROW( SQL_SSF_TRIM_LEADING                       ),
  820. INFO_VALUE_ROW( SQL_SSF_TRIM_TRAILING                      ),
  821. };
  822. //
  823. // Structure for SQL_SQL92_VALUE_EXPRESSIONS
  824. //
  825. static INFOSTRUCT GetInfoS92ValueExprs[] = {
  826. INFO_VALUE_ROW( SQL_SVE_CASE                               ),
  827. INFO_VALUE_ROW( SQL_SVE_CAST                               ),
  828. INFO_VALUE_ROW( SQL_SVE_COALESCE                           ),
  829. INFO_VALUE_ROW( SQL_SVE_NULLIF                             ),
  830. };
  831. //
  832. // Structure for SQL_SQL92_STANDARD_CLI_CONFORMANCE
  833. //
  834. static INFOSTRUCT GetInfoS92StdCLIConf[] = {
  835. INFO_VALUE_ROW( SQL_SCC_XOPEN_CLI_VERSION1                 ),
  836. INFO_VALUE_ROW( SQL_SCC_ISO92_CLI                          ),
  837. };
  838. //
  839. // Structure for SQL_SUBQUERUIES
  840. //
  841. static INFOSTRUCT GetInfoSubqueries[] = {
  842. INFO_VALUE_ROW( SQL_SQ_CORRELATED_SUBQUERIES               ),
  843. INFO_VALUE_ROW( SQL_SQ_COMPARISON                          ),
  844. INFO_VALUE_ROW( SQL_SQ_EXISTS                              ),
  845. INFO_VALUE_ROW( SQL_SQ_IN                                  ),
  846. INFO_VALUE_ROW( SQL_SQ_QUANTIFIED                          ),
  847. };
  848. //
  849. // Structure for SQL_STRING_FUNCTIONS
  850. //
  851. static INFOSTRUCT GetInfoStrings[] = {
  852. INFO_VALUE_ROW( SQL_FN_STR_ASCII                                         ),
  853. INFO_VALUE_ROW( SQL_FN_STR_CHAR                            ),
  854. INFO_VALUE_ROW( SQL_FN_STR_CONCAT                          ),
  855. INFO_VALUE_ROW( SQL_FN_STR_INSERT                          ),
  856. INFO_VALUE_ROW( SQL_FN_STR_LCASE                           ),
  857. INFO_VALUE_ROW( SQL_FN_STR_LEFT                            ),
  858. INFO_VALUE_ROW( SQL_FN_STR_LENGTH                          ),
  859. INFO_VALUE_ROW( SQL_FN_STR_LOCATE                          ),
  860. INFO_VALUE_ROW( SQL_FN_STR_LTRIM                           ),
  861. INFO_VALUE_ROW( SQL_FN_STR_REPEAT                          ),
  862. INFO_VALUE_ROW( SQL_FN_STR_REPLACE                         ),
  863. INFO_VALUE_ROW( SQL_FN_STR_RIGHT                           ),
  864. INFO_VALUE_ROW( SQL_FN_STR_RTRIM                           ),
  865. INFO_VALUE_ROW( SQL_FN_STR_SUBSTRING                       ),
  866. INFO_VALUE_ROW( SQL_FN_STR_UCASE                           ),
  867. };
  868. //
  869. // Structure for SQL_SYSTEM_FUNCTIONS
  870. //
  871. static INFOSTRUCT GetInfoSystem[] = {
  872. INFO_VALUE_ROW( SQL_FN_SYS_DBNAME                          ),
  873. INFO_VALUE_ROW( SQL_FN_SYS_IFNULL                          ),
  874. INFO_VALUE_ROW( SQL_FN_SYS_USERNAME                        ),
  875. };
  876. //
  877. // Structure for SQL_TIMEDATE_FUNCTIONS
  878. //
  879. static INFOSTRUCT GetInfoTimeDate[] = {
  880. INFO_VALUE_ROW( SQL_FN_TD_CURDATE                          ),
  881. INFO_VALUE_ROW( SQL_FN_TD_CURRENT_DATE                     ),
  882. INFO_VALUE_ROW( SQL_FN_TD_CURRENT_TIME                     ),
  883. INFO_VALUE_ROW( SQL_FN_TD_CURRENT_TIMESTAMP                ),
  884. INFO_VALUE_ROW( SQL_FN_TD_CURTIME                          ),
  885. INFO_VALUE_ROW( SQL_FN_TD_DAYOFMONTH                       ),
  886. INFO_VALUE_ROW( SQL_FN_TD_DAYOFWEEK                        ),
  887. INFO_VALUE_ROW( SQL_FN_TD_DAYOFYEAR                        ),
  888. INFO_VALUE_ROW( SQL_FN_TD_EXTRACT                          ),
  889. INFO_VALUE_ROW( SQL_FN_TD_HOUR                             ),
  890. INFO_VALUE_ROW( SQL_FN_TD_MINUTE                           ),
  891. INFO_VALUE_ROW( SQL_FN_TD_MONTH                            ),
  892. INFO_VALUE_ROW( SQL_FN_TD_NOW                              ),
  893. INFO_VALUE_ROW( SQL_FN_TD_QUARTER                          ),
  894. INFO_VALUE_ROW( SQL_FN_TD_SECOND                           ),
  895. INFO_VALUE_ROW( SQL_FN_TD_WEEK                             ),
  896. INFO_VALUE_ROW( SQL_FN_TD_YEAR                             ),
  897. };
  898. //
  899. // Structure for SQL_TIMEDATE_ADD_INTERVALS,
  900. //               SQL_TIMEDATE_DIFF_INTERVALS,
  901. //
  902. static INFOSTRUCT GetInfoTimeDateIvls[] = {
  903. INFO_VALUE_ROW( SQL_FN_TSI_FRAC_SECOND                     ),
  904. INFO_VALUE_ROW( SQL_FN_TSI_SECOND                          ),
  905. INFO_VALUE_ROW( SQL_FN_TSI_MINUTE                          ),
  906. INFO_VALUE_ROW( SQL_FN_TSI_HOUR                            ),
  907. INFO_VALUE_ROW( SQL_FN_TSI_DAY                             ),
  908. INFO_VALUE_ROW( SQL_FN_TSI_WEEK                            ),
  909. INFO_VALUE_ROW( SQL_FN_TSI_MONTH                           ),
  910. INFO_VALUE_ROW( SQL_FN_TSI_QUARTER                         ),
  911. INFO_VALUE_ROW( SQL_FN_TSI_YEAR                            ),
  912. };
  913. //
  914. // Structure for SQL_ODBC_API_CONFORMANCE
  915. //
  916. static INFOSTRUCT GetInfoAPIConform[] = {
  917. INFO_VALUE_ROW( SQL_OIC_CORE                               ),
  918. INFO_VALUE_ROW( SQL_OIC_LEVEL1                             ),
  919. INFO_VALUE_ROW( SQL_OIC_LEVEL2                             ),
  920. };
  921. //
  922. // Structure for SQL_ODBC_SQL_CONFORMANCE
  923. //
  924. static INFOSTRUCT GetInfoODBCSQL[] = {
  925. INFO_VALUE_ROW( SQL_OSC_MINIMUM                            ),
  926. INFO_VALUE_ROW( SQL_OSC_CORE                               ),
  927. INFO_VALUE_ROW( SQL_OSC_EXTENDED                           ),
  928. };
  929. //
  930. // Structure for SQL_IDENTIFIER_CASE
  931. //
  932. static INFOSTRUCT GetInfoIDCase[] = {
  933. INFO_VALUE_ROW( SQL_IC_UPPER                               ),
  934. INFO_VALUE_ROW( SQL_IC_LOWER                               ),
  935. INFO_VALUE_ROW( SQL_IC_SENSITIVE                           ),
  936. INFO_VALUE_ROW( SQL_IC_MIXED                               ),
  937. };
  938. //
  939. // Structure for SQL_TXN_CAPABLE
  940. //
  941. static INFOSTRUCT GetInfoTxnCapable[] = {
  942. INFO_VALUE_ROW( SQL_TC_NONE                                ),
  943. INFO_VALUE_ROW( SQL_TC_DML                                 ),
  944. INFO_VALUE_ROW( SQL_TC_DDL_COMMIT                          ),
  945. INFO_VALUE_ROW( SQL_TC_DDL_IGNORE                          ),
  946. INFO_VALUE_ROW( SQL_TC_ALL                                 ),
  947. };
  948. //
  949. // Structure for SQL_TXN_ISOLATION_OPTIONS
  950. //
  951. static INFOSTRUCT GetInfoTxnIsoOptions[] = {
  952. INFO_VALUE_ROW( SQL_TXN_READ_UNCOMMITTED                   ),
  953. INFO_VALUE_ROW( SQL_TXN_READ_COMMITTED                     ),
  954. INFO_VALUE_ROW( SQL_TXN_REPEATABLE_READ                    ),
  955. INFO_VALUE_ROW( SQL_TXN_SERIALIZABLE                       ),
  956. };
  957. //
  958. // Structure for SQL_UNION
  959. //
  960. static INFOSTRUCT GetInfoUnion[] = {
  961. INFO_VALUE_ROW( SQL_U_UNION                                ),
  962. INFO_VALUE_ROW( SQL_U_UNION_ALL                            ),
  963. };
  964. //
  965. // The following structure is used to retrieve information about the driver.  There
  966. //    are 5 types of GetInfo structures:
  967. //          INT16       16-bit value
  968. //          INT32       32-bit value
  969. //          STRVAL      String value
  970. //          DEXVAL      Indexed item (eg: 0-x)
  971. //          BITVAL      Bit-mask value
  972. //
  973. char           szGetInfo[MAXBUFF];
  974. UWORD          cb16;
  975. UDWORD         cb32;
  976. #define        INT16             1
  977. #define        INT32             2
  978. #define        STRVAL            3
  979. #define        DEXVAL            4
  980. #define        BITVAL            5
  981. #define INFOROW(name, string, type, addr, varsize, ptr, size) {name, string, type, addr, varsize, ptr, size}
  982. #define INT16_ITEM(name)        INFOROW(name, #name, INT16,  &cb16,      sizeof(cb16), NULL, 0)
  983. #define INT32_ITEM(name)        INFOROW(name, #name, INT32,  &cb32,      sizeof(cb32), NULL, 0)
  984. #define STRNG_ITEM(name)        INFOROW(name, #name, STRVAL, szGetInfo,  sizeof(szGetInfo), NULL, 0)
  985. #define BIT32_ITEM(name, list)  INFOROW(name, #name, BITVAL, &cb32,      sizeof(cb32), list, NumItems(list))
  986. #define DEX32_ITEM(name, list)  INFOROW(name, #name, DEXVAL, &cb32,      sizeof(cb32), list, NumItems(list))
  987. struct {
  988.    UWORD          fInfoType;                 // What we're looking for
  989.    LPSTR          szInfoName;                // Print name of the GetInfo item
  990.    int            fOutType;                  // string, 16-bit or 32-bit
  991.    PTR            rgbInfoValue;              // Output buffer
  992.    SWORD          cbInfoMax;                 // Size of output buffer
  993.    void FAR *     ptr;                       // Generic constant structure
  994.    int            cbNum;                     // Count of items in ptr
  995. } GetInfo[] = {
  996.    // Out Type  fInfoType                          List of Values
  997.    // --------  -------------------------          ---------------------------
  998.    STRNG_ITEM(  SQL_ACCESSIBLE_PROCEDURES                                      ),
  999.    STRNG_ITEM(  SQL_ACCESSIBLE_TABLES                                          ),
  1000.    INT16_ITEM(  SQL_ACTIVE_ENVIRONMENTS                                        ),
  1001.    BIT32_ITEM(  SQL_ALTER_DOMAIN,                  GetInfoAlterDomain          ),
  1002.    BIT32_ITEM(  SQL_ALTER_TABLE,                   GetInfoAlterTable           ),
  1003.    DEX32_ITEM(  SQL_ASYNC_MODE,                    GetInfoAsyncMode            ),
  1004.    BIT32_ITEM(  SQL_BATCH_ROW_COUNT,               GetInfoBatchRowCount        ),
  1005.    BIT32_ITEM(  SQL_BATCH_SUPPORT,                 GetInfoBatchSupport         ),
  1006.    BIT32_ITEM(  SQL_BOOKMARK_PERSISTENCE,          GetInfoBookmarkPersist      ),
  1007.    DEX32_ITEM(  SQL_CATALOG_LOCATION,              GetInfoCatLocation          ),
  1008.    STRNG_ITEM(  SQL_CATALOG_NAME                                               ),
  1009.    STRNG_ITEM(  SQL_CATALOG_NAME_SEPARATOR                                     ),
  1010.    STRNG_ITEM(  SQL_CATALOG_TERM                                               ),
  1011.    BIT32_ITEM(  SQL_CATALOG_USAGE,                 GetInfoCatUsage             ),
  1012.    STRNG_ITEM(  SQL_COLLATION_SEQ                                              ),
  1013.    STRNG_ITEM(  SQL_COLUMN_ALIAS                                               ),
  1014.    DEX32_ITEM(  SQL_CONCAT_NULL_BEHAVIOR,          GetInfoConcat               ),
  1015.    BIT32_ITEM(  SQL_CONVERT_BIGINT,                GetInfoConvertTypes         ),
  1016.    BIT32_ITEM(  SQL_CONVERT_BINARY,                GetInfoConvertTypes         ),
  1017.    BIT32_ITEM(  SQL_CONVERT_BIT,                   GetInfoConvertTypes         ),
  1018.    BIT32_ITEM(  SQL_CONVERT_CHAR,                  GetInfoConvertTypes         ),
  1019.    BIT32_ITEM(  SQL_CONVERT_DATE,                  GetInfoConvertTypes         ),
  1020.    BIT32_ITEM(  SQL_CONVERT_DECIMAL,               GetInfoConvertTypes         ),
  1021.    BIT32_ITEM(  SQL_CONVERT_DOUBLE,                GetInfoConvertTypes         ),
  1022.    BIT32_ITEM(  SQL_CONVERT_FLOAT,                 GetInfoConvertTypes         ),
  1023.    BIT32_ITEM(  SQL_CONVERT_FUNCTIONS,             GetInfoConvertTypes         ),
  1024.    BIT32_ITEM(  SQL_CONVERT_INTEGER,               GetInfoConvertTypes         ),
  1025.    BIT32_ITEM(  SQL_CONVERT_LONGVARBINARY,         GetInfoConvertTypes         ),
  1026.    BIT32_ITEM(  SQL_CONVERT_LONGVARCHAR,           GetInfoConvertTypes         ),
  1027.    BIT32_ITEM(  SQL_CONVERT_NUMERIC,               GetInfoConvertTypes         ),
  1028.    BIT32_ITEM(  SQL_CONVERT_REAL,                  GetInfoConvertTypes         ),
  1029.    BIT32_ITEM(  SQL_CONVERT_SMALLINT,              GetInfoConvertTypes         ),
  1030.    BIT32_ITEM(  SQL_CONVERT_TIME,                  GetInfoConvertTypes         ),
  1031.    BIT32_ITEM(  SQL_CONVERT_TIMESTAMP,             GetInfoConvertTypes         ),
  1032.    BIT32_ITEM(  SQL_CONVERT_TINYINT,               GetInfoConvertTypes         ),
  1033.    BIT32_ITEM(  SQL_CONVERT_VARBINARY,             GetInfoConvertTypes         ),
  1034.    BIT32_ITEM(  SQL_CONVERT_VARCHAR,               GetInfoConvertTypes         ),
  1035.    BIT32_ITEM(  SQL_CONVERT_FUNCTIONS,             GetInfoConvertFunctions     ),
  1036.    BIT32_ITEM(  SQL_CORRELATION_NAME,              GetInfoCorrelationName      ),
  1037.    BIT32_ITEM(  SQL_CREATE_ASSERTION,              GetInfoCreateAssertion      ),
  1038.    BIT32_ITEM(  SQL_CREATE_CHARACTER_SET,          GetInfoCreateCharset        ),
  1039.    BIT32_ITEM(  SQL_CREATE_COLLATION,              GetInfoCreateCollation      ),
  1040.    BIT32_ITEM(  SQL_CREATE_DOMAIN,                 GetInfoCreateDomain         ),
  1041.    BIT32_ITEM(  SQL_CREATE_SCHEMA,                 GetInfoCreateSchema         ),
  1042.    BIT32_ITEM(  SQL_CREATE_TABLE,                  GetInfoCreateTable          ),
  1043.    BIT32_ITEM(  SQL_CREATE_TRANSLATION,            GetInfoCreateXlation        ),
  1044.    BIT32_ITEM(  SQL_CREATE_VIEW,                   GetInfoCreateView           ),
  1045.    DEX32_ITEM(  SQL_CURSOR_COMMIT_BEHAVIOR,        GetInfoCommit               ),
  1046.    DEX32_ITEM(  SQL_CURSOR_ROLLBACK_BEHAVIOR,      GetInfoCommit               ),
  1047.    DEX32_ITEM(  SQL_CURSOR_SENSITIVITY,            GetInfoCursorSensitiv       ),
  1048.    STRNG_ITEM(  SQL_DATA_SOURCE_NAME                                           ),
  1049.    STRNG_ITEM(  SQL_DATA_SOURCE_READ_ONLY                                      ),
  1050.    STRNG_ITEM(  SQL_DATABASE_NAME                                              ),
  1051.    BIT32_ITEM(  SQL_DATETIME_LITERALS,             GetInfoSQLDateLit           ),
  1052.    STRNG_ITEM(  SQL_DBMS_NAME                                                  ),
  1053.    STRNG_ITEM(  SQL_DBMS_VER                                                   ),
  1054.    BIT32_ITEM(  SQL_DEFAULT_TXN_ISOLATION,         GetInfoTXNIsolation         ),
  1055.    STRNG_ITEM(  SQL_DESCRIBE_PARAMETER                                         ),
  1056.    INT32_ITEM(  SQL_DRIVER_HDBC                                                ),
  1057.    INT32_ITEM(  SQL_DRIVER_HENV                                                ),
  1058.    INT32_ITEM(  SQL_DRIVER_HLIB                                                ),
  1059.    INT32_ITEM(  SQL_DRIVER_HSTMT                                               ),
  1060.    STRNG_ITEM(  SQL_DRIVER_NAME                                                ),
  1061.    STRNG_ITEM(  SQL_DRIVER_ODBC_VER                                            ),
  1062.    STRNG_ITEM(  SQL_DRIVER_VER                                                 ),
  1063.    BIT32_ITEM(  SQL_DROP_ASSERTION,                GetInfoDropAssertion        ),
  1064.    BIT32_ITEM(  SQL_DROP_CHARACTER_SET,            GetInfoDropCharset          ),
  1065.    BIT32_ITEM(  SQL_DROP_COLLATION,                GetInfoDropCollation        ),
  1066.    BIT32_ITEM(  SQL_DROP_DOMAIN,                   GetInfoDropDomain           ),
  1067.    BIT32_ITEM(  SQL_DROP_SCHEMA,                   GetInfoDropSchema           ),
  1068.    BIT32_ITEM(  SQL_DROP_TABLE,                    GetInfoDropTable            ),
  1069.    BIT32_ITEM(  SQL_DROP_TRANSLATION,              GetInfoDropXlation          ),
  1070.    BIT32_ITEM(  SQL_DROP_VIEW,                     GetInfoDropView             ),
  1071.    BIT32_ITEM(  SQL_DYNAMIC_CURSOR_ATTRIBUTES1,    GetInfoCurAttrs1            ),
  1072.    BIT32_ITEM(  SQL_DYNAMIC_CURSOR_ATTRIBUTES2,    GetInfoCurAttrs2            ),
  1073.    STRNG_ITEM(  SQL_EXPRESSIONS_IN_ORDERBY                                     ),
  1074.    DEX32_ITEM(  SQL_FILE_USAGE,                    GetInfoFileUsage            ),
  1075.    BIT32_ITEM(  SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1, GetInfoCurAttrs1          ),
  1076.    BIT32_ITEM(  SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2, GetInfoCurAttrs2          ),
  1077.    BIT32_ITEM(  SQL_GETDATA_EXTENSIONS,            GetInfoGetdataExt           ),
  1078.    BIT32_ITEM(  SQL_GROUP_BY,                      GetInfoGroupBy              ),
  1079.    DEX32_ITEM(  SQL_IDENTIFIER_CASE,               GetInfoIDCase               ),
  1080.    INT16_ITEM(  SQL_IDENTIFIER_QUOTE_CHAR                                      ),
  1081.    BIT32_ITEM(  SQL_INDEX_KEYWORDS,                GetInfoIndexKeywords        ),
  1082.    BIT32_ITEM(  SQL_INFO_SCHEMA_VIEWS,             GetInfoInfoSchemaViews      ),
  1083.    STRNG_ITEM(  SQL_INTEGRITY                                                  ),
  1084.    BIT32_ITEM(  SQL_KEYSET_CURSOR_ATTRIBUTES1,     GetInfoCurAttrs1            ),
  1085.    BIT32_ITEM(  SQL_KEYSET_CURSOR_ATTRIBUTES2,     GetInfoCurAttrs2            ),
  1086.    STRNG_ITEM(  SQL_KEYWORDS                                                   ),
  1087.    STRNG_ITEM(  SQL_LIKE_ESCAPE_CLAUSE                                         ),
  1088.    INT32_ITEM(  SQL_MAX_ASYNC_CONCURRENT_STATEMENTS                            ),
  1089.    INT32_ITEM(  SQL_MAX_BINARY_LITERAL_LEN                                     ),
  1090.    INT16_ITEM(  SQL_MAX_CATALOG_NAME_LEN                                       ),
  1091.    INT32_ITEM(  SQL_MAX_CHAR_LITERAL_LEN                                       ),
  1092.    INT16_ITEM(  SQL_MAX_COLUMN_NAME_LEN                                        ),
  1093.    INT16_ITEM(  SQL_MAX_COLUMNS_IN_GROUP_BY                                    ),
  1094.    INT16_ITEM(  SQL_MAX_COLUMNS_IN_INDEX                                       ),
  1095.    INT16_ITEM(  SQL_MAX_COLUMNS_IN_ORDER_BY                                    ),
  1096.    INT16_ITEM(  SQL_MAX_COLUMNS_IN_SELECT                                      ),
  1097.    INT16_ITEM(  SQL_MAX_COLUMNS_IN_TABLE                                       ),
  1098.    INT16_ITEM(  SQL_MAX_CONCURRENT_ACTIVITIES                                  ),
  1099.    INT16_ITEM(  SQL_MAX_CURSOR_NAME_LEN                                        ),
  1100.    INT16_ITEM(  SQL_MAX_DRIVER_CONNECTIONS                                     ),
  1101.    INT16_ITEM(  SQL_MAX_IDENTIFIER_LEN                                         ),
  1102.    INT32_ITEM(  SQL_MAX_INDEX_SIZE                                             ),
  1103.    INT16_ITEM(  SQL_MAX_PROCEDURE_NAME_LEN                                     ),
  1104.    INT32_ITEM(  SQL_MAX_ROW_SIZE                                               ),
  1105.    STRNG_ITEM(  SQL_MAX_ROW_SIZE_INCLUDES_LONG                                 ),
  1106.    INT16_ITEM(  SQL_MAX_SCHEMA_NAME_LEN                                        ),
  1107.    INT16_ITEM(  SQL_MAX_STATEMENT_LEN                                          ),
  1108.    INT16_ITEM(  SQL_MAX_TABLE_NAME_LEN                                         ),
  1109.    INT16_ITEM(  SQL_MAX_TABLES_IN_SELECT                                       ),
  1110.    INT16_ITEM(  SQL_MAX_USER_NAME_LEN                                          ),
  1111.    STRNG_ITEM(  SQL_MULTIPLE_ACTIVE_TXN                                        ),
  1112.    STRNG_ITEM(  SQL_MULT_RESULT_SETS                                           ),
  1113.    STRNG_ITEM(  SQL_NEED_LONG_DATA_LEN                                         ),
  1114.    DEX32_ITEM(  SQL_NON_NULLABLE_COLUMNS,          GetInfoNonNullCols          ),
  1115.    DEX32_ITEM(  SQL_NULL_COLLATION,                GetInfoNullCollation        ),
  1116.    BIT32_ITEM(  SQL_NUMERIC_FUNCTIONS,             GetInfoNumeric              ),
  1117.    DEX32_ITEM(  SQL_ODBC_INTERFACE_CONFORMANCE,    GetInfoAPIConform           ),
  1118.    DEX32_ITEM(  SQL_ODBC_SQL_CONFORMANCE,          GetInfoODBCSQL              ),
  1119.    STRNG_ITEM(  SQL_ODBC_VER                                                   ),
  1120.    STRNG_ITEM(  SQL_ORDER_BY_COLUMNS_IN_SELECT                                 ),
  1121.    STRNG_ITEM(  SQL_OUTER_JOINS                                                ),
  1122.    DEX32_ITEM(  SQL_PARAM_ARRAY_ROW_COUNTS,        GetInfoParamRowCounts       ),
  1123.    DEX32_ITEM(  SQL_PARAM_ARRAY_SELECTS,           GetInfoParamSelects         ),
  1124.    STRNG_ITEM(  SQL_PROCEDURES                                                 ),
  1125.    STRNG_ITEM(  SQL_PROCEDURE_TERM                                             ),
  1126.    DEX32_ITEM(  SQL_QUOTED_IDENTIFIER_CASE,        GetInfoIDCase               ),
  1127.    STRNG_ITEM(  SQL_ROW_UPDATES                                                ),
  1128.    STRNG_ITEM(  SQL_SCHEMA_TERM                                                ),
  1129.    BIT32_ITEM(  SQL_SCHEMA_USAGE,                  GetInfoSchemaUsage          ),
  1130.    BIT32_ITEM(  SQL_SCROLL_OPTIONS,                GetInfoScrollOptions        ),
  1131.    STRNG_ITEM(  SQL_SEARCH_PATTERN_ESCAPE                                      ),
  1132.    STRNG_ITEM(  SQL_SERVER_NAME                                                ),
  1133.    STRNG_ITEM(  SQL_SPECIAL_CHARACTERS                                         ),
  1134.    BIT32_ITEM(  SQL_SQL_CONFORMANCE,               GetInfoSQLConform           ),
  1135.    BIT32_ITEM(  SQL_SQL92_DATETIME_FUNCTIONS,      GetInfoS92DatetimeFns       ),
  1136.    BIT32_ITEM(  SQL_SQL92_FOREIGN_KEY_DELETE_RULE, GetInfoS92FKeyDelRule       ),
  1137.    BIT32_ITEM(  SQL_SQL92_FOREIGN_KEY_UPDATE_RULE, GetInfoS92FKeyUpdRule       ),
  1138.    BIT32_ITEM(  SQL_SQL92_GRANT,                   GetInfoS92Grant             ),
  1139.    BIT32_ITEM(  SQL_SQL92_NUMERIC_VALUE_FUNCTIONS, GetInfoS92NumValFns         ),
  1140.    BIT32_ITEM(  SQL_SQL92_PREDICATES,              GetInfoS92Predicates        ),
  1141.    BIT32_ITEM(  SQL_SQL92_RELATIONAL_JOIN_OPERATORS, GetInfoS92RelJoinOps      ),
  1142.    BIT32_ITEM(  SQL_SQL92_REVOKE,                  GetInfoS92Revoke            ),
  1143.    BIT32_ITEM(  SQL_SQL92_ROW_VALUE_CONSTRUCTOR,   GetInfoS92RowValConstr      ),
  1144.    BIT32_ITEM(  SQL_SQL92_STRING_FUNCTIONS,        GetInfoS92StringFns         ),
  1145.    BIT32_ITEM(  SQL_SQL92_VALUE_EXPRESSIONS,       GetInfoS92ValueExprs        ),
  1146.    BIT32_ITEM(  SQL_STANDARD_CLI_CONFORMANCE,      GetInfoS92StdCLIConf        ),
  1147.    BIT32_ITEM(  SQL_STATIC_CURSOR_ATTRIBUTES1,     GetInfoCurAttrs1            ),
  1148.    BIT32_ITEM(  SQL_STATIC_CURSOR_ATTRIBUTES2,     GetInfoCurAttrs2            ),
  1149.    BIT32_ITEM(  SQL_STRING_FUNCTIONS,              GetInfoStrings              ),
  1150.    BIT32_ITEM(  SQL_SUBQUERIES,                    GetInfoSubqueries           ),
  1151.    BIT32_ITEM(  SQL_SYSTEM_FUNCTIONS,              GetInfoSystem               ),
  1152.    STRNG_ITEM(  SQL_TABLE_TERM                                                 ),
  1153.    BIT32_ITEM(  SQL_TIMEDATE_ADD_INTERVALS,        GetInfoTimeDateIvls         ),
  1154.    BIT32_ITEM(  SQL_TIMEDATE_DIFF_INTERVALS,       GetInfoTimeDateIvls         ),
  1155.    BIT32_ITEM(  SQL_TIMEDATE_FUNCTIONS,            GetInfoTimeDate             ),
  1156.    DEX32_ITEM(  SQL_TXN_CAPABLE,                   GetInfoTxnCapable           ),
  1157.    BIT32_ITEM(  SQL_TXN_ISOLATION_OPTION,          GetInfoTxnIsoOptions        ),
  1158.    BIT32_ITEM(  SQL_UNION,                         GetInfoUnion                ),
  1159.    STRNG_ITEM(  SQL_USER_NAME                                                  ),
  1160.    STRNG_ITEM(  SQL_XOPEN_CLI_YEAR                                             ),
  1161. };
  1162.    
  1163.    
  1164. //*---------------------------------------------------------------------------------
  1165. //| GetBitVal:
  1166. //|   Call this function to retrieve the string values for all items which meet
  1167. //|   the bitwise and condition.
  1168. //| Parms:
  1169. //|   in       rs                   Pointer to the results set
  1170. //|   in       szInfoName           The info value being retrieved
  1171. //|   in       is                   Structure with resource ids and values
  1172. //|   in       maxdex               Number of items in struct
  1173. //|   in       mask                 The value to compare against
  1174. //|   in       szOut                Output buffer for retrieval
  1175. //|   in       cbOut                Size of output buffer
  1176. //| Returns:              
  1177. //|   Nothing
  1178. //*---------------------------------------------------------------------------------
  1179. BOOL GetBitVal
  1180.    (RESULTSSET FAR * rs,
  1181.     LPSTR szInfoName,
  1182.     lpINFOSTRUCT is,
  1183.     int maxdex,
  1184.     UDWORD mask,
  1185.     LPSTR szVal,
  1186.     int cbVal)
  1187. {
  1188.    int            tdex;
  1189.    ROWDATA FAR *  rd;
  1190.    COLORREF       rgbDft=GetDefaultRGB();
  1191.    if (mask != 0) {
  1192.       for(tdex=0;  tdex<maxdex;  tdex++) 
  1193.          if(is[tdex].fVal & mask) {
  1194.             rd = AllocateRowData(rs, rgbDft, RDATA_DEFAULT_BKGRND);
  1195.             SetColumnData(0, rd, szInfoName);
  1196.             SetColumnData(1, rd, is[tdex].szStr);
  1197.             if(AddRowData(rs, rd) == LB_ERRSPACE)
  1198.                return FALSE;
  1199.          }
  1200.    }
  1201.    else {
  1202.       rd = AllocateRowData(rs, rgbDft, RDATA_DEFAULT_BKGRND);
  1203.       SetColumnData(0, rd, szInfoName);
  1204.       SetColumnData(1, rd, "0");
  1205.       if(AddRowData(rs, rd) == LB_ERRSPACE)
  1206.          return FALSE;
  1207.    }
  1208.    return TRUE;
  1209. }
  1210.    
  1211. //*---------------------------------------------------------------------------------
  1212. //| GetIndexVal:
  1213. //|   Call this function to retrieve the string value for a constant.
  1214. //| Parms:
  1215. //|   in       rs                   Pointer to the results set
  1216. //|   in       szInfoName           The info value being retrieved
  1217. //|   in       is                   Structure with resource ids and values
  1218. //|   in       maxdex               Number of items in struct
  1219. //|   in       dex                  String index value 
  1220. //|   in       szOut                Output buffer for retrieval
  1221. //|   in       cbOut                Size of output buffer
  1222. //| Returns:              
  1223. //|   FALSE if there is an error
  1224. //| No error is posted if matching value is not found.
  1225. //*---------------------------------------------------------------------------------
  1226. BOOL GetIndexVal
  1227.    (RESULTSSET FAR * rs,
  1228.     LPSTR szInfoName, 
  1229.     lpINFOSTRUCT is,
  1230.     int maxdex,
  1231.     int dex,
  1232.     LPSTR szOut,
  1233.     int cbOut)
  1234. {
  1235.    int tdex;
  1236.    ROWDATA FAR *  rd;
  1237.    COLORREF       rgbDft=GetDefaultRGB();
  1238.    for (tdex = 0; tdex<maxdex; tdex++)
  1239.       if (is[tdex].fVal == (UDWORD) dex) {
  1240.          rd = AllocateRowData(rs, rgbDft, RDATA_DEFAULT_BKGRND);
  1241.          SetColumnData(0, rd, szInfoName);
  1242.          SetColumnData(1, rd, is[tdex].szStr);
  1243.          if(AddRowData(rs, rd) == LB_ERRSPACE)
  1244.             return FALSE;
  1245.       }
  1246.    return TRUE;
  1247. }
  1248.    
  1249. //*---------------------------------------------------------------------------------
  1250. //| DisplayGetInfo:
  1251. //|   This function goes through all of the SQLGetInfo constants defined in the
  1252. //|   ODBC reference guide and displays them in a results set.
  1253. //| Parms:
  1254. //|   in       ci                   CHILDINFO information
  1255. //| Returns:              
  1256. //|   TRUE if successful,
  1257. //|   FALSE on error
  1258. //*---------------------------------------------------------------------------------
  1259. BOOL DisplayGetInfo(CHILDINFO FAR * ci)
  1260. {
  1261.    char                 szTitle[MAXBUFF];
  1262.    char                 szVal[MAXBUFF];
  1263.    int                  dex;
  1264.    lpINFOSTRUCT         lpINFS;
  1265.    RESULTSSET FAR *     rs;
  1266.    ROWDATA FAR *        rd;
  1267.    RETCODE              retcode;
  1268.    COLORREF             rgbDft=GetDefaultRGB();
  1269.    //
  1270.    // Create a hard coded results set with 2 columns
  1271.    //
  1272.    lstrcpy((LPSTR)szTitle, (LPSTR)ci->szClientTitle);
  1273.    lstrcat((LPSTR)szTitle, (LPSTR)szDash);
  1274.    lstrcat((LPSTR)szTitle, (LPSTR)szGetInfoTitle);
  1275.    rs = GetConnectWindowResultsNode(ci);
  1276.    if(!CreateResultsSet(rs, ci->hwndClient, ci->hInst, 2, (LPSTR)szTitle))
  1277.       return FALSE;  
  1278.    //
  1279.    // Set the meta data
  1280.    //
  1281.    SetMetaDataColumn(rs, 0, (LPSTR)"fInfoType", 
  1282.                      GetTypeName(SQL_TYPE, SQL_CHAR), SQL_CHAR, 40, 0,
  1283.                      45, TA_LEFT);
  1284.    SetMetaDataColumn(rs, 1, (LPSTR)"Value", 
  1285.                      GetTypeName(SQL_TYPE, SQL_CHAR), SQL_CHAR, 70, 0,
  1286.                      70, TA_LEFT);
  1287.    //
  1288.    // Now create the MDI child window which will hold the results.
  1289.    //
  1290.    if(!CreateResultsWindow(ci, rs)) 
  1291.       goto exit00;
  1292.    
  1293.    //
  1294.    // Loop through the control structure and check each fInfoType.  Certain
  1295.    //    types require extra processing.
  1296.    //
  1297.    Busy(TRUE);
  1298.    for(dex=0;  dex<NumItems(GetInfo);  dex++) {
  1299.       if(GetInfo[dex].fInfoType == SQL_DRIVER_HSTMT)           // Input arg also
  1300.          *(HSTMT FAR *)GetInfo[dex].rgbInfoValue = ci->hstmt;
  1301.       memset(GetInfo[dex].rgbInfoValue, 0, GetInfo[dex].cbInfoMax);
  1302.       retcode = SQLGetInfo(ci->hdbc, 
  1303.                            GetInfo[dex].fInfoType, 
  1304.                            GetInfo[dex].rgbInfoValue, 
  1305.                            GetInfo[dex].cbInfoMax, 
  1306.                            NULL);
  1307.       if(retcode != SQL_SUCCESS)
  1308.          PrintErrors(ci, SQL_HANDLE_DBC);
  1309.       switch(GetInfo[dex].fInfoType) {
  1310.         case SQL_DRIVER_HENV:
  1311.         case SQL_DRIVER_HDBC:
  1312.         case SQL_DRIVER_HSTMT:
  1313.          rd = AllocateRowData(rs, rgbDft, RDATA_DEFAULT_BKGRND);
  1314.          SetColumnData(0, rd, GetInfo[dex].szInfoName);
  1315.          wsprintf(szVal, "%04X:%04X", HIWORD(cb32), LOWORD(cb32));
  1316.          SetColumnData(1, rd, (LPSTR)szVal);
  1317.          if(AddRowData(rs, rd) == LB_ERRSPACE)
  1318.             goto exit00;
  1319.          break;
  1320.          
  1321.          //
  1322.          // The default action is taken when we only need to display the
  1323.          //    value as is.  We can use the structure to figure out what
  1324.          //    format it is in.
  1325.          //
  1326.         default:
  1327.          rd = AllocateRowData(rs, rgbDft, RDATA_DEFAULT_BKGRND);
  1328.          SetColumnData(0, rd, GetInfo[dex].szInfoName);
  1329.          switch(GetInfo[dex].fOutType) {
  1330.            case INT16:
  1331.             wsprintf(szVal, "%d", cb16);
  1332.             SetColumnData(1, rd, (LPSTR)szVal);
  1333.             if(AddRowData(rs, rd) == LB_ERRSPACE)
  1334.                goto exit00;
  1335.             break;
  1336.             
  1337.            case INT32:
  1338.             wsprintf(szVal, "%ld", cb32);
  1339.             SetColumnData(1, rd, (LPSTR)szVal);
  1340.             if(AddRowData(rs, rd) == LB_ERRSPACE)
  1341.                goto exit00;
  1342.             break;
  1343.            case DEXVAL:
  1344.             lpINFS = (lpINFOSTRUCT)GetInfo[dex].ptr;
  1345.             if(!GetIndexVal(rs, GetInfo[dex].szInfoName,
  1346.                             lpINFS, GetInfo[dex].cbNum,
  1347.                             cb32,
  1348.                             (LPSTR)szVal, sizeof(szVal)))
  1349.                goto exit00;
  1350.             break;
  1351.             
  1352.            case BITVAL:
  1353.             lpINFS = (lpINFOSTRUCT)GetInfo[dex].ptr;
  1354.             if(!GetBitVal(rs, GetInfo[dex].szInfoName,
  1355.                           lpINFS, GetInfo[dex].cbNum,
  1356.                           cb32,
  1357.                           (LPSTR)szVal, sizeof(szVal)))
  1358.                goto exit00;
  1359.             break;
  1360.             
  1361.            default: 
  1362.             szGetInfo[69] = ''; // truncate long string...
  1363.             SetColumnData(1, rd, (LPSTR)GetInfo[dex].rgbInfoValue);
  1364.             if(AddRowData(rs, rd) == LB_ERRSPACE)
  1365.                goto exit00;
  1366.             break;
  1367.          }
  1368.       }
  1369.       
  1370.    }
  1371.    
  1372.    Busy(FALSE);
  1373.    return TRUE;
  1374.    
  1375.   exit00:
  1376.    Busy(FALSE);
  1377.    return FALSE;
  1378. }
  1379.    
  1380. //*---------------------------------------------------------------------------------
  1381. //| DisplayODBCFunctions:
  1382. //|   This function will enumerate all of the ODBC functions in a results set
  1383. //|      and indicate which ones are supported.  The results set is attatched
  1384. //|      as a valid results window on the current child.
  1385. //| Parms:
  1386. //|   in       ci                   CHILDINFO information
  1387. //| Returns:              
  1388. //|   TRUE if successful,
  1389. //|   FALSE on error
  1390. //*---------------------------------------------------------------------------------
  1391. BOOL DisplayODBCFunctions(CHILDINFO FAR * ci)
  1392. {
  1393.    UWORD                fSupport;
  1394.    char                 szFuncName[35];
  1395.    char                 szTitle[MAXBUFF];
  1396.    int                  dex;
  1397.    RESULTSSET FAR *     rs;
  1398.    ROWDATA FAR *        rd;
  1399.    RETCODE              retcode;
  1400.    COLORREF             rgbDft=GetDefaultRGB();
  1401.    //
  1402.    // Create a hard coded results set with 3 columns
  1403.    //
  1404.    lstrcpy((LPSTR)szTitle, (LPSTR)ci->szClientTitle);
  1405.    lstrcat((LPSTR)szTitle, (LPSTR)szDash);
  1406.    lstrcat((LPSTR)szTitle, (LPSTR)szODBCFunctions);
  1407.    rs = GetConnectWindowResultsNode(ci);
  1408.    if(!CreateResultsSet(rs, ci->hwndClient, ci->hInst, 3, (LPSTR)szTitle))
  1409.       return FALSE;  
  1410.    //
  1411.    // Set the meta data
  1412.    //
  1413.    SetMetaDataColumn(rs, 0, (LPSTR)"Function", 
  1414.                      GetTypeName(SQL_TYPE, SQL_CHAR), SQL_CHAR, 20, 0,
  1415.                      25, TA_LEFT);
  1416.    SetMetaDataColumn(rs, 1, (LPSTR)"Conformance", 
  1417.                      GetTypeName(SQL_TYPE, SQL_CHAR), SQL_CHAR, 10, 0,
  1418.                      10, TA_LEFT);
  1419.    SetMetaDataColumn(rs, 2, (LPSTR)"Supported", 
  1420.                      GetTypeName(SQL_TYPE, SQL_CHAR), SQL_CHAR, 10, 0,
  1421.                      10, TA_LEFT);
  1422.    //
  1423.    // Now create the MDI child window which will hold the results.
  1424.    //
  1425.    if(!CreateResultsWindow(ci, rs)) 
  1426.       goto exit00;
  1427.    
  1428.    //
  1429.    // Loop through the control structure and check each function.  For each row
  1430.    //    add a record with the function name, conformance level, and Yes if
  1431.    //    supported, No if not.
  1432.    //
  1433.    for(dex=0;  dex<NumItems(ODBCFunctions);  dex++) {
  1434.       retcode = SQLGetFunctions(ci->hdbc, 
  1435.                                 ODBCFunctions[dex].fFunction, &fSupport);
  1436.       if(retcode != SQL_SUCCESS)
  1437.          PrintErrors(ci, SQL_HANDLE_DBC);
  1438.       iLoadString(ODBCFunctions[dex].idFunction, (LPSTR)szFuncName, sizeof(szFuncName));
  1439.       rd = AllocateRowData(rs, rgbDft, RDATA_DEFAULT_BKGRND);
  1440.       SetColumnData(0, rd, szFuncName);
  1441.       SetColumnData(1, rd, ODBCFunctions[dex].szLevel);
  1442.       SetColumnData(2, rd, (fSupport) ? (LPSTR)szYes : (LPSTR)szNo);
  1443.       AddRowData(rs, rd);
  1444.    }
  1445.    
  1446.    return TRUE;
  1447.    
  1448.   exit00:
  1449.    SQLFreeStmt(ci->hstmt, SQL_CLOSE);
  1450.    return FALSE;
  1451. }
  1452. //*---------------------------------------------------------------------------------
  1453. //| DisplayODBCDataSources:
  1454. //|   This function will enumerate all of the ODBC Data sources.
  1455. //| Parms:
  1456. //|   in       ci                   CHILDINFO information
  1457. //| Returns:              
  1458. //|   TRUE if successful,
  1459. //|   FALSE on error
  1460. //*---------------------------------------------------------------------------------
  1461. BOOL DisplayODBCDataSources(CHILDINFO FAR * ci)
  1462. {  
  1463.    HENV                 henv;
  1464.    RESULTSSET FAR *     rs;
  1465.    ROWDATA FAR *        rd;
  1466.    RETCODE              retcode;
  1467.    char                 szDSN[SQL_MAX_DSN_LENGTH + 1];
  1468.    char                 szDesc[MAXBUFF];
  1469.    char                 szTitle[MAXBUFF];
  1470.    COLORREF             rgbDft=GetDefaultRGB();
  1471.    //
  1472.    // Create a hard coded results set with 2 columns
  1473.    //
  1474.    lstrcpy((LPSTR)szTitle, (LPSTR)ci->szClientTitle);
  1475.    lstrcat((LPSTR)szTitle, (LPSTR)szDash);
  1476.    lstrcat((LPSTR)szTitle, (LPSTR)szODBCDataSources);
  1477.    rs = GetConnectWindowResultsNode(ci);
  1478.    if(!CreateResultsSet(rs, ci->hwndClient, ci->hInst, 2, (LPSTR)szTitle))
  1479.       return FALSE;  
  1480.    //
  1481.    // Set the meta data
  1482.    //
  1483.    SetMetaDataColumn(rs, 0, (LPSTR)"Driver", 
  1484.                      GetTypeName(SQL_TYPE, SQL_CHAR), SQL_CHAR, 15, 0,
  1485.                      15, TA_LEFT);
  1486.    SetMetaDataColumn(rs, 1, (LPSTR)"Description", 
  1487.                      GetTypeName(SQL_TYPE, SQL_CHAR), SQL_CHAR, 35, 0,
  1488.                      35, TA_LEFT);
  1489.    //
  1490.    // Now create the MDI child window which will hold the results.
  1491.    //
  1492.    if(!CreateResultsWindow(ci, rs)) 
  1493.       goto exit00;
  1494.    
  1495.    //
  1496.    // Loop through each data source and add it to the results set.
  1497.    //
  1498.    if (SQL_SUCCESS != SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HENV, &henv) )
  1499. {
  1500.  PrintErrors(ci, SQL_HANDLE_ENV);
  1501.  goto exit00;
  1502. }
  1503. if (SQL_SUCCESS != SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,
  1504. (SQLPOINTER)SQL_OV_ODBC3,SQL_IS_INTEGER))
  1505. {
  1506.  PrintErrors(ci, SQL_HANDLE_ENV);
  1507.  goto exit00;
  1508. }
  1509.    retcode = SQLDataSources(henv, SQL_FETCH_FIRST, szDSN, sizeof(szDSN),
  1510.                             NULL, szDesc, sizeof(szDesc), NULL);
  1511.    while(retcode != SQL_NO_DATA) {
  1512.       if(retcode != SQL_SUCCESS )
  1513. {
  1514.          PrintErrors(ci, SQL_HANDLE_ENV);
  1515. if (retcode != SQL_SUCCESS_WITH_INFO)
  1516. goto exit00;
  1517. }
  1518.       rd = AllocateRowData(rs, rgbDft, RDATA_DEFAULT_BKGRND);
  1519.       SetColumnData(0, rd, szDSN);
  1520.       SetColumnData(1, rd, szDesc);
  1521.       AddRowData(rs, rd);
  1522.       retcode = SQLDataSources(henv, SQL_FETCH_NEXT, szDSN, sizeof(szDSN),
  1523.                                NULL, szDesc, sizeof(szDesc), NULL);
  1524.    }
  1525.    SQLFreeHandle(SQL_HANDLE_ENV, henv); 
  1526.    return TRUE;
  1527.    
  1528.   exit00:
  1529.    return FALSE;
  1530. }
  1531. //*---------------------------------------------------------------------------------
  1532. //| DisplayODBCDataTypes:
  1533. //|   This function will enumerate data type information.
  1534. //| Parms:
  1535. //|   in       ci                   CHILDINFO information
  1536. //| Returns:              
  1537. //|   TRUE if successful,
  1538. //|   FALSE on error
  1539. //*---------------------------------------------------------------------------------
  1540. BOOL DisplayODBCDataTypes(CHILDINFO FAR * ci)
  1541. {  
  1542.    RESULTSSET FAR *     rs;
  1543.    RETCODE              retcode;
  1544.    SWORD                cbCols;
  1545.    char                 szTitle[MAXBUFF];
  1546.    //
  1547.    // We'll use SQLGetTypeInfo for this query.  Since this function can return more
  1548.    //    than the standard types, we must first execute the query and then create
  1549.    //    the results set.
  1550.    //
  1551.    lstrcpy((LPSTR)szTitle, (LPSTR)ci->szClientTitle);
  1552.    lstrcat((LPSTR)szTitle, (LPSTR)szDash);
  1553.    lstrcat((LPSTR)szTitle, (LPSTR)szODBCDataTypes);
  1554.    retcode = SQLGetTypeInfo(ci->hstmt, SQL_ALL_TYPES);
  1555.    if(retcode != SQL_SUCCESS) {
  1556.       PrintErrors(ci, SQL_HANDLE_STMT);
  1557.       return FALSE;
  1558.    }
  1559.    if(!(cbCols = GetNumResultsCols(ci->hstmt)))
  1560.       return FALSE;
  1561.    rs = GetConnectWindowResultsNode(ci);
  1562.    if(!CreateResultsSet(rs, ci->hwndClient, ci->hInst, cbCols, (LPSTR)szTitle))
  1563.       return FALSE;  
  1564.    //
  1565.    // Set the meta data
  1566.    //
  1567.    SetMetaDataFromSql(ci->hwndOut, ci->hstmt, rs, cbCols);
  1568.    //
  1569.    // Now create the MDI child window which will hold the results.
  1570.    //
  1571.    if(!CreateResultsWindow(ci, rs)) 
  1572.       goto exit00;
  1573.    
  1574.    //
  1575.    // Loop through each data source and add it to the results set.
  1576.    //
  1577.    FetchAllRecordsToResults(ci->hwndOut, ci->hstmt, rs, cbCols, TRUE);
  1578.    SQLFreeStmt(ci->hstmt, SQL_CLOSE);
  1579.    return TRUE;
  1580.    
  1581.   exit00:
  1582.    return FALSE;
  1583. }
  1584. //*---------------------------------------------------------------------------------
  1585. //| EditPipe:
  1586. //|   This function allows the user to create a new pipe.
  1587. //| Parms:
  1588. //|   in       ci                   CHILDINFO information
  1589. //| Returns:              
  1590. //|   TRUE if successful,
  1591. //|   FALSE on error
  1592. //*---------------------------------------------------------------------------------
  1593. void EditPipe(CHILDINFO FAR * ci)
  1594. {
  1595.    HWND     fHwnd=GetFocus();
  1596.    if(-1 == DialogBoxParam(ci->hInst, 
  1597.                            MAKEINTRESOURCE(IDD_EDIT_PIPE),
  1598.                            ci->hwnd, 
  1599.                            (DLGPROC) EditPipeWndProc, (LPARAM)ci))
  1600.       MessageBox(NULL, "Could not open dialog box.",
  1601.                  "Pipe", MB_ICONEXCLAMATION);
  1602.    
  1603.    if(fHwnd)
  1604.       SetFocus(fHwnd);
  1605. }
  1606. //*------------------------------------------------------------------------
  1607. //| IsValidParms:
  1608. //|   Verify that the parameters specified are the correct comma
  1609. //|   separated format.
  1610. //| Parms:
  1611. //|   hwnd              Window handle for errors
  1612. //|   szParms           The null terminated list of parms
  1613. //| Returns:              
  1614. //|   TRUE if they are valid, FALSE on error
  1615. //*------------------------------------------------------------------------
  1616. BOOL WINAPI IsValidParms(HWND hwnd, LPSTR szParms)
  1617. {
  1618.    LPSTR       str=szParms, nstr;
  1619.    char        sztmp[MAXSQL];
  1620.    int         iNum, iCnt=0;
  1621.    lstrcpy(sztmp, szParms);
  1622.    nstr = str = strtok(sztmp, szCOMMA);
  1623.    while(str) {
  1624.       ++iCnt;
  1625.       if(!(strlen(str) == 1 && *str == '0')) {
  1626.          iNum = atoi(str);
  1627.          while(*str) {
  1628.             if(*str < '0' ||
  1629.                *str > '9')
  1630.                goto invalidint;
  1631.             ++str;
  1632.          }
  1633.          
  1634.          // It was not 0, so if atoi returned 0 it was invalid
  1635.          if(!iNum)
  1636.             goto invalidint;
  1637.       }
  1638.       
  1639.       nstr = str = strtok(NULL, szCOMMA);
  1640.    }
  1641.    
  1642.    if(iCnt <= MAXPARMS)
  1643.       return TRUE;
  1644.    else {
  1645.       szMessageBox(hwnd,
  1646.                    MB_ICONEXCLAMATION | MB_OK,
  1647.                    (LPSTR)szErrorMsgTitle,
  1648.                    iLoadString(idsTooManyParms, OutStr, MAXBUFF),
  1649.                    iCnt,
  1650.                    MAXPARMS);
  1651.       return FALSE;
  1652.    }
  1653.   invalidint:
  1654.    szMessageBox(hwnd, 
  1655.                 MB_ICONEXCLAMATION | MB_OK,
  1656.                 (LPSTR)szErrorMsgTitle,
  1657.                 iLoadString(idsInvalidInt, OutStr, MAXBUFF),
  1658.                 nstr);
  1659.    
  1660.    return FALSE;
  1661. }
  1662. //*------------------------------------------------------------------------
  1663. //| EditPipeWndProc:
  1664. //|   Message handler for creating a new pipe.
  1665. //| Parms:
  1666. //|   in       Standard window parms
  1667. //| Returns:              
  1668. //|   Depends on message
  1669. //*------------------------------------------------------------------------
  1670. BOOL EXTFUN EditPipeWndProc(HWND hDlg, unsigned msg, WPARAM wParam, LPARAM lParam)
  1671. {
  1672.    static CHILDINFO FAR *     ci;
  1673.    static                     cbNames;
  1674.    static char                szName[MAXNAME];
  1675.    switch(msg) {
  1676.      case WM_INITDIALOG:
  1677.       {
  1678.          ci = (CHILDINFO FAR *)lParam;
  1679.          CenterDialog(hDlg);
  1680.          SendMessage(GetDlgItem(hDlg, IDC_NAME), CB_LIMITTEXT, MAXPARMS, 0L);
  1681.          SendMessage(GetDlgItem(hDlg, IDE_SQL), EM_LIMITTEXT, MAXSQL, 0L);
  1682.          SendMessage(GetDlgItem(hDlg, IDE_PARMS), EM_LIMITTEXT, (MAXNAME*2), 0L);
  1683.          CheckRadioButton(hDlg, IDR_VALUE, IDR_ADDRESS, IDR_VALUE);
  1684.          SendMessage(hDlg, USER_RESETLIST, 0, 0L);
  1685.          SendMessage(hDlg, USER_SETSTATES, 0, 0L);
  1686.       }
  1687.       return TRUE;      
  1688.       // This user message is sent when the list needs to be refreshed
  1689.      case USER_RESETLIST:
  1690.       {
  1691.          LPSTR       str, addstr;
  1692.          addstr = str = (LPSTR)GetMemory(1000);
  1693.          if(!addstr)
  1694.             return TRUE;
  1695.          cbNames = 0;
  1696.          if(str) {
  1697.             SendMessage(GetDlgItem(hDlg, IDC_NAME), CB_RESETCONTENT, 0, 0L);
  1698.             if(GetPrivateProfileString((LPSTR)szPIPES, NULL, NULL,
  1699.                                        str, 1000, szLABINI)) 
  1700.                while(*addstr) {
  1701.                   ++cbNames;
  1702.                   SendMessage(GetDlgItem(hDlg, IDC_NAME),
  1703.                               CB_ADDSTRING, 0,
  1704.                               (LPARAM)(LPSTR)addstr);
  1705.                   addstr = addstr + lstrlen(addstr) + 1;
  1706.                }
  1707.          }
  1708.          ReleaseMemory(str);
  1709.          if(cbNames) 
  1710.             SendMessage(GetDlgItem(hDlg, IDC_NAME), CB_SETCURSEL, 0, 0L);
  1711.          SendMessage(hDlg, USER_SETDEFAULTS, 0, 0L);
  1712.          SendMessage(hDlg, USER_SETSTATES, 0, 0L);
  1713.       }
  1714.       return TRUE;
  1715.       
  1716.       // This user defined message will set the state of controls
  1717.      case USER_SETSTATES:
  1718.       EnableWindow(GetDlgItem(hDlg, IDB_DELETE), cbNames);
  1719.       EnableWindow(GetDlgItem(hDlg, IDE_SQL), cbNames);
  1720.       EnableWindow(GetDlgItem(hDlg, IDR_VALUE), cbNames);
  1721.       EnableWindow(GetDlgItem(hDlg, IDR_ADDRESS), cbNames);
  1722.       EnableWindow(GetDlgItem(hDlg, IDE_PARMS), cbNames);
  1723.       EnableWindow(GetDlgItem(hDlg, IDOK), cbNames);
  1724.       return TRUE;
  1725.       // This user defined message is for setting default values
  1726.      case USER_SETDEFAULTS: 
  1727.       {
  1728.          char  szParmType[10];
  1729.          char  szSql[MAXSQL];
  1730.          char  szParms[MAXBUFF];
  1731.          
  1732.          HWND  hName = GetDlgItem(hDlg, IDC_NAME);
  1733.          
  1734.          if(cbNames == 0) {               // No current driver
  1735.             SetDlgItemText(hDlg, IDE_SQL, "");
  1736.             SetDlgItemText(hDlg, IDE_PARMS, "");
  1737.             return TRUE;
  1738.          }
  1739.          SendMessage(hName, CB_GETLBTEXT,
  1740.                      (WPARAM)SendMessage(hName, CB_GETCURSEL, 0, 0L),
  1741.                      (LPARAM)(LPSTR)szName);
  1742.          if(GetPrivateProfileString(szName, szSQL, NULL, szSql, sizeof(szSql), szLABINI))
  1743.             SetDlgItemText(hDlg, IDE_SQL, szSql);
  1744.          else
  1745.             SetDlgItemText(hDlg, IDE_SQL, "");
  1746.          if(GetPrivateProfileString(szName, szPARMS, NULL, szParms, sizeof(szParms), szLABINI))
  1747.             SetDlgItemText(hDlg, IDE_PARMS, szParms);
  1748.          else
  1749.             SetDlgItemText(hDlg, IDE_PARMS, "");
  1750.          if(GetPrivateProfileString(szName, szPARMOPT, NULL, szParmType, sizeof(szParmType), szLABINI))
  1751.             if(lstrcmpi(szVALUE, szParmType) == 0)
  1752.                CheckRadioButton(hDlg, IDR_VALUE, IDR_ADDRESS, IDR_VALUE);
  1753.             else
  1754.                CheckRadioButton(hDlg, IDR_VALUE, IDR_ADDRESS, IDR_ADDRESS);
  1755.          CheckDlgButton(hDlg, IDX_DELETE, GetPrivateProfileInt(szName, szDELETEOPT, 0, szLABINI));
  1756.       }
  1757.       return TRUE;
  1758.       
  1759.      case WM_COMMAND:
  1760.       switch(GET_WM_COMMAND_ID(wParam, lParam)) {
  1761.         case IDB_NEW:
  1762.          {
  1763.             NEWPIPE  np;
  1764.             
  1765.             np.hwnd = hDlg;
  1766.             np.hInst = ci->hInst;
  1767.             NewPipe(&np);
  1768.             if(np.fSuccess) {
  1769.                lstrcpy(szName, np.szName);
  1770.                SendMessage(GetDlgItem(hDlg, IDC_NAME), CB_SETCURSEL,
  1771.                            (WPARAM)SendMessage(GetDlgItem(hDlg, IDC_NAME), CB_ADDSTRING, 
  1772.                                                0, (LPARAM)(LPSTR)szName), 0L);
  1773.                if(cbNames)
  1774.                   SendMessage(hDlg, USER_SETDEFAULTS, 0, 0L);
  1775.                else
  1776.                   SendMessage(hDlg, USER_RESETLIST, 0, 0L);
  1777.             }
  1778.          }              
  1779.          return TRUE;
  1780.          
  1781.         case IDB_DELETE:
  1782.          GetText(GetDlgItem(hDlg, IDC_NAME), szName);
  1783.          wsprintf(OutStr, szDeletePipe, (LPSTR)szName);
  1784.          if(IDOK == MessageBox(hDlg, OutStr, szEditPipe, MB_OKCANCEL)) {
  1785.             WritePrivateProfileString(szName, NULL, NULL, szLABINI);
  1786.             WritePrivateProfileString(szPIPES, szName, NULL, szLABINI);
  1787.             SendMessage(hDlg, USER_RESETLIST, 0, 0L);
  1788.          }
  1789.          return TRUE;
  1790.          
  1791.          //
  1792.          // Read in the info from the dialog, validate the parms, write to file
  1793.          //
  1794.         case IDOK:
  1795.          {
  1796.             char  szSql[MAXSQL];
  1797.             char  szParms[MAXBUFF];
  1798.             GetDlgItemText(hDlg, IDC_NAME, (LPSTR)szName, sizeof(szName));
  1799.             GetDlgItemText(hDlg, IDE_PARMS, szParms, sizeof(szParms));
  1800.             if(IsValidParms(hDlg, szParms)) {
  1801.                WritePrivateProfileString(szName, szPARMS, szParms, szLABINI);
  1802.                
  1803.                GetDlgItemText(hDlg, IDE_SQL, szSql, sizeof(szSql));
  1804.                WritePrivateProfileString(szName, szSQL, szSql, szLABINI);
  1805.                if(IsDlgButtonChecked(hDlg, IDR_VALUE))                   
  1806.                   WritePrivateProfileString(szName, szPARMOPT, szVALUE, szLABINI);
  1807.                else
  1808.                   WritePrivateProfileString(szName, szPARMOPT, szADDRESS, szLABINI);
  1809.                WritePrivateProfileString(szName, szDELETEOPT, 
  1810.                                          (IsDlgButtonChecked(hDlg, IDX_DELETE)) ? (LPSTR)"1" : (LPSTR)"0",
  1811.                                          szLABINI);
  1812.             }
  1813.          }
  1814.          return TRUE;
  1815.          
  1816.         case IDCANCEL:
  1817.          EndDialog(hDlg, IDCANCEL);;
  1818.          return TRUE;
  1819.       }
  1820.       // Now check for control notification messages
  1821.       switch(HIWORD(lParam)) {
  1822.         case CBN_SELENDOK:
  1823.         case CBN_KILLFOCUS:
  1824.          SendMessage(hDlg, USER_SETDEFAULTS, TRUE, 0L);
  1825.          return TRUE;
  1826.          
  1827.         default:
  1828.          break;
  1829.       }
  1830.       break;
  1831.      default:
  1832.       return FALSE;
  1833.    }
  1834.    return FALSE;
  1835. }
  1836. //*---------------------------------------------------------------------------------
  1837. //| NewPipe:
  1838. //|   This function allows the user to create a new pipe.
  1839. //| Parms:
  1840. //|   in       ci                   CHILDINFO information
  1841. //| Returns:              
  1842. //|   Nothing
  1843. //*---------------------------------------------------------------------------------
  1844. void NewPipe(NEWPIPE FAR * np)
  1845. {
  1846.    HWND     fHwnd=GetFocus();
  1847.    if(-1 == DialogBoxParam(np->hInst, 
  1848.                            MAKEINTRESOURCE(IDD_NEW_PIPE),
  1849.                            np->hwnd, 
  1850.                            (DLGPROC) NewPipeWndProc, (LPARAM)np))
  1851.       MessageBox(NULL, "Could not open dialog box.",
  1852.                  "Pipe", MB_ICONEXCLAMATION);
  1853.    
  1854.    if(fHwnd)
  1855.       SetFocus(fHwnd);
  1856. }
  1857. //*------------------------------------------------------------------------
  1858. //| NewPipeWndProc:
  1859. //|   Message handler for creating a new pipe.
  1860. //| Parms:
  1861. //|   in       Standard window parms
  1862. //| Returns:              
  1863. //|   Depends on message
  1864. //*------------------------------------------------------------------------
  1865. BOOL EXTFUN NewPipeWndProc(HWND hDlg, unsigned msg, WPARAM wParam, LPARAM lParam)
  1866. {
  1867.    char                       szName[MAXNAME];
  1868.    static NEWPIPE FAR *       np;
  1869.    switch(msg) {
  1870.      case WM_INITDIALOG:
  1871.       {
  1872.          np = (NEWPIPE FAR *)lParam;
  1873.          CenterDialog(hDlg);
  1874.          SendMessage(GetDlgItem(hDlg, IDE_NAME), EM_LIMITTEXT, MAXNAME, 0L);
  1875.       }
  1876.       return TRUE;      
  1877.      case WM_COMMAND:
  1878.       switch(GET_WM_COMMAND_ID(wParam, lParam)) {
  1879.         case IDOK:
  1880.          {
  1881.             char szTmp[MAXNAME];
  1882.             //
  1883.             // Don't allow names with [,], or = in them, nor any
  1884.             // reserved section names
  1885.             //
  1886.             GetText(GetDlgItem(hDlg, IDE_NAME), (LPSTR)szName);
  1887.             if(!ValidName((LPSTR)szName) ||
  1888.                !*szName ||
  1889.                !lstrcmpi((LPSTR)szName, szSCREEN) ||
  1890.                !lstrcmpi((LPSTR)szName, szFONT) ||
  1891.                !lstrcmpi((LPSTR)szName, szCONNECTOPTIONS) ||
  1892.                !lstrcmpi((LPSTR)szName, szPIPES)) {
  1893.                szMessageBox(hDlg,
  1894.                             MB_ICONEXCLAMATION | MB_OK,
  1895.                             (LPSTR)szErrorMsgTitle,
  1896.                             iLoadString(idsInvalidName, OutStr, MAXBUFF),
  1897.                             (LPSTR)szName);
  1898.                return TRUE;
  1899.             }
  1900.             if(GetPrivateProfileString(szPIPES, szName, NULL,
  1901.                                        szTmp, sizeof(szTmp), szLABINI)) 
  1902.                MessageBox(hDlg, szDuplicatePipe, szEditPipe, MB_OK);
  1903.             else {
  1904.                lstrcpy(np->szName, szName);
  1905.                np->fSuccess = TRUE;
  1906.                WritePrivateProfileString(szPIPES, szName, szInstalled, szLABINI);
  1907.                EndDialog(hDlg, IDOK);
  1908.             }
  1909.          }
  1910.          return TRUE;
  1911.          
  1912.         case IDCANCEL:
  1913.          np->fSuccess = FALSE;
  1914.          EndDialog(hDlg, IDCANCEL);
  1915.          return TRUE;
  1916.       }
  1917.       break;
  1918.      default:
  1919.       return FALSE;
  1920.    }
  1921.    return FALSE;
  1922. }
  1923. //*---------------------------------------------------------------------------------
  1924. //| HandlePipe:
  1925. //|   This function will use the active results set and run use pipes against it.
  1926. //| Parms:
  1927. //|   lpci              Connection window information
  1928. //|   lpri              Ative results set
  1929. //| Returns:              
  1930. //|   Nothing.
  1931. //*---------------------------------------------------------------------------------
  1932. void INTFUN HandlePipe(lpCHILDINFO lpci, lpRESULTSINFO lpri)
  1933. {
  1934.    HWND                 fHwnd=GetFocus();
  1935.    if(-1 == DialogBoxParam(lpci->hInst, 
  1936.                            MAKEINTRESOURCE(IDD_DO_PIPE),
  1937.                            lpci->hwnd, 
  1938.                            (DLGPROC) DoPipeWndProc, (LPARAM)(lpRESULTSINFO)lpri))
  1939.       MessageBox(NULL, "Could not open dialog box.",
  1940.                  "HandlePipe", MB_ICONEXCLAMATION);
  1941.    
  1942.    if(fHwnd)
  1943.       SetFocus(fHwnd);
  1944. }
  1945. //*------------------------------------------------------------------------
  1946. //| DoPipeWndProc:
  1947. //|   Handle dialog messages for IDD_DO_PIPE.
  1948. //| Parms:
  1949. //|   in       Standard window parms
  1950. //| Returns:              
  1951. //|   Depends on message
  1952. //*------------------------------------------------------------------------
  1953. BOOL EXTFUN DoPipeWndProc(HWND hDlg, unsigned msg, WPARAM wParam, LPARAM lParam)
  1954. {
  1955.    static CHILDINFO FAR *     ci;
  1956.    static RESULTSSET FAR *    rs;
  1957.    static SDWORD              cbPipes;
  1958.    switch(msg) {
  1959.      case WM_INITDIALOG:
  1960.       {
  1961.          lpRESULTSINFO rwi;
  1962.          rwi = (lpRESULTSINFO)lParam;
  1963.          ci = rwi->ci;
  1964.          rs = rwi->rs;
  1965.          CenterDialog(hDlg);
  1966.          cbPipes = RefreshPipeList(GetDlgItem(hDlg, IDL_PIPES));
  1967.          EnableWindow(GetDlgItem(hDlg, IDL_PIPES), (int)(cbPipes));
  1968.          EnableWindow(GetDlgItem(hDlg, IDOK), (int)(cbPipes));
  1969.       }
  1970.       return TRUE;      
  1971.      case WM_COMMAND:
  1972.       switch(GET_WM_COMMAND_ID(wParam, lParam)) {
  1973.          // User has clicked OK.  Retrieve an array of the selected indexes
  1974.          // and run the current pipe against each.  Finally see if this
  1975.          // pipe wants to delete items.
  1976.         case IDOK:
  1977.          {
  1978.             int         cbCnt;
  1979.             int FAR *   xSel;
  1980.             int         dex;
  1981.             char        szPipeName[MAXBUFF];
  1982.             Busy(TRUE);
  1983.             cbCnt = (int)SendMessage(rs->hwndList, LB_GETSELCOUNT, 0, 0L);
  1984.             xSel = (int FAR *)GetMemory(sizeof(int) * cbCnt);
  1985.             if(!xSel) {
  1986.                Busy(FALSE);
  1987.                return TRUE;
  1988.             }
  1989.             SendMessage(rs->hwndList, LB_GETSELITEMS, cbCnt, (LPARAM)(int FAR *)xSel);
  1990.             SendMessage(GetDlgItem(hDlg, IDL_PIPES), LB_GETTEXT,
  1991.                         (WPARAM)SendMessage(GetDlgItem(hDlg, IDL_PIPES), LB_GETCURSEL, 0, 0L),
  1992.                         (LPARAM)(LPSTR)szPipeName);
  1993.             DoPipe(rs, ci, (LPSTR)szPipeName, xSel, cbCnt);
  1994.             if(GetPrivateProfileInt(szPipeName, szDELETEOPT, 0, szLABINI))
  1995.                for(dex=cbCnt-1;  dex>=0;  dex--)
  1996.                   SendMessage(rs->hwndList, LB_DELETESTRING, xSel[dex], 0L);
  1997.             Busy(FALSE);
  1998.             ReleaseMemory(xSel);
  1999.          }
  2000.          return TRUE;
  2001.          
  2002.         case IDCANCEL:
  2003.          EndDialog(hDlg, IDCANCEL);
  2004.          return TRUE;
  2005.       }
  2006.       return TRUE;
  2007.      default:
  2008.       return FALSE;
  2009.    }
  2010.    return FALSE;
  2011. }
  2012. //*---------------------------------------------------------------------------------
  2013. //| RefreshPipeList:
  2014. //|   This function will reset the list of pipes based on the values returned
  2015. //|      from GetPipeName.  Having this extra level of abstraction allows us
  2016. //|      to change the location of the pipes without affecting this code.
  2017. //| Parms:
  2018. //|   in       hwnd                 Window handle to list box to fill
  2019. //| Returns:              
  2020. //|   Number of items selected
  2021. //*---------------------------------------------------------------------------------
  2022. SDWORD RefreshPipeList(HWND hDlg)
  2023. {
  2024. #define MAX_PIPE_SIZE 4000
  2025.    LPSTR    szPipes, str;
  2026.    SDWORD count=0;
  2027.    
  2028.    szPipes = (LPSTR)GetMemory(MAX_PIPE_SIZE);
  2029.    if(!szPipes) 
  2030.       return 0;
  2031.    
  2032.    SendMessage(hDlg, LB_RESETCONTENT, 0, 0L);
  2033.    GetPipeNames((LPSTR)szPipes, MAX_PIPE_SIZE);
  2034.    str = szPipes;
  2035.    while(*str) {
  2036.       SendMessage(hDlg, LB_ADDSTRING, 0, (LPARAM)(LPSTR)str);
  2037.       str += lstrlen(str) + 1;
  2038.       ++count;
  2039.    }
  2040.    if(count)
  2041.       SendMessage(hDlg, LB_SETCURSEL, 0, 0L);
  2042.    ReleaseMemory(szPipes);
  2043.    return count;
  2044. }
  2045. //*---------------------------------------------------------------------------------
  2046. //| DoPipe:
  2047. //|   This function will implement a pipe against the object which is passed in.
  2048. //| Parms:
  2049. //|   in       rs                   Pointer to results set describing data
  2050. //|   in       ci                   Connection window information
  2051. //|   in       szPipeName           Name of pipe to use
  2052. //|   in       xPipes               Array of items to pipe
  2053. //|   in       cbCnt                Number of items
  2054. //| Returns:              
  2055. //|   Nothing.
  2056. //*---------------------------------------------------------------------------------
  2057. void DoPipe(RESULTSSET FAR * rs, CHILDINFO FAR * ci, LPSTR szPipeName,
  2058.             int FAR xPipes[], int cbCnt)
  2059. {
  2060.    SDWORD            cbDataAtExec=SQL_DATA_AT_EXEC;
  2061.    int               dex;
  2062.    int               cParm;
  2063.    char              szpsql[200];
  2064.    char              szparms[35];
  2065.    char              parmopt[10];
  2066.    UWORD             cParmCnt=0;
  2067.    LPSTR             str=szparms;
  2068.    LPSTR             numstr=szparms;
  2069.    ROWDATA FAR *     rd;
  2070.    RETCODE           retcode;
  2071.    //
  2072.    // Make sure we can retrieve the pipe from the .ini file.  Also get the parameter
  2073.    //    values if they are available.
  2074.    //
  2075.    if(!GetPrivateProfileString(szPipeName, szSQL, NULL, szpsql, sizeof(szpsql), szLABINI)) {
  2076.       szWrite(ci->hwndOut, 
  2077.               GetidsString(idsPipeNotFound, OutStr, MAXBUFF), 
  2078.               (LPSTR)szPipeName);
  2079.       return;
  2080.    }
  2081.    GetPrivateProfileString(szPipeName, szPARMS, NULL, szparms, sizeof(szparms), szLABINI);
  2082.    GetPrivateProfileString(szPipeName, szPARMOPT, NULL, parmopt, sizeof(parmopt), szLABINI);
  2083.    //
  2084.    // If there are parameters to set, set each one based on user desription
  2085.    //
  2086.    if(str && *str)
  2087.       PrepareParmList(str);
  2088.    SQLFreeStmt(ci->hstmt, SQL_CLOSE);
  2089.    
  2090.    //
  2091.    // What type of parameter passing to do?  value means substitue text and execute,
  2092.    //    address means use parameter data.  The following will handle the former, the
  2093.    //    next more complicated routine will pass parameters.
  2094.    //
  2095.    if(lstrcmpi(parmopt, szVALUE) == 0) {
  2096.       DoPipeByValue(rs, ci, szpsql, str, xPipes, cbCnt, (LPSTR)szPipeName);
  2097.       return;
  2098.    }
  2099.    
  2100.    //
  2101.    // Now prepare the user's statement, return on error
  2102.    //
  2103.    retcode = SQLPrepare(ci->hstmt, szpsql, SQL_NTS);
  2104.    if(retcode != SQL_SUCCESS) {
  2105.       PrintErrors(ci, SQL_HANDLE_STMT);
  2106.       return;
  2107.    }
  2108.    
  2109.    //
  2110.    // For each parameter, make sure it's in our range, then see which mode we want,
  2111.    //    address (param data) or value (textual substitution).
  2112.    //
  2113.    while(*str) {
  2114.       ++cParmCnt;
  2115.       cParm = lpatoi(str);
  2116.       if(cParm > rs->cbColumns) 
  2117.          szWrite(ci->hwndOut, 
  2118.                  GetidsString(idsInvalidParamValue, OutStr, MAXBUFF), 
  2119.                  cParm, (LPSTR)szPipeName);
  2120.       else {
  2121.          retcode = SQLBindParameter(ci->hstmt, 
  2122.                                     cParmCnt, SQL_PARAM_INPUT,
  2123.                                     SQL_C_CHAR, SQL_CHAR, 
  2124.                                     rs->md[cParm-1].precision,
  2125.                                     rs->md[cParm-1].scale, 
  2126.                                     (PTR FAR *)(cParm - 1), 
  2127.                                     rs->md[cParm-1].precision,
  2128.                                     &cbDataAtExec);
  2129.          if(retcode != SQL_SUCCESS) 
  2130.             PrintErrors(ci, SQL_HANDLE_STMT);
  2131.       }
  2132.       str += lstrlen(str) + 1;
  2133.    }  
  2134.    //
  2135.    // For each row selected, retrieve the row data structure associated with it,
  2136.    //    then do an execute.  When prompted for SQL_NEED_DATA, substitute the
  2137.    //    correct parameter address.
  2138.    //
  2139.    for(dex=0;  dex<cbCnt;  dex++) { 
  2140.       int      cNeedParm;
  2141.       rd = (ROWDATA FAR *)SendMessage(rs->hwndList, LB_GETITEMDATA, (WPARAM)xPipes[dex], 0L);
  2142.       retcode = SQLExecute(ci->hstmt);
  2143.       switch(retcode) {
  2144.          //
  2145.          // User had parameter data which we are being prompted for.  Since we
  2146.          //    did the SQLSetParam using the index number, we simply use that
  2147.          //    value to index into our column data and give the driver what
  2148.          //    it requires.
  2149.          //
  2150.         case SQL_NEED_DATA:
  2151.          retcode = SQLParamData(ci->hstmt, (PTR FAR *)&cNeedParm);
  2152.          while(retcode == SQL_NEED_DATA) {
  2153.             retcode = SQLPutData(ci->hstmt, rd->cd[cNeedParm].szCols, SQL_NTS);
  2154.             retcode = SQLParamData(ci->hstmt, (PTR FAR *)&cNeedParm);
  2155.          }
  2156.          break;
  2157.          
  2158.         case SQL_SUCCESS:
  2159.          CheckForResults(ci);
  2160.          break;
  2161.          
  2162.         default:
  2163.          PrintErrors(ci, SQL_HANDLE_STMT);
  2164.          break;
  2165.       }
  2166.    }
  2167.    
  2168.    SQLFreeStmt(ci->hstmt, SQL_CLOSE);
  2169.    return;
  2170. }
  2171. //*---------------------------------------------------------------------------------
  2172. //| PrepareParmList:
  2173. //|   The user will enter a list of numbers separated by columns which will
  2174. //|   designate which parms go for what marker.  We will turn this list into
  2175. //|   a double-null terminated list which can be used later for retrieval.
  2176. //| Parms:
  2177. //|   in       str                  Pointer to string to work on
  2178. //| Returns:              
  2179. //|   Nothing.
  2180. //*---------------------------------------------------------------------------------
  2181. void PrepareParmList(LPSTR str)
  2182. {
  2183.    LPSTR tmpstr=str;
  2184.    LPSTR lststr=tmpstr;
  2185.    //
  2186.    // Convert parm list into a double-null terminated list
  2187.    //
  2188.    while(tmpstr) {
  2189.       if((tmpstr = _fstrchr(str, ','))) {
  2190.          lststr = tmpstr + 1;
  2191.          *tmpstr++ = '';
  2192.       }
  2193.       else {
  2194.          lststr += lstrlen(lststr) + 1;
  2195.          *lststr = '';
  2196.       }
  2197.    }
  2198. }        
  2199. //*---------------------------------------------------------------------------------
  2200. //| DoPipeByValue:
  2201. //|   This function will process all of the selcted values by creating a
  2202. //|   statement which has all parameters embedded in it.
  2203. //|
  2204. //|   Note:    There are some servers which use a semi-colon for the name of
  2205. //|            a stored procedure, but which cannot handle doing a drop of the
  2206. //|            object with this name.  If the pipe name is the reserved name
  2207. //|            of "Drop Procedure (with semi-colon)" then we will strip off the
  2208. //|            name since this can't really be done any other way.
  2209. //| Parms:
  2210. //|   in       rs                   Results set pointer
  2211. //|   in       ci                   Child information
  2212. //|   in       szUserSQL               Statement with parameter markers
  2213. //|   in       szParms              Parameter list, double null terminated
  2214. //|   in       xPipes               Array of indexes to use for param data
  2215. //|   in       cbCnt                Number of records to process
  2216. //|   in       szPipeName           Pipe names
  2217. //| Returns:              
  2218. //|   Nothing.
  2219. //*---------------------------------------------------------------------------------
  2220. void DoPipeByValue(RESULTSSET FAR * rs, CHILDINFO FAR * ci, LPSTR szUserSQL,
  2221.                    LPSTR szParms, int FAR xPipes[], int cbCnt, LPSTR szPipeName)
  2222. {
  2223.    char              szUserSQLCopy[300];
  2224.    char              sqlstmt[300];
  2225.    LPSTR             szParmStrOut;
  2226.    LPSTR             szParmStrIn;
  2227.    LPSTR             szParmStrLast;
  2228.    LPSTR             str=szParms;
  2229.    int               dex;
  2230.    int               cParm;
  2231.    ROWDATA FAR *     rd;
  2232.    BOOL              fSemiProc=FALSE;
  2233.    
  2234.    // Handle special case of a procedure name with a semi-colon
  2235.    if(lstrcmp(szPipeName, szDROPPROCSEMI) == 0)
  2236.       fSemiProc = TRUE;
  2237.    
  2238.    //
  2239.    // For each record selected, create a statement which can be executed by finding
  2240.    //    parameter markers and replacing them at run time.
  2241.    //
  2242.    for(dex=0;  dex<cbCnt;  dex++) {
  2243.       _fmemset(sqlstmt, 0, sizeof(sqlstmt));
  2244.       _fmemset(szUserSQLCopy, 0, sizeof(szUserSQLCopy));
  2245.       lstrcpy(szUserSQLCopy, szUserSQL);
  2246.       szParmStrOut = sqlstmt;
  2247.       szParmStrIn = szUserSQLCopy;
  2248.       szParmStrLast = szParmStrIn;
  2249.       str = szParms;
  2250.       rd = (ROWDATA FAR *)SendMessage(rs->hwndList, LB_GETITEMDATA, (WPARAM)xPipes[dex], 0L);
  2251.       while(*str) {
  2252.          cParm = lpatoi(str);
  2253.          if(cParm > rs->cbColumns) 
  2254.             szWrite(ci->hwndOut, 
  2255.                     GetidsString(idsInvalidParamValue, OutStr, MAXBUFF), 
  2256.                     cParm, (LPSTR)szPipeName);
  2257.          else if(szParmStrIn && *szParmStrIn) {
  2258.             if((szParmStrIn = _fstrchr(szParmStrIn, '?'))) {
  2259.                *szParmStrIn++ = '';
  2260.                lstrcpy(szParmStrOut, szParmStrLast);
  2261.                _fstrcat(szParmStrOut, rd->cd[cParm-1].szCols);
  2262.                // Remove semi-colon for special case of drop procedure
  2263.                if(fSemiProc) {
  2264.                   LPSTR    str = _fstrchr(szParmStrOut, ';');
  2265.                   if(str)
  2266.                      *str = '';
  2267.                }
  2268.                szParmStrLast = szParmStrIn; 
  2269.             }
  2270.             else
  2271.                lstrcpy(szParmStrOut, szParmStrLast);              // end of list
  2272.          }
  2273.          str += lstrlen(str) + 1;
  2274.       }
  2275.       if(*szParmStrLast)
  2276.          _fstrcat(szParmStrOut, szParmStrLast);
  2277.       ExecuteCmds(ci, sqlstmt);
  2278.    }
  2279.    
  2280.    return;
  2281. }