+/********** wxDB::Catalog() **********/
+bool wxDB::Catalog(char *userID, char *fileName)
+{
+ assert(userID && strlen(userID));
+ assert(fileName && strlen(fileName));
+
+ RETCODE retcode;
+ SDWORD cb;
+ char tblName[DB_MAX_TABLE_NAME_LEN+1];
+ char tblNameSave[DB_MAX_TABLE_NAME_LEN+1];
+ char colName[DB_MAX_COLUMN_NAME_LEN+1];
+ SWORD sqlDataType;
+ char typeName[16];
+ SWORD precision, length;
+
+ FILE *fp = fopen(fileName,"wt");
+ if (fp == NULL)
+ return(FALSE);
+
+ SQLFreeStmt(hstmt, SQL_CLOSE);
+
+ int i = 0;
+ char userIdUC[81];
+ for (char *p = userID; *p; p++)
+ userIdUC[i++] = toupper(*p);
+ userIdUC[i] = 0;
+
+ retcode = SQLColumns(hstmt,
+ NULL, 0, // All qualifiers
+ (UCHAR *) userIdUC, SQL_NTS, // User specified
+ NULL, 0, // All tables
+ NULL, 0); // All columns
+ if (retcode != SQL_SUCCESS)
+ {
+ DispAllErrors(henv, hdbc, hstmt);
+ fclose(fp);
+ return(FALSE);
+ }
+
+ SQLBindCol(hstmt, 3, SQL_C_CHAR, (UCHAR*) tblName, DB_MAX_TABLE_NAME_LEN+1, &cb);
+ SQLBindCol(hstmt, 4, SQL_C_CHAR, (UCHAR*) colName, DB_MAX_COLUMN_NAME_LEN+1, &cb);
+ SQLBindCol(hstmt, 5, SQL_C_SSHORT, (UCHAR*) &sqlDataType, 0, &cb);
+ SQLBindCol(hstmt, 6, SQL_C_CHAR, (UCHAR*) typeName, 16, &cb);
+ SQLBindCol(hstmt, 7, SQL_C_SSHORT, (UCHAR*) &precision, 0, &cb);
+ SQLBindCol(hstmt, 8, SQL_C_SSHORT, (UCHAR*) &length, 0, &cb);
+
+ char outStr[256];
+ strcpy(tblNameSave,"");
+ int cnt = 0;
+
+ while ((retcode = SQLFetch(hstmt)) == SQL_SUCCESS)
+ {
+ if (strcmp(tblName,tblNameSave))
+ {
+ if (cnt)
+ fputs("\n", fp);
+ fputs("================================ ", fp);
+ fputs("================================ ", fp);
+ fputs("===================== ", fp);
+ fputs("========= ", fp);
+ fputs("=========\n", fp);
+ sprintf(outStr, "%-32s %-32s %-21s %9s %9s\n",
+ "TABLE NAME", "COLUMN NAME", "DATA TYPE", "PRECISION", "LENGTH");
+ fputs(outStr, fp);
+ fputs("================================ ", fp);
+ fputs("================================ ", fp);
+ fputs("===================== ", fp);
+ fputs("========= ", fp);
+ fputs("=========\n", fp);
+ strcpy(tblNameSave,tblName);
+ }
+ sprintf(outStr, "%-32s %-32s (%04d)%-15s %9d %9d\n",
+ tblName, colName, sqlDataType, typeName, precision, length);
+ if (fputs(outStr, fp) == EOF)
+ {
+ fclose(fp);
+ return(FALSE);
+ }
+ cnt++;
+ }
+
+ if (retcode != SQL_NO_DATA_FOUND)
+ {
+ DispAllErrors(henv, hdbc, hstmt);
+ fclose(fp);
+ return(FALSE);
+ }
+
+ SQLFreeStmt(hstmt, SQL_CLOSE);
+ fclose(fp);
+ return(TRUE);
+
+} // wxDB::Catalog()
+
+