// Make sure the cursor is closed first
if (! CloseCursor(hstmt))
return(FALSE);
-
+
// Execute the SQL SELECT statement
if (SQLExecDirect(hstmt, (UCHAR FAR *) (queryType == DB_SELECT_STATEMENT ? pSqlStmt : sqlStmt),
SQL_NTS) != SQL_SUCCESS)
/********** wxTable::bindInsertParams() **********/
bool wxTable::bindInsertParams(void)
{
- SWORD fSqlType;
- UDWORD precision;
- SWORD scale;
+ SWORD fSqlType = 0;
+ UDWORD precision = 0;
+ SWORD scale = 0;
// Bind each column (that can be inserted) of the table to a parameter marker
for (int i = 0; i < noCols; i++)
/********** wxTable::bindUpdateParams() **********/
bool wxTable::bindUpdateParams(void)
{
- SWORD fSqlType;
- UDWORD precision;
- SWORD scale;
+ SWORD fSqlType = 0;
+ UDWORD precision = 0;
+ SWORD scale = 0;
// Bind each UPDATEABLE column of the table to a parameter marker
for (int i = 0, colNo = 1; i < noCols; i++)
sprintf(sqlStmt, "DROP TABLE %s", tableName);
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt, SQL_NTS) != SQL_SUCCESS)
{
- // Check for sqlState = S0002, "Table or view not found".
- // Ignore this error, bomb out on any other error.
- // SQL Sybase Anwhere v5.5 returns an access violation error here
- // (sqlstate = 42000) rather than an S0002.
+ /* Check for sqlState = S0002, "Table or view not found".
+ * Ignore this error, bomb out on any other error.
+ * SQL Sybase Anwhere v5.5 returns an access violation error here
+ * (sqlstate = 42000) rather than an S0002. */
+
+ /* PostgreSQL 6.4.0 returns "08S01" or in written form
+ "ERROR: Relation ... Does Not Exist", Robert Roebling */
+
+ /* MySQL 3.23.33b returns "S1000" or in written form
+ "ERROR: Unknown table ...", Robert Roebling */
+
+ /* This routine is bullshit, Robert Roebling */
+
pDb->GetNextError(henv, hdbc, hstmt);
- if (strcmp(pDb->sqlState, "S0002") && strcmp(pDb->sqlState, "42000"))
+ if (strcmp(pDb->sqlState, "S0002") &&
+ strcmp(pDb->sqlState, "S1000") &&
+ strcmp(pDb->sqlState, "42000") &&
+ strcmp(pDb->sqlState, "08S01"))
{
pDb->DispNextError();
pDb->DispAllErrors(henv, hdbc, hstmt);
sprintf(s, "(%d)", colDefs[i].SzDataObj);
strcat(sqlStmt, s);
}
+
+#ifdef __WXGTK__
+ if (colDefs[i].KeyField)
+ {
+ strcat(sqlStmt, " NOT NULL");
+ }
+#endif
+
needComma = TRUE;
}
// If there is a primary key defined, include it in the create statement
}
if (j) // Found a keyfield
{
+#ifndef __WXGTK__
+ /* MySQL goes out on this one. We also declare the relevant key NON NULL above */
strcat(sqlStmt, ",CONSTRAINT ");
strcat(sqlStmt, tableName);
strcat(sqlStmt, "_PIDX PRIMARY KEY (");
+#else
+ strcat(sqlStmt, ", PRIMARY KEY (");
+#endif
+
// List column name(s) of column(s) comprising the primary key
for (i = j = 0; i < noCols; i++)
{
strcat(sqlStmt, ")");
}
// Append the closing parentheses for the create table statement
- strcat(sqlStmt, ")");
-
+ strcat(sqlStmt, ")");
+
pDb->WriteSqlLog(sqlStmt);
#ifdef _CONSOLE
for (int i = 0; i < noIdxCols; i++)
{
strcat(sqlStmt, pIdxDefs[i].ColName);
+
+ /* Postgres doesnt cope with ASC */
+#ifndef __WXGTK__
if (pIdxDefs[i].Ascending)
strcat(sqlStmt, " ASC");
else
strcat(sqlStmt, " DESC");
+#endif
+
if ((i + 1) < noIdxCols)
- strcat(sqlStmt, ",");
+ strcat(sqlStmt, ", ");
}
// Append closing parentheses
int cType, int size, bool keyField, bool upd,
bool insAllow, bool derivedCol)
{
- if (strlen(fieldName) > (uint)DB_MAX_COLUMN_NAME_LEN) // glt 4/21/97
+ // Please, no uint, it doesn't exist for VC++
+ if (strlen(fieldName) > (unsigned int) DB_MAX_COLUMN_NAME_LEN) // glt 4/21/97
{
strncpy (colDefs[index].ColName, fieldName, DB_MAX_COLUMN_NAME_LEN);
colDefs[index].ColName[DB_MAX_COLUMN_NAME_LEN] = 0; // glt 10/23/97