- // Assign member variables
- pDb = pwxDB; // Pointer to the wxDB object
-
- strcpy(tableName, tblName); // Table Name
- if (qryTblName) // Name of the table/view to query
- strcpy(queryTableName, qryTblName);
- else
- strcpy(queryTableName, tblName);
-
- assert(pDb); // Assert is placed after table name is assigned for error reporting reasons
- if (!pDb)
- return;
-
- noCols = nCols; // No. of cols in the table
- where = 0; // Where clause
- orderBy = 0; // Order By clause
- from = 0; // From clause
- selectForUpdate = FALSE; // SELECT ... FOR UPDATE; Indicates whether to include the FOR UPDATE phrase
-
- // Grab the HENV and HDBC from the wxDB object
- henv = pDb->henv;
- hdbc = pDb->hdbc;
-
- // Allocate space for column definitions
- if (noCols)
- colDefs = new CcolDef[noCols]; // Points to the first column defintion
- else
- colDefs = 0;
-
- // Allocate statement handles for the table
- if (SQLAllocStmt(hdbc, &c0) != SQL_SUCCESS)
- pDb->DispAllErrors(henv, hdbc);
- if (SQLAllocStmt(hdbc, &c1) != SQL_SUCCESS)
- pDb->DispAllErrors(henv, hdbc);
- if (SQLAllocStmt(hdbc, &c2) != SQL_SUCCESS)
- pDb->DispAllErrors(henv, hdbc);
-// if (SQLAllocStmt(hdbc, &c3) != SQL_SUCCESS)
-// pDb->DispAllErrors(henv, hdbc);
-// if (SQLAllocStmt(hdbc, &c4) != SQL_SUCCESS)
-// pDb->DispAllErrors(henv, hdbc);
-// if (SQLAllocStmt(hdbc, &c5) != SQL_SUCCESS)
-// pDb->DispAllErrors(henv, hdbc);
- // Allocate a separate statement handle for performing inserts
- if (SQLAllocStmt(hdbc, &hstmtInsert) != SQL_SUCCESS)
- pDb->DispAllErrors(henv, hdbc);
- // Allocate a separate statement handle for performing deletes
- if (SQLAllocStmt(hdbc, &hstmtDelete) != SQL_SUCCESS)
- pDb->DispAllErrors(henv, hdbc);
- // Allocate a separate statement handle for performing updates
- if (SQLAllocStmt(hdbc, &hstmtUpdate) != SQL_SUCCESS)
- pDb->DispAllErrors(henv, hdbc);
- // Allocate a separate statement handle for performing count(*) function
- if (SQLAllocStmt(hdbc, &hstmtCount) != SQL_SUCCESS)
- pDb->DispAllErrors(henv, hdbc);
-
- // Set the cursor type for the statement handles
- UDWORD cursorType = SQL_CURSOR_STATIC;
- if (SQLSetStmtOption(c1, SQL_CURSOR_TYPE, cursorType) != SQL_SUCCESS)
- {
- // Check to see if cursor type is supported
- pDb->GetNextError(henv, hdbc, c1);
- if (! strcmp(pDb->sqlState, "01S02")) // Option Value Changed
- {
- // Datasource does not support static cursors. Driver
- // will substitute a cursor type. Call SQLGetStmtOption()
- // to determine which cursor type was selected.
- if (SQLGetStmtOption(c1, SQL_CURSOR_TYPE, &cursorType) != SQL_SUCCESS)
- pDb->DispAllErrors(henv, hdbc, c1);
-#ifdef _CONSOLE
- cout << "Static cursor changed to: ";
- switch(cursorType)
- {
- case SQL_CURSOR_FORWARD_ONLY:
- cout << "Forward Only"; break;
- case SQL_CURSOR_STATIC:
- cout << "Static"; break;
- case SQL_CURSOR_KEYSET_DRIVEN:
- cout << "Keyset Driven"; break;
- case SQL_CURSOR_DYNAMIC:
- cout << "Dynamic"; break;
- }
- cout << endl << endl;
+ pDb = pwxDb; // Pointer to the wxDb object
+ henv = 0;
+ hdbc = 0;
+ hstmt = 0;
+ hstmtDefault = 0; // Initialized below
+ hstmtCount = 0; // Initialized first time it is needed
+ hstmtInsert = 0;
+ hstmtDelete = 0;
+ hstmtUpdate = 0;
+ hstmtInternal = 0;
+ colDefs = 0;
+ tableID = 0;
+ noCols = nCols; // No. of cols in the table
+ where = ""; // Where clause
+ orderBy = ""; // Order By clause
+ from = ""; // From clause
+ selectForUpdate = FALSE; // SELECT ... FOR UPDATE; Indicates whether to include the FOR UPDATE phrase
+ queryOnly = qryOnly;
+ insertable = TRUE;
+ wxStrcpy(tablePath,"");
+ wxStrcpy(tableName,"");
+ wxStrcpy(queryTableName,"");
+
+ assert (tblName);
+
+ wxStrcpy(tableName, tblName); // Table Name
+ if (tblPath)
+ wxStrcpy(tablePath, tblPath); // Table Path - used for dBase files
+ else
+ tablePath[0] = 0;
+
+ if (qryTblName) // Name of the table/view to query
+ wxStrcpy(queryTableName, qryTblName);
+ else
+ wxStrcpy(queryTableName, tblName);
+
+ if (!pDb)
+ return;
+
+ pDb->incrementTableCount();
+
+ wxString s;
+ tableID = ++lastTableID;
+ s.sprintf("wxDbTable constructor (%-20s) tableID:[%6lu] pDb:[%p]", tblName,tableID,pDb);
+
+#ifdef __WXDEBUG__
+ wxTablesInUse *tableInUse;
+ tableInUse = new wxTablesInUse();
+ tableInUse->tableName = tblName;
+ tableInUse->tableID = tableID;
+ tableInUse->pDb = pDb;
+ TablesInUse.Append(tableInUse);