1 \section{\class{wxDb
}}\label{wxdb
}
3 A wxDb instance is a connection to an ODBC data source which may
4 be opened, closed, and re-opened an unlimited number of times. A
5 database connection allows function to be performed directly on the
6 data source, as well as allowing access to any tables/views defined in
7 the data source to which the user has sufficient privileges.
9 \wxheading{Include files
}
13 \wxheading{Helper classes and data structures
}
15 The following classes and structs are defined in db.cpp/.h for use with the wxDb class.
17 \begin{itemize
}\itemsep=
0pt
18 \item \helpref{wxDbColFor
}{wxdbcolfor
}
19 \item \helpref{wxDbColInf
}{wxdbcolinf
}
20 \item \helpref{wxDbTableInf
}{wxdbtableinf
}
21 \item \helpref{wxDbInf
}{wxdbinf
}
26 NOTE: In a future release, all ODBC class constants will be prefaced with 'wx'
30 wxDB_PATH_MAX Maximum path length allowed to be passed to the ODBC
31 driver to indicate where the data file is located.
33 DB_MAX_COLUMN_NAME_LEN Maximum supported length for the name of a column
35 DB_MAX_ERROR_HISTORY Maximum number of error messages retained in the
36 queue before being overwritten by new errors.
38 DB_MAX_ERROR_MSG_LEN Maximum supported length of an error message returned
41 DB_MAX_STATEMENT_LEN Maximum supported length for a complete SQL statement
42 to be passed to the ODBC driver
44 DB_MAX_TABLE_NAME_LEN Maximum supported length for the name of a table
46 DB_MAX_WHERE_CLAUSE_LEN Maximum supported WHERE clause length that can be
47 passed to the ODBC driver
49 DB_TYPE_NAME_LEN Maximum length of the name of a column's data type
53 \wxheading{Enumerated types
}
55 \docparam{enum
{\bf wxDbSqlLogState
}}{sqlLogOFF, sqlLogON
}
57 {\it enum
{\bf wxDBMS
}}
59 These are the databases currently tested and working with the ODBC classes. A call to
\helpref{wxDb::Dbms
}{wxdbdbms
} will return one of these enumerated values listed below.
64 dbmsSYBASE_ASA, // Adaptive Server Anywhere
65 dbmsSYBASE_ASE, // Adaptive Server Enterprise
74 See the remarks in
\helpref{wxDb::Dbms
}{wxdbdbms
} for exceptions/issues with each of these database engines.
76 \wxheading{Public member variables
}
78 \docparam{SWORD
{\bf wxDb::cbErrorMsg
}}{This member variable is populated as a result of calling
\helpref{wxDb::GetNextError
}{wxdbgetnexterror
}. Contains the count of bytes in the wxDb::errorMsg string.
}
80 \docparam{int
{\bf wxDb::DB
\_STATUS}}{The last ODBC error that occurred on this data connection. Possible codes are:
}
83 DB_ERR_GENERAL_WARNING // SqlState = '
01000'
84 DB_ERR_DISCONNECT_ERROR // SqlState = '
01002'
85 DB_ERR_DATA_TRUNCATED // SqlState = '
01004'
86 DB_ERR_PRIV_NOT_REVOKED // SqlState = '
01006'
87 DB_ERR_INVALID_CONN_STR_ATTR // SqlState = '
01S00'
88 DB_ERR_ERROR_IN_ROW // SqlState = '
01S01'
89 DB_ERR_OPTION_VALUE_CHANGED // SqlState = '
01S02'
90 DB_ERR_NO_ROWS_UPD_OR_DEL // SqlState = '
01S03'
91 DB_ERR_MULTI_ROWS_UPD_OR_DEL // SqlState = '
01S04'
92 DB_ERR_WRONG_NO_OF_PARAMS // SqlState = '
07001'
93 DB_ERR_DATA_TYPE_ATTR_VIOL // SqlState = '
07006'
94 DB_ERR_UNABLE_TO_CONNECT // SqlState = '
08001'
95 DB_ERR_CONNECTION_IN_USE // SqlState = '
08002'
96 DB_ERR_CONNECTION_NOT_OPEN // SqlState = '
08003'
97 DB_ERR_REJECTED_CONNECTION // SqlState = '
08004'
98 DB_ERR_CONN_FAIL_IN_TRANS // SqlState = '
08007'
99 DB_ERR_COMM_LINK_FAILURE // SqlState = '
08S01'
100 DB_ERR_INSERT_VALUE_LIST_MISMATCH // SqlState = '
21S01'
101 DB_ERR_DERIVED_TABLE_MISMATCH // SqlState = '
21S02'
102 DB_ERR_STRING_RIGHT_TRUNC // SqlState = '
22001'
103 DB_ERR_NUMERIC_VALUE_OUT_OF_RNG // SqlState = '
22003'
104 DB_ERR_ERROR_IN_ASSIGNMENT // SqlState = '
22005'
105 DB_ERR_DATETIME_FLD_OVERFLOW // SqlState = '
22008'
106 DB_ERR_DIVIDE_BY_ZERO // SqlState = '
22012'
107 DB_ERR_STR_DATA_LENGTH_MISMATCH // SqlState = '
22026'
108 DB_ERR_INTEGRITY_CONSTRAINT_VIOL // SqlState = '
23000'
109 DB_ERR_INVALID_CURSOR_STATE // SqlState = '
24000'
110 DB_ERR_INVALID_TRANS_STATE // SqlState = '
25000'
111 DB_ERR_INVALID_AUTH_SPEC // SqlState = '
28000'
112 DB_ERR_INVALID_CURSOR_NAME // SqlState = '
34000'
113 DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL // SqlState = '
37000'
114 DB_ERR_DUPLICATE_CURSOR_NAME // SqlState = '
3C000'
115 DB_ERR_SERIALIZATION_FAILURE // SqlState = '
40001'
116 DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL2 // SqlState = '
42000'
117 DB_ERR_OPERATION_ABORTED // SqlState = '
70100'
118 DB_ERR_UNSUPPORTED_FUNCTION // SqlState = 'IM001'
119 DB_ERR_NO_DATA_SOURCE // SqlState = 'IM002'
120 DB_ERR_DRIVER_LOAD_ERROR // SqlState = 'IM003'
121 DB_ERR_SQLALLOCENV_FAILED // SqlState = 'IM004'
122 DB_ERR_SQLALLOCCONNECT_FAILED // SqlState = 'IM005'
123 DB_ERR_SQLSETCONNECTOPTION_FAILED // SqlState = 'IM006'
124 DB_ERR_NO_DATA_SOURCE_DLG_PROHIB // SqlState = 'IM007'
125 DB_ERR_DIALOG_FAILED // SqlState = 'IM008'
126 DB_ERR_UNABLE_TO_LOAD_TRANSLATION_DLL // SqlState = 'IM009'
127 DB_ERR_DATA_SOURCE_NAME_TOO_LONG // SqlState = 'IM010'
128 DB_ERR_DRIVER_NAME_TOO_LONG // SqlState = 'IM011'
129 DB_ERR_DRIVER_KEYWORD_SYNTAX_ERROR // SqlState = 'IM012'
130 DB_ERR_TRACE_FILE_ERROR // SqlState = 'IM013'
131 DB_ERR_TABLE_OR_VIEW_ALREADY_EXISTS // SqlState = 'S0001'
132 DB_ERR_TABLE_NOT_FOUND // SqlState = 'S0002'
133 DB_ERR_INDEX_ALREADY_EXISTS // SqlState = 'S0011'
134 DB_ERR_INDEX_NOT_FOUND // SqlState = 'S0012'
135 DB_ERR_COLUMN_ALREADY_EXISTS // SqlState = 'S0021'
136 DB_ERR_COLUMN_NOT_FOUND // SqlState = 'S0022'
137 DB_ERR_NO_DEFAULT_FOR_COLUMN // SqlState = 'S0023'
138 DB_ERR_GENERAL_ERROR // SqlState = 'S1000'
139 DB_ERR_MEMORY_ALLOCATION_FAILURE // SqlState = 'S1001'
140 DB_ERR_INVALID_COLUMN_NUMBER // SqlState = 'S1002'
141 DB_ERR_PROGRAM_TYPE_OUT_OF_RANGE // SqlState = 'S1003'
142 DB_ERR_SQL_DATA_TYPE_OUT_OF_RANGE // SqlState = 'S1004'
143 DB_ERR_OPERATION_CANCELLED // SqlState = 'S1008'
144 DB_ERR_INVALID_ARGUMENT_VALUE // SqlState = 'S1009'
145 DB_ERR_FUNCTION_SEQUENCE_ERROR // SqlState = 'S1010'
146 DB_ERR_OPERATION_INVALID_AT_THIS_TIME // SqlState = 'S1011'
147 DB_ERR_INVALID_TRANS_OPERATION_CODE // SqlState = 'S1012'
148 DB_ERR_NO_CURSOR_NAME_AVAIL // SqlState = 'S1015'
149 DB_ERR_INVALID_STR_OR_BUF_LEN // SqlState = 'S1090'
150 DB_ERR_DESCRIPTOR_TYPE_OUT_OF_RANGE // SqlState = 'S1091'
151 DB_ERR_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1092'
152 DB_ERR_INVALID_PARAM_NO // SqlState = 'S1093'
153 DB_ERR_INVALID_SCALE_VALUE // SqlState = 'S1094'
154 DB_ERR_FUNCTION_TYPE_OUT_OF_RANGE // SqlState = 'S1095'
155 DB_ERR_INF_TYPE_OUT_OF_RANGE // SqlState = 'S1096'
156 DB_ERR_COLUMN_TYPE_OUT_OF_RANGE // SqlState = 'S1097'
157 DB_ERR_SCOPE_TYPE_OUT_OF_RANGE // SqlState = 'S1098'
158 DB_ERR_NULLABLE_TYPE_OUT_OF_RANGE // SqlState = 'S1099'
159 DB_ERR_UNIQUENESS_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1100'
160 DB_ERR_ACCURACY_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1101'
161 DB_ERR_DIRECTION_OPTION_OUT_OF_RANGE // SqlState = 'S1103'
162 DB_ERR_INVALID_PRECISION_VALUE // SqlState = 'S1104'
163 DB_ERR_INVALID_PARAM_TYPE // SqlState = 'S1105'
164 DB_ERR_FETCH_TYPE_OUT_OF_RANGE // SqlState = 'S1106'
165 DB_ERR_ROW_VALUE_OUT_OF_RANGE // SqlState = 'S1107'
166 DB_ERR_CONCURRENCY_OPTION_OUT_OF_RANGE // SqlState = 'S1108'
167 DB_ERR_INVALID_CURSOR_POSITION // SqlState = 'S1109'
168 DB_ERR_INVALID_DRIVER_COMPLETION // SqlState = 'S1110'
169 DB_ERR_INVALID_BOOKMARK_VALUE // SqlState = 'S1111'
170 DB_ERR_DRIVER_NOT_CAPABLE // SqlState = 'S1C00'
171 DB_ERR_TIMEOUT_EXPIRED // SqlState = 'S1T00'
174 \docparam{struct
{\bf wxDb::dbInf
}}{This structure is internal to the wxDb class and contains details of the ODBC datasource that the current instance of the wxDb is connected to in its members. When the data source is opened, all of the information contained in the dbInf structure is queried from the data source. This information is used almost exclusively within the ODBC class library. Where there is a need for this information outside of the class library a member function such as wxDbTable::IsCursorClosedOnCommit() has been added for ease of use.
}
177 char dbmsName
[40] - Name of the dbms product
178 char dbmsVer
[64] - Version # of the dbms product
179 char driverName
[40] - Driver name
180 char odbcVer
[60] - ODBC version of the driver
181 char drvMgrOdbcVer
[60] - ODBC version of the driver manager
182 char driverVer
[60] - Driver version
183 char serverName
[80] - Server Name, typically a connect string
184 char databaseName
[128] - Database filename
185 char outerJoins
[2] - Does datasource support outer joins
186 char procedureSupport
[2] - Does datasource support stored procedures
187 UWORD maxConnections - Maximum # of connections datasource supports
188 UWORD maxStmts - Maximum # of HSTMTs per HDBC
189 UWORD apiConfLvl - ODBC API conformance level
190 UWORD cliConfLvl - Is datasource SAG compliant
191 UWORD sqlConfLvl - SQL conformance level
192 UWORD cursorCommitBehavior - How cursors are affected on db commit
193 UWORD cursorRollbackBehavior - How cursors are affected on db rollback
194 UWORD supportNotNullClause - Does datasource support NOT NULL clause
195 char supportIEF
[2] - Integrity Enhancement Facility (Ref. Integrity)
196 UDWORD txnIsolation - Transaction isolation level supported by driver
197 UDWORD txnIsolationOptions - Transaction isolation level options available
198 UDWORD fetchDirections - Fetch directions supported
199 UDWORD lockTypes - Lock types supported in SQLSetPos
200 UDWORD posOperations - Position operations supported in SQLSetPos
201 UDWORD posStmts - Position statements supported
202 UDWORD scrollConcurrency - Scrollable cursor concurrency options supported
203 UDWORD scrollOptions - Scrollable cursor options supported
204 UDWORD staticSensitivity - Can additions/deletions/updates be detected
205 UWORD txnCapable - Indicates if datasource supports transactions
206 UDWORD loginTimeout - Number seconds to wait for a login request
209 \docparam{char
{\bf wxDb::errorList
}[DB_MAX_ERROR_HISTORY
][DB_MAX_ERROR_MSG_LEN
]}{The last n ODBC errors that have occurred on this database connection.
}
211 \docparam{char
{\bf wxDb::errorMsg
}[SQL_MAX_MESSAGE_LENGTH
]}{This member variable is populated as a result of calling
\helpref{wxDb::GetNextError
}{wxdbgetnexterror
}. It contains the ODBC error message text.
}
213 \docparam{SDWORD
{\bf wxDb::nativeError
}}{Set by wxDb::DispAllErrors, wxDb::GetNextError, and wxDb::DispNextError. It contains the datasource-specific error code returned by the datasource to the ODBC driver. Used for reporting ODBC errors.
}
215 \docparam{wxChar
{\bf wxDb::sqlState
}[20]}{Set by wxDb::TranslateSqlState(). Indicates the error state after a failed ODBC operation. Used for reporting ODBC errors.
}
219 Default cursor scrolling is defined by wxODBC_FWD_ONLY_CURSORS in setup.h
220 when the wxWindows library is built. This behavior can be overridden when
221 an instance of a wxDb is created (see
\helpref{wxDb constructor
}{wxdbconstr
}).
225 \helpref{wxDbColFor
}{wxdbcolfor
},
\helpref{wxDbColInf
}{wxdbcolinf
},
\helpref{wxDbTable
}{wxdbtable
},
\helpref{wxDbTableInf
}{wxdbtableinf
},
\helpref{wxDbInf
}{wxdbinf
}
227 \subsection{Associated non-class functions
}\label{wxdbfunctions
}
229 The following functions are used in conjunction with the wxDb class.
231 \func{wxDb *
}{wxDbGetConnection
}{\param{wxDbConnectInf *
}{pDbConfig
},
\param{bool
}{FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS
}}
233 \func{bool
}{wxDbFreeConnection
}{\param{wxDb *
}{pDb
}}
235 \func{void
}{wxDbCloseConnections
}{\void}
237 \func{int
}{wxDbConnectionsInUse
}{\void}
239 \func{bool
}{wxDbSqlLog
}{\param{wxDbSqlLogState
}{state
},
\param{const wxChar *
}{filename = SQL_LOG_FILENAME
}}
241 \func{bool
}{wxDbGetDataSource
}{\param{HENV
}{henv
},
\param{char *
}{Dsn
},
\param{SWORD
}{DsnMax
},
\param{char *
}{DsDesc
},
\param{SWORD
}{DsDescMax
},
\param{UWORD
}{direction = SQL_FETCH_NEXT
}}
243 \latexignore{\rtfignore{\wxheading{Members
}}}
245 \membersection{wxDb::wxDb
}\label{wxdbconstr
}
251 \func{}{wxDb
}{\param{HENV\&
}{aHenv
},
\param{bool
}{FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS
}}
253 Constructor, used to create an ODBC connection to a data source.
255 \wxheading{Parameters
}
257 \docparam{aHenv
}{Environment handle used for this connection.
}
259 \docparam{FwdOnlyCursors
}{Will cursors created for use with this datasource connection only allow forward scrolling cursors.
}
263 This is the constructor for the wxDb class. The wxDb object must
264 be created and opened before any database activity can occur.
269 wxDbConnectInf ConnectInf;
270 ....Set values for member variables of ConnectInf here
272 wxDb sampleDB(ConnectInf.Henv);
273 if (!sampleDB.Open(ConnectInf.Dsn, ConnectInf.Uid, ConnectInf.AuthStr))
275 // Error opening data source
280 \membersection{wxDb::Catalog
}\label{wxdbcatalog
}
282 \func{bool
}{Catalog
}{\param{char *
}{ userID
},
\param{char *
}{fileName = SQL_CATALOG_FILENAME
}}
284 Allows a data "dictionary" of the data source to be created, dumping pertinent information about all data tables to which the user specified in userID has access.
286 \wxheading{Parameters
}
288 \docparam{userID
}{Database user name to use in accessing the database. All tables to which this user has rights will be evaluated in the catalog.
}
290 \docparam{fileName
}{OPTIONAL argument. Name of the text file to create and write the DB catalog to.
}
292 \wxheading{Return value
}
294 Returns TRUE if the catalog request was successful, of FALSE if there was some reason the catalog could not be generated
299 ============== ============== ================ ========= =======
300 TABLE NAME COLUMN NAME DATA TYPE PRECISION LENGTH
301 ============== ============== ================ ========= =======
302 EMPLOYEE RECID (
0008)NUMBER
15 8
303 EMPLOYEE USER_ID (
0012)VARCHAR2
13 13
304 EMPLOYEE FULL_NAME (
0012)VARCHAR2
26 26
305 EMPLOYEE PASSWORD (
0012)VARCHAR2
26 26
306 EMPLOYEE START_DATE (
0011)DATE
19 16
310 \membersection{wxDb::Close
}\label{wxdbclose
}
312 \func{void
}{Close
}{\void}
314 Closes the database connection.
318 At the end of your program, when you have finished all of your database work, you must close the ODBC connection to the data source. There are actually four steps involved in doing this as illustrated in the example.
320 Any wxDbTable instances which use this connection must be deleted before closing the database connection.
325 // Commit any open transactions on the data source
326 sampleDB.CommitTrans();
328 // Delete any remaining wxDbTable objects allocated with new
331 // Close the wxDb connection when finished with it
334 // Free Environment Handle that ODBC uses
335 if (SQLFreeEnv(Db.Henv) != SQL_SUCCESS)
337 // Error freeing environment handle
342 \membersection{wxDb::CommitTrans
}\label{wxdbcommittrans
}
344 \func{bool
}{CommitTrans
}{\void}
346 Permanently "commits" changes (insertions/deletions/updates) to the database.
348 \wxheading{Return value
}
350 Returns TRUE if the commit was successful, or FALSE if the commit failed.
354 Transactions begin implicitly as soon as you make a change to the database. At any time thereafter, you can save your work to the database ("Commit") or roll back all of your changes ("Rollback"). Calling this member function commits all open transactions on this ODBC connection.
356 \wxheading{Special Note :
{\it Cursors
} }
358 \normalbox{It is important to understand that different database/ODBC driver combinations handle
359 transactions differently. One thing in particular that you must pay attention to is
360 cursors, in regard to transactions. Cursors are what allow you to scroll through
361 records forward and backward and to manipulate records as you scroll through them.
362 When you issue a query, a cursor is created behind the scenes. The cursor keeps track
363 of the query and keeps track of the current record pointer. After you commit or
364 rollback a transaction, the cursor may be closed automatically. This means you must
365 requery the data source before you can perform any additional work against the wxDbTable
366 object. This is only necessary however if the data source closes the cursor after a
367 commit or rollback. Use the wxDbTable::IsCursorClosedOnCommit() member function to
368 determine the data source's transaction behavior. Note, it would be very inefficient
369 to just assume the data source closes the cursor and always requery. This could put
370 a significant, unnecessary load on data sources that leave the cursors open after a
374 \membersection{wxDb::CreateView
}\label{wxdbcreateviews
}
376 \func{bool
}{CreateView
}{\param{char *
}{ viewName
},
\param{char *
}{ colList
},
\param{char *
}{pSqlStmt
}}
380 \wxheading{Parameters
}
382 \docparam{viewName
}{The name of the view. e.g. PARTS_V
}
384 \docparam{colList
}{{\it OPTIONAL
} Pass in a comma delimited list of column names if you wish to explicitly name each column in the result set. If not desired, pass in an empty string.
}
386 \docparam{pSqlStmt
}{Pointer to the select statement portion of the CREATE VIEW statement. Must be a complete, valid SQL SELECT statement.
}
390 A 'view' is a logical table that derives columns from one or more other tables or views. Once the view is created, it can be queried exactly like any other table in the database.
392 NOTE: Views are not available with all datasources. Oracle is one example of a datasouce which does support views.
397 // Incomplete code sample
398 db.CreateView("PARTS_SD1", "PN, PD, QTY",
399 "SELECT PART_NO, PART_DESC, QTY_ON_HAND *
1.1 FROM PARTS \
400 WHERE STORAGE_DEVICE =
1");
402 // PARTS_SD1 can now be queried just as if it were a data table.
403 // e.g. SELECT PN, PD, QTY FROM PARTS_SD1
407 \membersection{wxDb::DispAllErrors
}\label{wxdbdispallerrors
}
409 \func{bool
}{DispAllErrors
}{\param{HENV
}{ aHenv
},
{\param}{HDBC
}{ aHdbc = SQL_NULL_HDBC
},
{\param}{HSTMT
}{ aHstmt = SQL_NULL_HSTMT
}}
411 Logs all database errors that occurred as a result of the last executed database command. This logging also includes debug logging when compiled in debug mode via
\helpref{wxLogDebug
}{wxlogdebug
}. If logging is turned on via
\helpref{wxDb::SetSqlLogging
}{wxdbsetsqllogging
}, then an entry is also logged to the defined log file.
413 \wxheading{Parameters
}
415 \docparam{aHenv
}{A handle to the ODBC environment.
}
417 \docparam{aHdbc
}{A handle to the ODBC connection. Pass this in if the ODBC function call that erred out required a hdbc or hstmt argument.
}
419 \docparam{AHstmt
}{A handle to the ODBC statement being executed against. Pass this in if the ODBC function call that erred out required a hstmt argument.
}
423 This member function will display all of the ODBC error messages for the last ODBC function call that was made. Normally used internally within the ODBC class library. Would be used externally if calling ODBC functions directly (i.e. SQLFreeEnv()).
427 \helpref{wxDb::SetSqlLogging
}{wxdbsetsqllogging
}, wxDbSqlLog
432 if (SQLExecDirect(hstmt, (UCHAR FAR *) pSqlStmt, SQL_NTS) != SQL_SUCCESS)
433 // Display all ODBC errors for this stmt
434 return(db.DispAllErrors(db.henv, db.hdbc, hstmt));
438 \membersection{wxDb::DispNextError
}\label{wxdbdispnexterror
}
440 \func{void
}{DispNextError
}{\void}
444 This function is normally used internally within the ODBC class library.
445 It could be used externally if calling ODBC functions directly. This
446 function works in conjunction with
\helpref{wxDb::GetNextError
}{wxdbgetnexterror
} when errors (or
447 sometimes informational messages) returned from ODBC need to be analyzed
448 rather than simply displaying them as an error. GetNextError() retrieves
449 the next ODBC error from the ODBC error queue. The wxDb member variables
450 "sqlState", "nativeError" and "errorMsg" could then be evaluated. To
451 display the error retrieved, DispNextError() could then be called.
452 The combination of GetNextError() and DispNextError() can be used to
453 iteratively step through the errors returned from ODBC evaluating each
454 one in context and displaying the ones you choose.
459 // Drop the table before attempting to create it
460 sprintf(sqlStmt, "DROP TABLE
%s", tableName);
461 // Execute the drop table statement
462 if (SQLExecDirect(hstmt,(UCHAR FAR *)sqlStmt,SQL_NTS) != SQL_SUCCESS)
464 // Check for sqlState = S0002, "Table or view not found".
465 // Ignore this error, bomb out on any other error.
466 pDb->GetNextError(henv, hdbc, hstmt);
467 if (strcmp(pDb->sqlState, "S0002"))
469 pDb->DispNextError(); // Displayed error retrieved
470 pDb->DispAllErrors(henv, hdbc, hstmt); // Display all other errors, if any
471 pDb->RollbackTrans(); // Rollback the transaction
472 CloseCursor(); // Close the cursor
473 return(FALSE); // Return Failure
479 \membersection{wxDb::DropView
}\label{wxdbdropview
}
481 \func{bool
}{DropView
}{\param{const char *
}{viewName
}}
483 Drops the data table view named in 'viewName'.
485 \wxheading{Parameters
}
487 \docparam{viewName
}{Name of the view to be dropped.
}
491 If the view does not exist, this function will return TRUE. Note that views are not supported with all data sources.
493 \membersection{wxDb::ExecSql
}\label{wxdbexecsql
}
495 \func{bool
}{ExecSql
}{\param{char *
}{pSqlStmt
}}
497 Allows a native SQL command to be executed directly against the datasource. In addition to being able to run any standard SQL command, use of this function allows a user to (potentially) utilize features specific to the datasource they are connected to that may not be available through ODBC. The ODBC driver will pass the specified command directly to the datasource.
499 \wxheading{Parameters
}
501 \docparam{pSqlStmt
}{Pointer to the SQL statement to be executed.
}
505 This member extends the wxDb class and allows you to build and execute ANY VALID
506 SQL statement against the data source. This allows you to extend the class
507 library by being able to issue any SQL statement that the data source is capable
512 \helpref{wxDb::GetData
}{wxdbgetdata
},
\helpref{wxDb::GetNext
}{wxdbgetnext
}
514 \membersection{wxDb::FwdOnlyCursors
}\label{wxdbfwdonlycursors
}
516 \func{bool
}{FwdOnlyCursors
}{\void}
518 Indicates whether this connection to the datasource only allows forward scrolling cursors or not. This state is set at connection creation time.
522 In wxWindows v2.4 release, this function will be deprecated to use a renamed version of the function called wxDb::IsFwdOnlyCursors() to match the normal wxWindows naming conventions for class member functions.
526 \helpref{wxDb::IsFwdOnlyCursors
}{wxdbisfwdonlycursors
},
\helpref{wxDb::wxDb
}{wxdbconstr
},
\helpref{wxDbGetConnection
}{wxdbfunctions
}
528 \membersection{wxDb::GetCatalog
}\label{wxdbgetcatalog
}
530 \func{wxDbInf *
}{GetCatalog
}{\param{char *
}{userID
}}
532 Returns a wxDbInf pointer that points to the catalog(data source) name, schema, number of tables accessible to the current user, and a wxDbTableInf pointer to all data pertaining to all tables in the users catalog.
534 \wxheading{Parameters
}
536 \docparam{userID
}{Owner of the table. Specify a userID when the datasource you are connected to allows multiple unique tables with the same name to be owned by different users.
{\it userID
} is evaluated as follows:
}
539 userID == NULL ... UserID is ignored (DEFAULT)
540 userID == "" ... UserID set equal to 'this->uid'
541 userID != "" ... UserID set equal to 'userID'
546 The returned catalog will only contain catalog entries for tables to which the user specified in 'userID' has sufficient privileges. If no user is specified (NULL passed in), a catalog pertaining to all tables in the datasource accessible via this connection will be returned.
548 \membersection{wxDb::GetColumnCount
}\label{wxdbgetcolumncount
}
550 \func{int
}{GetColumnCount
}{\param{char *
}{tableName
},
\param{const char *
}{userID
}}
552 \wxheading{Parameters
}
554 \docparam{tableName
}{A table name you wish to obtain column information about.
}
556 \docparam{userID
}{Name of the user that owns the table(s). Required for some datasources for situations where there may be multiple tables with the same name in the datasource, but owned by different users.
{\it userID
} is evaluated in the following manner:
}
559 userID == NULL ... UserID is ignored (DEFAULT)
560 userID == "" ... UserID set equal to 'this->uid'
561 userID != "" ... UserID set equal to 'userID'
564 \wxheading{Return value
}
566 Returns a count of how many columns are in the specified table. If an error occurs retrieving the number of columns the function will return a -
1.
568 \membersection{wxDb::GetColumns
}\label{wxdbgetcolumns
}
570 \func{wxDbColInf *
}{GetColumns
}{\param{char *
}{tableName
},
\param{int *
}{numCols
},
\param{const char *
}{userID=NULL
}}
572 \func{wxDbColInf *
}{GetColumns
}{\param{char *
}{tableName
[]},
\param{const char *
}{userID
}}
574 \wxheading{Parameters
}
576 \docparam{tableName
}{A table name you wish to obtain column information about.
}
577 \docparam{numCols
}{A pointer to a integer which will hold a count of the number of columns returned by this function
}
578 \docparam{tableName
[]}{An array of pointers to table names you wish to obtain column information about. The last element of this array must be a NULL string.
}
579 \docparam{userID
}{Name of the user that owns the table(s). Required for some datasources for situations where there may be multiple tables with the same name in the datasource, but owned by different users.
{\it userID
} is evaluated in the following manner:
}
582 userID == NULL ... UserID is ignored (DEFAULT)
583 userID == "" ... UserID set equal to 'this->uid'
584 userID != "" ... UserID set equal to 'userID'
587 \wxheading{Return value
}
589 This function returns an array of wxDbColInf structures. This allows you to obtain
590 information regarding the columns of your table(s). If no columns were found, or
591 an error occurred, this pointer will be zero (null).
593 THE CALLING FUNCTION IS RESPONSIBLE FOR DELETING THE
{\it wxDbColInf
} MEMORY WHEN IT IS
596 \normalbox{ALL column bindings associated with this wxDb instance are unbound
597 by this function. This function should use its own wxDb instance
598 to avoid undesired unbinding of columns.
}
602 \helpref{wxDbColInf
}{wxdbcolinf
}
607 char *tableList
[] =
{"PARTS",
0};
608 wxDbColInf *colInf = pDb->GetColumns(tableList);
611 // Use the column inf
613 // Destroy the memory
619 \membersection{wxDb::GetData
}\label{wxdbgetdata
}
621 \func{bool
}{GetData
}{\param{UWORD
}{ colNo
},
\param{SWORD
}{ cType
},
\param{PTR
}{ pData
},
\param{SDWORD
}{ maxLen
},
\param{SDWORD FAR *
}{ cbReturned
} }
623 Used to retrieve result set data without binding column values to memory variables (i.e. not using a wxDbTable instance to access table data).
625 \wxheading{Parameters
}
627 \docparam{colNo
}{Ordinal number of column in the result set to be returned.
}
628 \docparam{cType
}{The C data type that is to be returned.
}
629 \docparam{pData
}{Memory buffer which will hold the data returned by the call to this function.
}
630 \docparam{maxLen
}{Maximum size of the buffer that will hold the returned value.
}
631 \docparam{cbReturned
}{Pointer to the buffer containing the length of the actual data returned. If this value comes back as SQL_NULL_DATA, then the GetData() call has failed.
}
635 \helpref{wxDb::GetNext
}{wxdbgetnext
},
\helpref{wxDb::ExecSql
}{wxdbexecsql
}
643 sqlStmt = "SELECT SUM(REQUIRED_QTY - PICKED_QTY) FROM ORDER_TABLE WHERE \
644 PART_RECID =
1450 AND REQUIRED_QTY > PICKED_QTY";
647 if (!pDb->ExecSql(sqlStmt.c_str()))
653 // Request the first row of the result set
660 Read column
#1 of this row of the result set and store the value in 'reqQty'
661 if (!pDb->GetData(
1, SQL_C_ULONG, &reqQty,
0, &cb))
667 // Check for a NULL result
668 if (cb == SQL_NULL_DATA)
674 When requesting multiple columns to be returned from the result set (for example, the SQL query
675 requested
3 columns be returned), the calls to GetData must request the columns in ordinal
676 sequence (
1,
2,
3 or
1,
3 or
2,
3).
678 \membersection{wxDb::GetDatabaseName
}\label{wxdbgetdatabasename
}
680 \func{char *
}{GetDatabaseName
}{\void}
682 Returns the name of the database engine.
684 \membersection{wxDb::GetDataSource
}\label{wxdbgetdatasource
}
686 \func{char *
}{GetDataSource
}{\void}
688 Returns the ODBC datasource name.
690 \membersection{wxDb::GetHDBC
}\label{wxdbgethdbc
}
692 \func{HDBC
}{GetHDBC
}{\void}
694 Returns the ODBC handle to the database connection.
696 \membersection{wxDb::GetHENV
}\label{wxdbgethenv
}
698 \func{HENV
}{GetHENV
}{\void}
700 Returns the ODBC environment handle.
702 \membersection{wxDb::GetHSTMT
}\label{wxdbgethstmt
}
704 \func{HSTMT
}{GetHSTMT
}{\void}
706 Returns the ODBC statement handle associated with this database connection.
708 \membersection{wxDb::GetKeyFields
}\label{wxdbgetkeyfields
}
710 \func{int
}{GetKeyFields
}{\param{char *
}{tableName
},
\param{wxDbColInf *
}{colInf
},
\param{int
}{nocols
}}
712 Used to determine which columns are members of primary or non-primary indexes on the specified table. If a column is a member of a foreign key for some other table, that information is detected also.
714 This function is primarily for use by the
\helpref{wxDb::GetColumns
}{wxdbgetcolumns
} function, but may be called if desired from the client application.
716 \wxheading{Parameters
}
718 \docparam{tableName
}{Name of the table for which the columns will be evaluated as to their inclusion in any indexes.
}
719 \docparam{colInf
}{Data structure containing the column definitions (obtained with
\helpref{wxDb::GetColumns
}{wxdbgetcolumns
}). This function populates the PkCol, PkTableName, and FkTableName members of the colInf structure.
}
720 \docparam{nocols
}{Number of columns defined in the instance of colInf.
}
722 \wxheading{Return value
}
724 Currently always returns TRUE.
728 \helpref{wxDbColInf
}{wxdbcolinf
},
\helpref{wxDb::GetColumns
}{wxdbgetcolumns
}
730 \membersection{wxDb::GetNext
}\label{wxdbgetnext
}
732 \func{bool
}{GetNext
}{\void}
734 Requests the next row in the result set obtained by issueing a query through a direct request using wxDb::ExecSql().
738 \helpref{wxDb::ExecSql
}{wxdbexecsql
},
\helpref{wxDb::GetData
}{wxdbgetdata
}
740 \membersection{wxDb::GetNextError
}\label{wxdbgetnexterror
}
742 \func{bool
}{GetNextError
}{\param{HENV
}{ aHenv
},
\param{HDBC
}{ aHdbc = SQL_NULL_HDBC
},
\param{HSTMT
}{ aHstmt = SQL_NULL_HSTMT
}}
744 \wxheading{Parameters
}
746 \docparam{aHenv
}{A handle to the ODBC environment.
}
747 \docparam{aHdbc
}{A handle to the ODBC connection. Pass this in if the ODBC function call that
748 erred out required a hdbc or hstmt argument.
}
749 \docparam{AHstmt
}{A handle to the ODBC statement being executed against. Pass this in if the
750 ODBC function call that erred out requires a hstmt argument.
}
754 \helpref{wxDb::DispNextError
}{wxdbdispnexterror
},
\helpref{wxDb::DispAllErrors
}{wxdbdispallerrors
}
759 if (SQLExecDirect(hstmt, (UCHAR FAR *) pSqlStmt, SQL_NTS) != SQL_SUCCESS)
761 // Display all ODBC errors for this stmt
762 return(db.DispAllErrors(db.henv, db.hdbc, hstmt));
766 \membersection{wxDb::GetPassword
}\label{wxdbgetpassword
}
768 \func{char *
}{GetPassword
}{\void}
770 Returns the password used to connect to the datasource.
772 \membersection{wxDb::GetTableCount
}\label{wxdbgettablecount
}
774 \func{int
}{GetTableCount
}{\void}
776 Returns the number of wxDbTable() instances currently using this data source connection.
778 \membersection{wxDb::GetUsername
}\label{wxdbgetusername
}
780 \func{char *
}{GetUsername
}{\void}
782 Returns the user name used to access the datasource.
784 \membersection{wxDb::Grant
}\label{wxdbgrant
}
786 \func{bool
}{Grant
}{\param{int
}{ privileges
},
\param{char *
}{tableName
},
\param{char *
}{userList = "PUBLIC"
}}
788 Use this member function to GRANT privileges to users for accessing tables in the datasource.
790 \wxheading{Parameters
}
792 \docparam{privileges
}{Use this argument to select which privileges you want to grant. Pass DB_GRANT_ALL to grant all privileges. To grant individual privileges pass one or more of the following OR'd together:
}
798 DB_GRANT_ALL = DB_GRANT_SELECT | DB_GRANT_INSERT |
799 DB_GRANT_UPDATE | DB_GRANT_DELETE
801 \docparam{tableName
}{The name of the table you wish to grant privileges on.
}
802 \docparam{userList
}{A comma delimited list of users to grant the privileges to. If this argument is not passed in, the privileges will be given to the general PUBLIC.
}
806 Some databases require user names to be specified in all capital letters (i.e. Oracle). This function does not automatically capitalize the user names passed in the comma-separated list. This is the responsibility of the calling routine.
811 db.Grant(DB_GRANT_SELECT | DB_GRANT_INSERT, "PARTS", "mary, sue");
815 \membersection{wxDb::IsFwdOnlyCursors
}\label{wxdbisfwdonlycursors
}
817 \func{bool
}{IsFwdOnlyCursors
}{\void}
819 Indicates whether this connection to the datasource only allows forward scrolling cursors or not. This state is set at connection creation time.
823 Added as of wxWindows v2.4 release, this function is a renamed version of wxDb::FwdOnlyCursors() to match the normal wxWindows naming conventions for class member functions.
825 This function is not available in versions prior to v2.4. You should use
\helpref{wxDb::FwdOnlyCursors
}{wxdbfwdonlycursors
} for wxWindows versions priori to
2.4.
829 \helpref{wxDb::wxDb
}{wxdbconstr
},
\helpref{wxDbGetConnection
}{wxdbfunctions
}
831 \membersection{wxDb::IsOpen
}\label{wxdbisopen
}
833 \func{bool
}{IsOpen
}{\void}
835 Indicates whether the database connection to the datasource is currently opened.
837 \membersection{wxDb::Open
}\label{wxdbopen
}
839 \func{bool
}{Open
}{\param{char *
}{Dsn
},
\param{char *
}{Uid
},
\param{char *
}{AuthStr
}}
841 \wxheading{Parameters
}
843 \docparam{Dsn
}{Data source name. The name of the ODBC data source as
844 assigned when the data source is initially set up through the ODBC data
846 \docparam{Uid
}{User ID. The name (ID) of the user you wish to connect as
847 to the data source. The user name (ID) determines what objects you
848 have access to in the datasource and what datasource privileges you have.
849 Privileges include being able to create new objects, update objects, delete
850 objects and so on. Users and privileges are normally administered by the
851 database administrator.
}
852 \docparam{AuthStr
}{The password associated witht the Uid.
}
856 After a wxDb instance is created, it must then be opened. When opening a data source, there must be hree pieces of information passed. The data source name, user name (ID) and the password for the user. No database activity on the data source can be performed until it is opened. This would normally be done at program startup and the data source would remain open for the duration of the program run. Note: It is possible to have multiple data sources open at the same time to support distributed database connections.
861 wxDb sampleDB(Db.Henv);
862 if (!sampleDB.Open("Oracle
7.1 HP/UX", "gtasker", "myPassword"))
864 // Error opening data source
869 \membersection{wxDb::RollbackTrans
}\label{wxdbrollbacktrans
}
871 \func{bool
}{RollbackTrans
}{\void}
873 Function to "rollback" changes made to the database. After an insert/update/delete, the operation may be "undone" by issuing this command any time before a
\helpref{wxDb::CommitTrans
}{wxdbcommittrans
} is called on the database connection.
877 Transactions begin implicitly as soon as you make a change to the database. At any time thereafter, you can save your work to the database (using
\helpref{wxDb::CommitTrans
}{wxdbcommittrans
}) or undo all of your changes using this function.
879 \normalbox{Calling this member function rolls back ALL open (uncommitted) transactions on this ODBC connection.
}
883 \helpref{wxDb::CommitTrans
}{wxdbcommittrans
} for a special note on cursors
885 \membersection{wxDb::SetSqlLogging
}\label{wxdbsetsqllogging
}
887 \func{bool
}{SetSqlLogging
}{\param{wxDbSqlLogState
}{ state
},
\param{const wxChar *
}{filename = SQL_LOG_FILENAME
},
\param{bool
}{ append = FALSE
}}
889 \wxheading{Parameters
}
891 \docparam{state
}{Either sqlLogOFF or sqlLogON (see
\helpref{enum wxDbSqlLogState
}{wxdbcolfor
}). Turns logging of SQL commands sent to the data source OFF or ON.
}
892 \docparam{filename
}{{\it OPTIONAL
}. Name of the file to which the log text is to be written.
}
893 \docparam{append
}{{\it OPTIONAL
}. Whether the file is appended to or overwritten.
}
897 When called with
{\it sqlLogON
}, all commands sent to the data source engine are logged to the file specified by
{\it filename
}. Logging is done by embedded WriteSqlLog() calls in the database member functions, or may be manually logged by adding calls to WriteSqlLog() in your own source code.
899 When called with
{\it sqlLogOFF
}, the logging file is closed, and any calls to WriteSqlLog() are ignored.
901 \membersection{wxDb::TableExists
}\label{wxdbtablexists
}
903 \func{bool
}{TableExists
}{\param{const char *
}{tableName
},
\param{const char *
}{userID=NULL
},
\param{const char *
}{path=NULL
}}
905 Checks the ODBC data source for the existence of a table. If a
{\it userID
} is specified, then the table must be accessible by that user (user must have at least minimal privileges to the table).
907 \wxheading{Parameters
}
909 \docparam{tableName
}{Name of the table to check for the existence of
}
910 \docparam{userID
}{Owner of the table. Specify a userID when the datasource you are connected
911 to allows multiple unique tables with the same name to be owned by different users.
{\it userID
}
912 is evaluated as follows:
}
915 userID == NULL ... UserID is ignored (DEFAULT)
916 userID == "" ... UserID set equal to 'this->uid'
917 userID != "" ... UserID set equal to 'userID'
922 {\it tableName
} may refer to a table, view, alias or synonym.
924 This function does not indicate whether or not the user has privileges to query or perform other functions on the table.
926 \membersection{wxDb::TranslateSqlState
}\label{wxdbtranslatesqlstate
}
928 \func{int
}{TranslateSqlState
}{\param{const wxChar *
}{SQLState
}}
930 \wxheading{Parameters
}
932 \docparam{SQLState
}{Converts an ODBC sqlstate to an internal error code.
}
934 \wxheading{Return value
}
936 Returns the internal class DB_ERR code. See
\helpref{wxDb::DB_STATUS
}{wxdb
} definition.
938 \membersection{wxDb::WriteSqlLog
}\label{wxdbwritesqllog
}
940 \func{bool
}{WriteSqlLog
}{\param{const wxChar *
}{logMsg
}}
942 \wxheading{Parameters
}
944 \docparam{logMsg
}{Free form string to be written to the log file.
}
948 Very useful debugging tool that may be turned on/off during run time. The
949 passed in string
{\it logMsg
} will be written to a log file if SQL logging
950 is turned on (see
\helpref{wxDb::SetSqlLogging
}{wxdbsetsqllogging
} for details on turning logging on/off).
952 \wxheading{Return value
}
954 If SQL logging is off when a call to WriteSqlLog() is made, or there is a
955 failure to write the log message to the log file, the function returns
956 FALSE without performing the requested log, otherwise TRUE is returned.
960 \helpref{wxDb::SetSqlLogging
}{wxdbsetsqllogging
}
962 \begin{comment
} % George: this is a duplicate of one above (only with more text)
963 \membersection{wxDb::IsFwdOnlyCursors
}\label{wxdbisfwdonlycursors
}
965 \func{bool
}{IsFwdOnlyCursors
}{\void}
969 This setting indicates whether this database connection was created
970 as being capable of using only forward scrolling cursors. This function
971 does NOT indicate if the ODBC driver or datasource supports backward
972 scrolling cursors. There is no standard way of detecting if the driver
973 or datasource can support backward scrolling cursors.
975 If a wxDb instance was created as being forward only cursors, then even if
976 the datasource and ODBC driver support backward scrolling cursors, then
977 tables using this database connection can only use forward scrolling
980 The default setting of whether a wxDb connection to a database allows
981 forward-only or also backward scrolling cursors is defined in setup.h by
982 the wxODBC_FWD_ONLY_CURSORS value. This default setting can be overridden
983 when the wxDb connection is initially created (see
\helpref{wxDb constructor
}{wxdbconstr
}).
985 \wxheading{Return value
}
987 Returns TRUE if this datasource connection is defined as using only forward
988 scrolling cursors, or FALSE if the connection is defined as being capable
989 of supporting backward scrolling cursors (see note above).
993 \helpref{wxDb constructor
}{wxdbconstr
}
996 \membersection{wxDb::Dbms
}\label{wxdbdbms
}
998 \func{wxDBMS
}{Dbms
}{\void}
1002 The return value will be of the enumerated type wxDBMS. This enumerated
1003 type contains a list of all the currently tested and supported databases.
1005 Additional databases may be work with these classes, but these databases
1006 returned by this function have been tested and confirmed to work with
1009 enum wxDBMS includes:
1023 There are known issues with conformance to the ODBC standards with several
1024 datasources listed above. Please see the overview for specific details on
1025 which datasource have which issues.
1027 \wxheading{Return value
}
1029 The return value will indicate which of the supported datasources is
1030 currently connected to by this connection. In the event that the
1031 datasource is not recognized, a value of 'dbmsUNIDENTIFIED' is returned.
1033 \membersection{wxDb::SetDebugErrorMessages
}\label{wxdbsetdebugerrormessages
}
1035 \func{void
}{SetDebugErrorMessages
}{\param{bool
}{state
}}
1037 \docparam{state
}{Either TRUE (debug messages are displayed) or FALSE (debug
1038 messages are not displayed.
}
1042 Turns on/off debug error messages from the ODBC class library. When
1043 this function is passed TRUE, errors are reported to the user automatically
1044 in a text or pop-up dialog when an ODBC error occurs. When passed FALSE,
1045 errors are silently handled.
1047 When compiled in release mode (FINAL=
1), this setting has no affect.
1049 \wxheading{See also
}
1051 \helpref{wxDb constructor
}{wxdbconstr
}
1053 \membersection{wxDb::LogError
}\label{wxdblogerror
}
1055 \func{void
}{LogError
}{\param{const char *
}{errMsg
} \param{const char *
}{SQLState=
0}}
1057 \docparam{errMsg
}{Free-form text to display describing the error to be logged.
}
1058 \docparam{SQLState
}{Native SQL state error
}
1062 Calling this function will enter a log message in the error list maintained
1063 for the database connection. This log message is free form and can be
1064 anything the programmer wants to enter in the error list.
1066 If SQL logging is turned on, the call to this function will also log the
1067 text into the SQL log file.
1069 \wxheading{See also
}
1071 \helpref{wxDb::WriteSqlLog
}{wxdbwritesqllog
}
1073 \section{\class{wxDbColInf
}}\label{wxdbcolinf
}
1075 Used with the
\helpref{wxDb::GetColumns
}{wxdbgetcolumns
} functions for obtaining all retrievable information about a columns definition.
1077 \section{\class{wxDbColFor
}}\label{wxdbcolfor
}
1079 Beginning support for handling international formatting specifically on dates and floats.
1081 Only one function is provided with this class currently:
1083 \membersection{wxDbColFor::Format
}\label{wxdbcolforformat
}
1085 \func{int
}{Format
}{\param{int
}{Nation
},
\param{int
}{dbDataType
},
\param{SWORD
}{sqlDataType
},
\param{short
}{columnSize
},
\param{short
}{decimalDigits
}}\label{wxdbcolforformat
}
1087 Work in progress, and should be inter-related with wxLocale
1089 \section{\class{wxDbInf
}}\label{wxdbinf
}
1091 Contains information regarding the database connection (data source name,
1092 number of tables, etc). A pointer to a wxDbTableInf is included in this
1093 class so a program can create a wxDbTableInf array instance to maintain all
1094 information about all tables in the datasource to have all the datasource's
1095 information in one memory structure.
1097 \section{\class{wxDbTable
}}\label{wxdbtable
}
1099 A wxDbTable instance provides re-usable access to rows of data in
1100 a table contained within the associated ODBC data source
1102 \wxheading{Include files
}
1107 \latexignore{\rtfignore{\wxheading{Members
}}}
1108 \wxheading{Helper classes and data structures
}
1110 The following classes and structs are defined in dbtable.cpp/.h for use with the wxDbTable class.
1113 class wxDbColDef : Bound column definitions for use by a wxDbTable
1116 class wxDbColDataPtr : Pointer to dynamic column definitions for use with
1117 a wxDbTable instance
1119 class wxDbIdxDef : Used in creation of non-primary indexes
1123 \wxheading{Constants
}
1125 wxDB_DEFAULT_CURSOR Index number of the cursor that each table will use
1128 wxDB_QUERY_ONLY Used to indicate whether a table that is opened is
1129 for query only, or if insert/update/deletes will
1130 be performed on the table. Less overhead (cursors
1131 and memory) are allocated for query only tables, plus
1132 read access times are faster with some datasources.
1134 wxDB_ROWID_LEN
[Oracle specific
] - Used when CanUpdateByRowID() is
1135 true. Optimizes updates so they are faster by
1136 updating on the Oracle-specific ROWID column rather
1137 than some other index.
1140 wxDB_DISABLE_VIEW Use to indicate when a database view should not be
1141 if a table is normally set up to use a view.
1142 [Currently unsupported.
]
1148 \wxheading{See also
}
1150 \helpref{wxDbTable
}{wxdbtable
}
1152 \latexignore{\rtfignore{\wxheading{Members
}}}
1154 \membersection{wxDbTable::wxDbTable
}\label{wxdbtableconstr
}
1156 \func{}{wxDbTable
}{\param{wxDb *
}{pwxDb
},
\param{const char *
}{tblName
},
\param{const int
}{nCols
},
\param{const char *
}{qryTblName =
0},
\param{bool
}{qryOnly = !wxDB_QUERY_ONLY
},
\param{const char *
}{tblPath=NULL
}}
1158 Default constructor.
1160 \wxheading{Parameters
}
1162 \docparam{pSqlStmt
}{}
1163 \docparam{typeOfDel
}{}
1164 \docparam{pWhereClause
}{Default is
0.
}
1167 \membersection{wxDbTable::wxDbTable
}\label{wxdbtabledestr
}
1169 \func{virtual
}{\destruct{wxDbTable
}}{}
1171 Virtual default destructor.
1174 \membersection{wxDbTable::BuildDeleteStmt
}\label{wxdbtablebuilddeletestmt
}
1176 \func{void
}{BuildSelectStmt
}{\param{char *
}{pSqlStmt
},
\param{int
}{typeOfDel
},
\param{const char *
}{pWhereClause=
0}}
1178 \wxheading{Parameters
}
1180 \docparam{pSqlStmt
}{}
1181 \docparam{typeOfDel
}{}
1182 \docparam{pWhereClause
}{Default is
0.
}
1185 \membersection{wxDbTable::BuildSelectStmt
}\label{wxdbtablebuildselectstmt
}
1187 \func{void
}{BuildSelectStmt
}{\param{char *
}{pSqlStmt
},
\param{int
}{typeOfSelect
},
\param{bool
}{distinct
}}
1189 \wxheading{Parameters
}
1191 \docparam{pSqlStmt
}{}
1192 \docparam{typeOfSelect
}{}
1193 \docparam{distinct
}{}
1196 \membersection{wxDbTable::BuildUpdateStmt
}\label{wxdbtablebuildupdatestmt
}
1198 \func{void
}{BuildSelectStmt
}{\param{char *
}{pSqlStmt
},
\param{int
}{typeOfUpd
},
\param{const char *
}{pWhereClause=
0}}
1200 \wxheading{Parameters
}
1202 \docparam{pSqlStmt
}{}
1203 \docparam{typeOfUpd
}{}
1204 \docparam{pWhereClause
}{Default is
0.
}
1207 \membersection{wxDbTable::BuildWhereStmt
}\label{wxdbtablebuildwherestmt
}
1209 \func{void
}{BuildSelectStmt
}{\param{char *
}{pWhereClause
},
\param{int
}{typeOfWhere
},
\param{const char *
}{qualTableName=
0},
\param{const char *
}{useLikeComparison=FALSE
}}
1211 \wxheading{Parameters
}
1213 \docparam{pWhereClause
}{}
1214 \docparam{typeOfWhere
}{}
1215 \docparam{qualTableName
}{Default is
0.
}
1216 \docparam{useLikeComparison
}{Default is FALSE.
}
1219 \membersection{wxDbTable::CanSelectForUpdate
}\label{wxdbtablecanselectforupdate
}
1221 \func{bool
}{CanSelectForUpdate
}{\void}
1226 \membersection{wxDbTable::CanUpdateByROWID
}\label{wxdbtablecanupdatebyrowid
}
1228 \func{bool
}{CanUpdateByROWID
}{\void}
1233 \membersection{wxDbTable::ClearMemberVars
}\label{wxdbtableclearmembervars
}
1235 \func{void
}{ClearMemberVars
}{\void}
1240 \membersection{wxDbTable::CloseCursor
}\label{wxdbtableclosecursor
}
1242 \func{bool
}{CloseCursor
}{\param{HSTMT
}{cursor
}}
1244 \wxheading{Parameters
}
1251 \membersection{wxDbTable::Count
}\label{wxdbtablecount
}
1253 \func{ULONG
}{Count
}{\param{const char *
}{args="*"
}}
1255 \wxheading{Parameters
}
1257 \docparam{args
}{Default is "*".
}
1262 \membersection{wxDbTable::CreateIndex
}\label{wxdbtablecreateindex
}
1264 \func{bool
}{CreateIndex
}{\param{const char *
}{idxName
},
\param{bool
}{unique
},
\param{int
}{noIdxCols
},
\param{wxDbIdxDef *
}{pIdxDefs
},
\param{bool
}{attemptDrop=TRUE
}}
1266 \wxheading{Parameters
}
1268 \docparam{idxName
}{}
1270 \docparam{noIdxCols
}{}
1271 \docparam{pIdxDefs
}{}
1272 \docparam{attemptDrop
}{Default is TRUE.
}
1276 \membersection{wxDbTable::CreateTable
}\label{wxdbtablecreatetable
}
1278 \func{bool
}{CreateTable
}{\param{bool
}{attemptDrop=TRUE
}}
1280 \wxheading{Parameters
}
1282 \docparam{attemptDrop
}{Default is TRUE.
}
1286 \membersection{wxDbTable::DB_STATUS
}\label{wxdbtabledbstatus
}
1288 \func{bool
}{DB_STATUS
}{\void}
1290 Accessor function for the private member variable DB_STATUS.
1292 \membersection{wxDbTable::IsColNull
}\label{wxdbtableiscolnull
}
1294 \func{bool
}{IsColNull
}{\param{int
}{colNo
}}
1296 \wxheading{Parameters
}
1302 \membersection{wxDbTable::Delete
}\label{wxdbtabledelete
}
1304 \func{bool
}{Delete
}{\void}
1308 \membersection{wxDbTable::DeleteCursor
}\label{wxdbtabledeletecursor
}
1310 \func{bool
}{DeleteCursor
}{\param{HSTMT
}{hstmtDel
}}
1312 \wxheading{Parameters
}
1314 \docparam{hstmtDel
}{}
1318 \membersection{wxDbTable::DeleteWhere
}\label{wxdbtabledeletewhere
}
1320 \func{bool
}{DeleteWhere
}{\param{const char *
}{pWhereClause
}}
1322 \wxheading{Parameters
}
1324 \docparam{pWhereClause
}{}
1328 \membersection{wxDbTable::DeleteMatching
}\label{wxdbtabledeletematching
}
1330 \func{bool
}{DeleteMatching
}{\void}
1334 \membersection{wxDbTable::DropIndex
}\label{wxdbtabledropindex
}
1336 \func{bool
}{DropIndex
}{\param{const char *
}{idxName
}}
1338 \wxheading{Parameters
}
1340 \docparam{idxName
}{}
1344 \membersection{wxDbTable::DropTable
}\label{wxdbtabledroptable
}
1346 \func{bool
}{DropTable
}{\void}
1350 \membersection{wxDbTable::GetColDefs
}\label{wxdbtablegetcoldefs
}
1352 \func{wxDbColDef *
}{GetColDefs
}{}
1356 \membersection{wxDbTable::GetCursor
}\label{wxdbtablegetcursor
}
1358 \func{HSTMT
}{GetCursor
}{\void}
1362 \membersection{wxDbTable::GetDb
}\label{wxdbtablegetdb
}
1364 \func{wxDb *
}{GetDb
}{}
1366 Accessor function for the private member variable pDb which is a pointer to the datasource connection that this wxDbTable instance uses.
1370 \membersection{wxDbTable::GetFirst
}\label{wxdbtablegetfirst
}
1372 \func{bool
}{GetFirst
}{\void}
1376 This function can only be used if the datasource connection used by the wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the connection does not allow backward scrolling cursors, this function will return FALSE, and the data contained in the bound columns will be undefined.
1378 \wxheading{See also
}
1380 \helpref{wxDb::FwdOnlyCursors
}{wxdbfwdonlycursors
}
1382 \membersection{wxDbTable::GetFromClause
}\label{wxdbtablegetfromclause
}
1384 \func{const char *
}{GetFromClause
}{}
1386 Accessor function that returns the current FROM setting assigned with the
\helpref{wxDbTable::SetFromClause
}{wxdbtablesetfromclause
}.
1388 \membersection{wxDbTable::GetLast
}\label{wxdbtablegetlast
}
1390 \func{bool
}{GetLast
}{\void}
1394 This function can only be used if the datasource connection used by the wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the connection does not allow backward scrolling cursors, this function will return FALSE, and the data contained in the bound columns will be undefined.
1396 \wxheading{See also
}
1398 \helpref{wxDb::FwdOnlyCursors
}{wxdbfwdonlycursors
}
1400 \membersection{wxDbTable::GetNewCursor
}\label{wxdbtablegetnewcursor
}
1402 \func{HSTMT *
}{GetNewCursor
}{\param{bool
}{setCursor=FALSE
},
\param{bool
}{bindColumns=TRUE
}}
1404 \wxheading{Parameters
}
1406 \docparam{setCursor
}{Default is FALSE.
}
1407 \docparam{bindColumns
}{Default is TRUE.
}
1411 \membersection{wxDbTable::GetNext
}\label{wxdbtablegetnext
}
1413 \func{bool
}{GetNext
}{\void}
1418 \membersection{wxDbTable::GetNumberOfColumns
}\label{wxdbtablegetnumberofcolumns
}
1420 \func{bool
}{GetNumberOfColumns
}{}
1422 Accessor function that returns the number of columns that are statically bound for access by the wxDbTable instance.
1424 \membersection{wxDbTable::GetOrderByClause
}\label{wxdbtablegetorderbyclause
}
1426 \func{const char *
}{GetOrderByClause
}{}
1428 Accessor function that returns the current ORDER BY setting assigned with the
\helpref{wxDbTable::SetOrderByClause
}{wxdbtablesetorderbyclause
}.
1430 \membersection{wxDbTable::GetPrev
}\label{wxdbtablegetprev
}
1432 \func{bool
}{GetPrev
}{\void}
1436 This function can only be used if the datasource connection used by the wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the connection does not allow backward scrolling cursors, this function will return FALSE, and the data contained in the bound columns will be undefined.
1438 \wxheading{See also
}
1440 \helpref{wxDb::FwdOnlyCursors
}{wxdbfwdonlycursors
}
1443 \membersection{wxDbTable::GetQueryTableName
}\label{wxdbtablegetquerytablename
}
1445 \func{const char *
}{GetQueryTableName
}{}
1449 \membersection{wxDbTable::GetRowNum
}\label{wxdbtablegetrownum
}
1451 \func{UWORD
}{GetRowNum
}{\void}
1455 \membersection{wxDbTable::GetTableName
}\label{wxdbtablegettablename
}
1457 \func{const char *
}{GetTableName
}{}
1461 \membersection{wxDbTable::GetTablePath
}\label{wxdbtablegettablepath
}
1463 \func{const char *
}{GetTablePath
}{}
1467 \membersection{wxDbTable::GetWhereClause
}\label{wxdbtablegetwhereclause
}
1469 \func{const char *
}{GetWhereClause
}{}
1471 Accessor function that returns the current WHERE setting assigned with the
\helpref{wxDbTable::SetWhereClause
}{wxdbtablesetwhereclause
}
1473 \membersection{wxDbTable::Insert
}\label{wxdbtableinsert
}
1475 \func{int
}{Insert
}{\void}
1479 \membersection{wxDbTable::IsCursorClosedOnCommit
}\label{wxdbtableiscursorclosedoncommit
}
1481 \func{bool
}{IsCursorClosedOnCommit
}{\void}
1485 \membersection{wxDbTable::IsQueryOnly
}\label{wxdbtableisqueryonly
}
1487 \func{bool
}{IsQueryOnly
}{}
1489 Accessor function that returns a value indicating if this wxDbTable instance was created to allow only queries to be performed on the bound columns. If this function returns TRUE, then no actions may be performed using this wxDbTable instance that would modify (insert/delete/update) the table's data.
1491 \membersection{wxDbTable::Open
}\label{wxdbtableopen
}
1493 \func{bool
}{Open
}{\void}
1497 \membersection{wxDbTable::Query
}\label{wxdbtablequery
}
1499 \func{virtual bool
}{Query
}{\param{bool
}{forUpdate=FALSE
},
\param{bool
}{distinct=FALSE
}}
1501 \wxheading{Parameters
}
1503 \docparam{forUpdate
}{Default is FALSE.
}
1504 \docparam{distinct
}{Default is FALSE.
}
1508 \membersection{wxDbTable::QueryBySqlStmt
}\label{wxdbtablequerybysqlstmt
}
1510 \func{bool
}{QueryBySqlStmt
}{\param{const char *
}{pSqlStmt
}}
1512 \wxheading{Parameters
}
1514 \docparam{pSqlStmt
}{}
1518 \membersection{wxDbTable::QueryMatching
}\label{wxdbtablequerymatching
}
1520 \func{virtual bool
}{QueryMatching
}{\param{bool
}{forUpdate=FALSE
},
\param{bool
}{distinct=FALSE
}}
1522 \wxheading{Parameters
}
1524 \docparam{forUpdate
}{Default is FALSE.
}
1525 \docparam{distinct
}{Default is FALSE.
}
1529 \membersection{wxDbTable::QueryOnKeyFields
}\label{wxdbtablequeryonkeyfields
}
1531 \func{bool
}{QueryOnKeyFields
}{\param{bool
}{forUpdate=FALSE
},
\param{bool
}{distinct=FALSE
}}
1533 \wxheading{Parameters
}
1535 \docparam{forUpdate
}{Default is FALSE.
}
1536 \docparam{distinct
}{Default is FALSE.
}
1540 \membersection{wxDbTable::Refresh
}\label{wxdbtablerefresh
}
1542 \func{bool
}{Refresh
}{\void}
1546 \membersection{wxDbTable::SetColDefs
}\label{wxdbtablesetcoldefs
}
1548 \func{void
}{SetColDefs
}{\param{int
}{index
},
\param{const char *
}{fieldName
},
\param{int
}{dataType
},
\param{void *
}{pData
},
\param{int
}{cType
},
\param{int
}{size
},
\param{bool
}{keyField = FALSE
},
\param{bool
}{upd = TRUE
},
\param{bool
}{insAllow = TRUE
},
\param{bool
}{derivedCol = FALSE
}}
1550 \func{wxDbColDataPtr *
}{SetColDefs
}{\param{wxDbColInf *
}{colInfs
},
\param{ULONG
}{numCols
}}
1552 \wxheading{Parameters
}
1555 \docparam{fieldName
}{}
1556 \docparam{dataType
}{}
1560 \docparam{keyField
}{Default is FALSE.
}
1561 \docparam{upd
}{Default is TRUE.
}
1562 \docparam{insAllow
}{Default is TRUE.
}
1563 \docparam{derivedCol
}{Default is FALSE.
}
1565 \docparam{colInfs
}{}
1566 \docparam{numCols
}{}
1570 \membersection{wxDbTable::SetCursor
}\label{wxdbtablesetcursor
}
1572 \func{bool
}{Open
}{\param{HSTMT *
}{hstmtActivate = (void **) wxDB_DEFAULT_CURSOR
}}
1574 \wxheading{Parameters
}
1576 \docparam{hstmtActivate
}{Default is wxDB_DEFAULT_CURSOR.
}
1580 \membersection{wxDbTable::SetFromClause
}\label{wxdbtablesetfromclause
}
1582 \func{void
}{SetFromClause
}{\param{const wxString&
}{From
}}
1584 \wxheading{Parameters
}
1588 \membersection{wxDbTable::SetNull
}\label{wxdbtablesetnull
}
1590 \func{bool
}{SetNull
}{\param{int
}{colNo
}}
1592 \func{bool
}{SetNull
}{\param{const char *
}{colName
}}
1594 \wxheading{Parameters
}
1597 \docparam{colName
}{}
1601 \membersection{wxDbTable::SetOrderByClause
}\label{wxdbtablesetorderbyclause
}
1603 \func{void
}{SetOrderByClause
}{\param{const wxString&
}{OrderBy
}}
1605 \wxheading{Parameters
}
1607 \docparam{OrderBy
}{}
1609 \membersection{wxDbTable::SetQueryTimeout
}\label{wxdbtablesetquerytimeout
}
1611 \func{bool
}{SetQueryTimeout
}{\param{UDWORD
}{nSeconds
}}
1613 \wxheading{Parameters
}
1615 \docparam{nSeconds
}{}
1619 \membersection{wxDbTable::SetWhereClause
}\label{wxdbtablesetwhereclause
}
1621 \func{void
}{SetWhereClause
}{\param{const wxString&
}{Where
}}
1623 \wxheading{Parameters
}
1627 \membersection{wxDbTable::Update
}\label{wxdbtableupdate
}
1629 \func{bool
}{Update
}{\void}
1631 \func{bool
}{Update
}{\param{const char *
}{pSqlStmt
}}
1633 \wxheading{Parameters
}
1635 \docparam{pSqlStmt
}{}
1639 \membersection{wxDbTable::UpdateWhere
}\label{wxdbtableupdatewhere
}
1641 \func{bool
}{UpdateWhere
}{\param{const char *
}{pWhereClause
}}
1643 \wxheading{Parameters
}
1645 \docparam{pWhereClause
}{}
1649 \membersection{wxDbTable::operator $++$
}\label{wxdbtableplusplus
}
1651 \func{bool
}{operator $++$
}{\void}
1653 Same as
\helpref{wxDbTable::GetNext
}{wxdbtablegetnext
}
1655 \wxheading{See also
}
1657 \helpref{wxDbTable::GetNext
}{wxdbtablegetnext
}
1659 \membersection{wxDbTable::operator $--$
}\label{wxdbtableminusminus
}
1661 \func{bool
}{operator $--$
}{\void}
1663 Same as
\helpref{wxDbTable::GetPrev
}{wxdbtablegetprev
}
1665 \wxheading{See also
}
1667 \helpref{wxDbTable::GetPrev
}{wxdbtablegetprev
}
1669 \section{\class{wxDbTableInf
}}\label{wxdbtableinf
}
1671 Currently only used by wxDb::GetCatalog() internally and wxDbInf class,
1672 but may be used in future releases for user functions. Contains information
1673 describing the table (Name, type, etc). A pointer to a wxDbColInf array
1674 instance is included so a program can create a wxDbColInf array instance
1675 (using
\helpref{wxDb::GetColumns
}{wxdbgetcolumns
}) to maintain all information about the columns
1676 of a table in one memory structure.