]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/db.tex
Lots more memory/resource leak fixes. There are still more, but this solves about...
[wxWidgets.git] / docs / latex / wx / db.tex
CommitLineData
3ca6a5f0 1\section{\class{wxDb}}\label{wxdb}
f6bcfd97 2
3ca6a5f0 3A wxDb instance is a connection to an ODBC data source which may
f6bcfd97
BP
4be opened, closed, and re-opened an unlimited number of times. A
5database connection allows function to be performed directly on the
6data source, as well as allowing access to any tables/views defined in
7the data source to which the user has sufficient privileges.
8
9\wxheading{Include files}
10
f6bcfd97
BP
11<wx/db.h>
12
d0c6b305
GT
13\wxheading{Helper classes and data structures}
14
15The following classes and structs are defined in db.cpp/.h for use with the wxDb class.
16
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}
22\end{itemize}
23
24\wxheading{Constants}
25
26NOTE: In a future release, all ODBC class constants will be prefaced with 'wx'
27
28\begin{verbatim}
29
30 wxDB_PATH_MAX Maximum path length allowed to be passed to the ODBC
31 driver to indicate where the data file is located.
32
33 DB_MAX_COLUMN_NAME_LEN Maximum supported length for the name of a column
34
35 DB_MAX_ERROR_HISTORY Maximum number of error messages retained in the
36 queue before being overwritten by new errors.
37
38 DB_MAX_ERROR_MSG_LEN Maximum supported length of an error message returned
39 by the ODBC classes
40
41 DB_MAX_STATEMENT_LEN Maximum supported length for a complete SQL statement
42 to be passed to the ODBC driver
43
44 DB_MAX_TABLE_NAME_LEN Maximum supported length for the name of a table
45
46 DB_MAX_WHERE_CLAUSE_LEN Maximum supported WHERE clause length that can be
47 passed to the ODBC driver
48
49 DB_TYPE_NAME_LEN Maximum length of the name of a column's data type
50\end{verbatim}
51
52
3ca6a5f0
BP
53\wxheading{Enumerated types}
54
d0c6b305 55\docparam{enum {\bf wxDbSqlLogState}}{sqlLogOFF, sqlLogON}
3ca6a5f0
BP
56
57{\it enum {\bf wxDBMS}}
58
d0c6b305 59These 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.
3ca6a5f0
BP
60
61\begin{verbatim}
eea22fd5
GT
62 dbmsUNIDENTIFIED
63 dbmsORACLE
64 dbmsSYBASE_ASA // Adaptive Server Anywhere
65 dbmsSYBASE_ASE // Adaptive Server Enterprise
66 dbmsMS_SQL_SERVER
67 dbmsMY_SQL
68 dbmsPOSTGRES
69 dbmsACCESS
70 dbmsDBASE
3ca6a5f0 71 dbmsINFORMIX
eea22fd5
GT
72 dbmsVIRTUOSO
73 dbmsDB2
3ca6a5f0
BP
74\end{verbatim}
75
d0c6b305 76See the remarks in \helpref{wxDb::Dbms}{wxdbdbms} for exceptions/issues with each of these database engines.
3ca6a5f0
BP
77
78\wxheading{Public member variables}
79
d0c6b305 80\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.}
3ca6a5f0 81
d0c6b305 82\docparam{int {\bf wxDb::DB\_STATUS}}{The last ODBC error that occurred on this data connection. Possible codes are:}
3ca6a5f0
BP
83
84\begin{verbatim}
85 DB_ERR_GENERAL_WARNING // SqlState = '01000'
86 DB_ERR_DISCONNECT_ERROR // SqlState = '01002'
87 DB_ERR_DATA_TRUNCATED // SqlState = '01004'
88 DB_ERR_PRIV_NOT_REVOKED // SqlState = '01006'
89 DB_ERR_INVALID_CONN_STR_ATTR // SqlState = '01S00'
90 DB_ERR_ERROR_IN_ROW // SqlState = '01S01'
91 DB_ERR_OPTION_VALUE_CHANGED // SqlState = '01S02'
92 DB_ERR_NO_ROWS_UPD_OR_DEL // SqlState = '01S03'
93 DB_ERR_MULTI_ROWS_UPD_OR_DEL // SqlState = '01S04'
94 DB_ERR_WRONG_NO_OF_PARAMS // SqlState = '07001'
95 DB_ERR_DATA_TYPE_ATTR_VIOL // SqlState = '07006'
96 DB_ERR_UNABLE_TO_CONNECT // SqlState = '08001'
97 DB_ERR_CONNECTION_IN_USE // SqlState = '08002'
98 DB_ERR_CONNECTION_NOT_OPEN // SqlState = '08003'
99 DB_ERR_REJECTED_CONNECTION // SqlState = '08004'
100 DB_ERR_CONN_FAIL_IN_TRANS // SqlState = '08007'
101 DB_ERR_COMM_LINK_FAILURE // SqlState = '08S01'
102 DB_ERR_INSERT_VALUE_LIST_MISMATCH // SqlState = '21S01'
103 DB_ERR_DERIVED_TABLE_MISMATCH // SqlState = '21S02'
104 DB_ERR_STRING_RIGHT_TRUNC // SqlState = '22001'
105 DB_ERR_NUMERIC_VALUE_OUT_OF_RNG // SqlState = '22003'
106 DB_ERR_ERROR_IN_ASSIGNMENT // SqlState = '22005'
107 DB_ERR_DATETIME_FLD_OVERFLOW // SqlState = '22008'
108 DB_ERR_DIVIDE_BY_ZERO // SqlState = '22012'
109 DB_ERR_STR_DATA_LENGTH_MISMATCH // SqlState = '22026'
110 DB_ERR_INTEGRITY_CONSTRAINT_VIOL // SqlState = '23000'
111 DB_ERR_INVALID_CURSOR_STATE // SqlState = '24000'
112 DB_ERR_INVALID_TRANS_STATE // SqlState = '25000'
113 DB_ERR_INVALID_AUTH_SPEC // SqlState = '28000'
114 DB_ERR_INVALID_CURSOR_NAME // SqlState = '34000'
115 DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL // SqlState = '37000'
116 DB_ERR_DUPLICATE_CURSOR_NAME // SqlState = '3C000'
117 DB_ERR_SERIALIZATION_FAILURE // SqlState = '40001'
118 DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL2 // SqlState = '42000'
119 DB_ERR_OPERATION_ABORTED // SqlState = '70100'
120 DB_ERR_UNSUPPORTED_FUNCTION // SqlState = 'IM001'
121 DB_ERR_NO_DATA_SOURCE // SqlState = 'IM002'
122 DB_ERR_DRIVER_LOAD_ERROR // SqlState = 'IM003'
123 DB_ERR_SQLALLOCENV_FAILED // SqlState = 'IM004'
124 DB_ERR_SQLALLOCCONNECT_FAILED // SqlState = 'IM005'
125 DB_ERR_SQLSETCONNECTOPTION_FAILED // SqlState = 'IM006'
126 DB_ERR_NO_DATA_SOURCE_DLG_PROHIB // SqlState = 'IM007'
127 DB_ERR_DIALOG_FAILED // SqlState = 'IM008'
128 DB_ERR_UNABLE_TO_LOAD_TRANSLATION_DLL // SqlState = 'IM009'
129 DB_ERR_DATA_SOURCE_NAME_TOO_LONG // SqlState = 'IM010'
130 DB_ERR_DRIVER_NAME_TOO_LONG // SqlState = 'IM011'
131 DB_ERR_DRIVER_KEYWORD_SYNTAX_ERROR // SqlState = 'IM012'
132 DB_ERR_TRACE_FILE_ERROR // SqlState = 'IM013'
133 DB_ERR_TABLE_OR_VIEW_ALREADY_EXISTS // SqlState = 'S0001'
134 DB_ERR_TABLE_NOT_FOUND // SqlState = 'S0002'
135 DB_ERR_INDEX_ALREADY_EXISTS // SqlState = 'S0011'
136 DB_ERR_INDEX_NOT_FOUND // SqlState = 'S0012'
137 DB_ERR_COLUMN_ALREADY_EXISTS // SqlState = 'S0021'
138 DB_ERR_COLUMN_NOT_FOUND // SqlState = 'S0022'
139 DB_ERR_NO_DEFAULT_FOR_COLUMN // SqlState = 'S0023'
140 DB_ERR_GENERAL_ERROR // SqlState = 'S1000'
141 DB_ERR_MEMORY_ALLOCATION_FAILURE // SqlState = 'S1001'
142 DB_ERR_INVALID_COLUMN_NUMBER // SqlState = 'S1002'
143 DB_ERR_PROGRAM_TYPE_OUT_OF_RANGE // SqlState = 'S1003'
144 DB_ERR_SQL_DATA_TYPE_OUT_OF_RANGE // SqlState = 'S1004'
145 DB_ERR_OPERATION_CANCELLED // SqlState = 'S1008'
146 DB_ERR_INVALID_ARGUMENT_VALUE // SqlState = 'S1009'
147 DB_ERR_FUNCTION_SEQUENCE_ERROR // SqlState = 'S1010'
148 DB_ERR_OPERATION_INVALID_AT_THIS_TIME // SqlState = 'S1011'
149 DB_ERR_INVALID_TRANS_OPERATION_CODE // SqlState = 'S1012'
150 DB_ERR_NO_CURSOR_NAME_AVAIL // SqlState = 'S1015'
151 DB_ERR_INVALID_STR_OR_BUF_LEN // SqlState = 'S1090'
152 DB_ERR_DESCRIPTOR_TYPE_OUT_OF_RANGE // SqlState = 'S1091'
153 DB_ERR_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1092'
154 DB_ERR_INVALID_PARAM_NO // SqlState = 'S1093'
155 DB_ERR_INVALID_SCALE_VALUE // SqlState = 'S1094'
156 DB_ERR_FUNCTION_TYPE_OUT_OF_RANGE // SqlState = 'S1095'
157 DB_ERR_INF_TYPE_OUT_OF_RANGE // SqlState = 'S1096'
158 DB_ERR_COLUMN_TYPE_OUT_OF_RANGE // SqlState = 'S1097'
159 DB_ERR_SCOPE_TYPE_OUT_OF_RANGE // SqlState = 'S1098'
160 DB_ERR_NULLABLE_TYPE_OUT_OF_RANGE // SqlState = 'S1099'
161 DB_ERR_UNIQUENESS_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1100'
162 DB_ERR_ACCURACY_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1101'
163 DB_ERR_DIRECTION_OPTION_OUT_OF_RANGE // SqlState = 'S1103'
164 DB_ERR_INVALID_PRECISION_VALUE // SqlState = 'S1104'
165 DB_ERR_INVALID_PARAM_TYPE // SqlState = 'S1105'
166 DB_ERR_FETCH_TYPE_OUT_OF_RANGE // SqlState = 'S1106'
167 DB_ERR_ROW_VALUE_OUT_OF_RANGE // SqlState = 'S1107'
168 DB_ERR_CONCURRENCY_OPTION_OUT_OF_RANGE // SqlState = 'S1108'
169 DB_ERR_INVALID_CURSOR_POSITION // SqlState = 'S1109'
170 DB_ERR_INVALID_DRIVER_COMPLETION // SqlState = 'S1110'
171 DB_ERR_INVALID_BOOKMARK_VALUE // SqlState = 'S1111'
172 DB_ERR_DRIVER_NOT_CAPABLE // SqlState = 'S1C00'
173 DB_ERR_TIMEOUT_EXPIRED // SqlState = 'S1T00'
174\end{verbatim}
175
d0c6b305 176\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.}
3ca6a5f0
BP
177
178\begin{verbatim}
179 char dbmsName[40] - Name of the dbms product
180 char dbmsVer[64] - Version # of the dbms product
181 char driverName[40] - Driver name
182 char odbcVer[60] - ODBC version of the driver
183 char drvMgrOdbcVer[60] - ODBC version of the driver manager
184 char driverVer[60] - Driver version
185 char serverName[80] - Server Name, typically a connect string
186 char databaseName[128] - Database filename
187 char outerJoins[2] - Does datasource support outer joins
188 char procedureSupport[2] - Does datasource support stored procedures
189 UWORD maxConnections - Maximum # of connections datasource supports
190 UWORD maxStmts - Maximum # of HSTMTs per HDBC
191 UWORD apiConfLvl - ODBC API conformance level
192 UWORD cliConfLvl - Is datasource SAG compliant
193 UWORD sqlConfLvl - SQL conformance level
194 UWORD cursorCommitBehavior - How cursors are affected on db commit
195 UWORD cursorRollbackBehavior - How cursors are affected on db rollback
196 UWORD supportNotNullClause - Does datasource support NOT NULL clause
197 char supportIEF[2] - Integrity Enhancement Facility (Ref. Integrity)
198 UDWORD txnIsolation - Transaction isolation level supported by driver
199 UDWORD txnIsolationOptions - Transaction isolation level options available
200 UDWORD fetchDirections - Fetch directions supported
201 UDWORD lockTypes - Lock types supported in SQLSetPos
202 UDWORD posOperations - Position operations supported in SQLSetPos
203 UDWORD posStmts - Position statements supported
204 UDWORD scrollConcurrency - Scrollable cursor concurrency options supported
205 UDWORD scrollOptions - Scrollable cursor options supported
206 UDWORD staticSensitivity - Can additions/deletions/updates be detected
207 UWORD txnCapable - Indicates if datasource supports transactions
208 UDWORD loginTimeout - Number seconds to wait for a login request
209\end{verbatim}
210
d0c6b305 211\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.}
3ca6a5f0
BP
212
213\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.}
214
215\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.}
216
217\docparam{wxChar {\bf wxDb::sqlState}[20]}{Set by wxDb::TranslateSqlState(). Indicates the error state after a failed ODBC operation. Used for reporting ODBC errors.}
218
d0c6b305 219\wxheading{Remarks}
3ca6a5f0 220
d0c6b305
GT
221Default cursor scrolling is defined by wxODBC_FWD_ONLY_CURSORS in setup.h
222when the wxWindows library is built. This behavior can be overridden when
223an instance of a wxDb is created (see \helpref{wxDb constructor}{wxdbconstr}).
3ca6a5f0 224
d0c6b305 225\wxheading{See also}
3ca6a5f0 226
d0c6b305 227\helpref{wxDbColFor}{wxdbcolfor}, \helpref{wxDbColInf}{wxdbcolinf}, \helpref{wxDbTable}{wxdbtable}, \helpref{wxDbTableInf}{wxdbtableinf}, \helpref{wxDbInf}{wxdbinf}
3ca6a5f0 228
d0c6b305 229\subsection{Associated non-class functions}\label{wxdbfunctions}
3ca6a5f0 230
d0c6b305 231The following functions are used in conjunction with the wxDb class.
3ca6a5f0 232
d0c6b305 233\func{wxDb *}{wxDbGetConnection}{\param{wxDbConnectInf *}{pDbConfig}, \param{bool }{FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS}}
3ca6a5f0 234
d0c6b305 235\func{bool}{wxDbFreeConnection}{\param{wxDb *}{pDb}}
f6bcfd97 236
d0c6b305 237\func{void}{wxDbCloseConnections}{\void}
f6bcfd97 238
d0c6b305 239\func{int}{wxDbConnectionsInUse}{\void}
f6bcfd97 240
d0c6b305 241\func{bool}{wxDbSqlLog}{\param{wxDbSqlLogState }{state}, \param{const wxChar *}{filename = SQL_LOG_FILENAME}}
f6bcfd97 242
d0c6b305 243\func{bool}{wxDbGetDataSource}{\param{HENV }{henv}, \param{char *}{Dsn}, \param{SWORD }{DsnMax}, \param{char *}{DsDesc}, \param{SWORD }{DsDescMax}, \param{UWORD }{direction = SQL_FETCH_NEXT}}
f6bcfd97 244
d0c6b305 245\latexignore{\rtfignore{\wxheading{Members}}}
f6bcfd97 246
3ca6a5f0
BP
247\membersection{wxDb::wxDb}\label{wxdbconstr}
248
249\func{}{wxDb}{\void}
f6bcfd97
BP
250
251Default constructor.
252
eea22fd5 253\func{}{wxDb}{\param{HENV &}{aHenv}, \param{bool }{FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS}}
f6bcfd97
BP
254
255Constructor, used to create an ODBC connection to a data source.
256
257\wxheading{Parameters}
258
d0c6b305
GT
259\docparam{aHenv}{Environment handle used for this connection.}
260
261\docparam{FwdOnlyCursors}{Will cursors created for use with this datasource connection only allow forward scrolling cursors.}
f6bcfd97
BP
262
263\wxheading{Remarks}
264
3ca6a5f0 265This is the constructor for the wxDb class. The wxDb object must
f6bcfd97
BP
266be created and opened before any database activity can occur.
267
268\wxheading{Example}
d0c6b305 269
f6bcfd97 270\begin{verbatim}
3ca6a5f0
BP
271 wxDbConnectInf ConnectInf;
272 ....Set values for member variables of ConnectInf here
f6bcfd97 273
3ca6a5f0
BP
274 wxDb sampleDB(ConnectInf.Henv);
275 if (!sampleDB.Open(ConnectInf.Dsn, ConnectInf.Uid, ConnectInf.AuthStr))
f6bcfd97
BP
276 {
277 // Error opening data source
278 }
279\end{verbatim}
280
281
3ca6a5f0 282\membersection{wxDb::Catalog}\label{wxdbcatalog}
f6bcfd97
BP
283
284\func{bool}{Catalog}{\param{char *}{ userID}, \param{char *}{fileName = SQL_CATALOG_FILENAME}}
285
3ca6a5f0
BP
286Allows 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.
287
f6bcfd97
BP
288\wxheading{Parameters}
289
290\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.}
291
eea22fd5 292\docparam{fileName}{{\it OPTIONAL}. Name of the text file to create and write the DB catalog to.}
f6bcfd97 293
3ca6a5f0 294\wxheading{Return value}
f6bcfd97 295
3ca6a5f0 296Returns TRUE if the catalog request was successful, of FALSE if there was some reason the catalog could not be generated
f6bcfd97
BP
297
298\wxheading{Example}
d0c6b305 299
f6bcfd97
BP
300\begin{verbatim}
301============== ============== ================ ========= =======
302TABLE NAME COLUMN NAME DATA TYPE PRECISION LENGTH
303============== ============== ================ ========= =======
304EMPLOYEE RECID (0008)NUMBER 15 8
305EMPLOYEE USER_ID (0012)VARCHAR2 13 13
306EMPLOYEE FULL_NAME (0012)VARCHAR2 26 26
307EMPLOYEE PASSWORD (0012)VARCHAR2 26 26
308EMPLOYEE START_DATE (0011)DATE 19 16
309\end{verbatim}
310
311
3ca6a5f0 312\membersection{wxDb::Close}\label{wxdbclose}
f6bcfd97
BP
313
314\func{void}{Close}{\void}
315
3ca6a5f0
BP
316Closes the database connection.
317
f6bcfd97
BP
318\wxheading{Remarks}
319
3ca6a5f0
BP
320At 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.
321
d0c6b305 322Any wxDbTable instances which use this connection must be deleted before closing the database connection.
f6bcfd97
BP
323
324\wxheading{Example}
d0c6b305 325
f6bcfd97
BP
326\begin{verbatim}
327 // Commit any open transactions on the data source
328 sampleDB.CommitTrans();
329
d0c6b305 330 // Delete any remaining wxDbTable objects allocated with new
f6bcfd97
BP
331 delete parts;
332
3ca6a5f0 333 // Close the wxDb connection when finished with it
f6bcfd97
BP
334 sampleDB.Close();
335
336 // Free Environment Handle that ODBC uses
337 if (SQLFreeEnv(Db.Henv) != SQL_SUCCESS)
338 {
339 // Error freeing environment handle
340 }
341\end{verbatim}
342
3ca6a5f0
BP
343
344\membersection{wxDb::CommitTrans}\label{wxdbcommittrans}
345
346\func{bool}{CommitTrans}{\void}
347
348Permanently "commits" changes (insertions/deletions/updates) to the database.
349
350\wxheading{Return value}
351
352Returns TRUE if the commit was successful, or FALSE if the commit failed.
353
354\wxheading{Remarks}
355
356Transactions 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.
357
358\wxheading{Special Note : {\it Cursors} }
359
360\normalbox{It is important to understand that different database/ODBC driver combinations handle
361transactions differently. One thing in particular that you must pay attention to is
362cursors, in regard to transactions. Cursors are what allow you to scroll through
363records forward and backward and to manipulate records as you scroll through them.
364When you issue a query, a cursor is created behind the scenes. The cursor keeps track
365of the query and keeps track of the current record pointer. After you commit or
366rollback a transaction, the cursor may be closed automatically. This means you must
d0c6b305 367requery the data source before you can perform any additional work against the wxDbTable
3ca6a5f0 368object. This is only necessary however if the data source closes the cursor after a
d0c6b305 369commit or rollback. Use the wxDbTable::IsCursorClosedOnCommit() member function to
3ca6a5f0
BP
370determine the data source's transaction behavior. Note, it would be very inefficient
371to just assume the data source closes the cursor and always requery. This could put
372a significant, unnecessary load on data sources that leave the cursors open after a
373transaction.}
374
375
376\membersection{wxDb::CreateView}\label{wxdbcreateviews}
377
378\func{bool}{CreateView}{\param{char *}{ viewName}, \param{char *}{ colList}, \param{char *}{pSqlStmt}}
379
380Creates a SQL VIEW.
381
382\wxheading{Parameters}
383
384\docparam{viewName}{The name of the view. e.g. PARTS_V}
d0c6b305
GT
385
386\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.}
387
388\docparam{pSqlStmt}{Pointer to the select statement portion of the CREATE VIEW statement. Must be a complete, valid SQL SELECT statement.}
3ca6a5f0
BP
389
390\wxheading{Remarks}
391
392A '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.
393
394NOTE: Views are not available with all datasources. Oracle is one example of a datasouce which does support views.
395
396\wxheading{Example}
d0c6b305 397
3ca6a5f0
BP
398\begin{verbatim}
399 // Incomplete code sample
400 db.CreateView("PARTS_SD1", "PN, PD, QTY",
d0c6b305
GT
401 "SELECT PART_NO, PART_DESC, QTY_ON_HAND * 1.1 FROM PARTS \
402 WHERE STORAGE_DEVICE = 1");
3ca6a5f0
BP
403
404 // PARTS_SD1 can now be queried just as if it were a data table.
405 // e.g. SELECT PN, PD, QTY FROM PARTS_SD1
406\end{verbatim}
407
408
eea22fd5
GT
409\membersection{wxDb::Dbms}\label{wxdbdbms}
410
411\func{wxDBMS }{Dbms}{\void}
412
413\wxheading{Remarks}
414
415The return value will be of the enumerated type wxDBMS. This enumerated
416type contains a list of all the currently tested and supported databases.
417
418Additional databases may be work with these classes, but these databases
419returned by this function have been tested and confirmed to work with
420these ODBC classes.
421
422enum wxDBMS includes:
423
424\begin{verbatim}
425 dbmsUNIDENTIFIED
426 dbmsORACLE
427 dbmsSYBASE_ASA
428 dbmsSYBASE_ASE
429 dbmsMY_SQL_SERVER
430 dbmsMY_SQL
431 dbmsPOSTGRES
432 dbmsACCESS
433 dbmsDBASE
434 dbmsINFORMIX
435\end{verbatim}
436
437There are known issues with conformance to the ODBC standards with several
438datasources listed above. Please see the overview for specific details on
439which datasource have which issues.
440
441\wxheading{Return value}
442
443The return value will indicate which of the supported datasources is
444currently connected to by this connection. In the event that the
445datasource is not recognized, a value of 'dbmsUNIDENTIFIED' is returned.
446
447
3ca6a5f0
BP
448\membersection{wxDb::DispAllErrors}\label{wxdbdispallerrors}
449
450\func{bool}{DispAllErrors}{\param{HENV}{ aHenv}, {\param}{HDBC}{ aHdbc = SQL_NULL_HDBC}, {\param}{HSTMT}{ aHstmt = SQL_NULL_HSTMT}}
451
eea22fd5
GT
452Logs all database errors that occurred as a result of the last executed
453database command. This logging also includes debug logging when compiled in
454debug mode via \helpref{wxLogDebug}{wxlogdebug}. If logging is turned on
455via \helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging}, then an entry is also
456logged to the defined log file.
3ca6a5f0
BP
457
458\wxheading{Parameters}
459
460\docparam{aHenv}{A handle to the ODBC environment.}
d0c6b305
GT
461
462\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.}
463
464\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.}
3ca6a5f0
BP
465
466\wxheading{Remarks}
467
468This 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()).
469
470\wxheading{See also}
471
d0c6b305 472\helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging}, wxDbSqlLog
3ca6a5f0
BP
473
474\wxheading{Example}
d0c6b305 475
3ca6a5f0
BP
476\begin{verbatim}
477 if (SQLExecDirect(hstmt, (UCHAR FAR *) pSqlStmt, SQL_NTS) != SQL_SUCCESS)
478 // Display all ODBC errors for this stmt
479 return(db.DispAllErrors(db.henv, db.hdbc, hstmt));
480\end{verbatim}
481
482
483\membersection{wxDb::DispNextError}\label{wxdbdispnexterror}
484
485\func{void}{DispNextError}{\void}
486
487\wxheading{Remarks}
488
489This function is normally used internally within the ODBC class library.
490It could be used externally if calling ODBC functions directly. This
491function works in conjunction with \helpref{wxDb::GetNextError}{wxdbgetnexterror} when errors (or
492sometimes informational messages) returned from ODBC need to be analyzed
493rather than simply displaying them as an error. GetNextError() retrieves
494the next ODBC error from the ODBC error queue. The wxDb member variables
495"sqlState", "nativeError" and "errorMsg" could then be evaluated. To
496display the error retrieved, DispNextError() could then be called.
497The combination of GetNextError() and DispNextError() can be used to
498iteratively step through the errors returned from ODBC evaluating each
499one in context and displaying the ones you choose.
500
501\wxheading{Example}
d0c6b305 502
3ca6a5f0
BP
503\begin{verbatim}
504 // Drop the table before attempting to create it
505 sprintf(sqlStmt, "DROP TABLE %s", tableName);
506 // Execute the drop table statement
507 if (SQLExecDirect(hstmt,(UCHAR FAR *)sqlStmt,SQL_NTS) != SQL_SUCCESS)
508 {
509 // Check for sqlState = S0002, "Table or view not found".
510 // Ignore this error, bomb out on any other error.
511 pDb->GetNextError(henv, hdbc, hstmt);
512 if (strcmp(pDb->sqlState, "S0002"))
513 {
514 pDb->DispNextError(); // Displayed error retrieved
515 pDb->DispAllErrors(henv, hdbc, hstmt); // Display all other errors, if any
516 pDb->RollbackTrans(); // Rollback the transaction
517 CloseCursor(); // Close the cursor
518 return(FALSE); // Return Failure
519 }
520 }
521\end{verbatim}
522
523
524\membersection{wxDb::DropView}\label{wxdbdropview}
525
526\func{bool}{DropView}{\param{const char *}{viewName}}
527
528Drops the data table view named in 'viewName'.
529
530\wxheading{Parameters}
531
532\docparam{viewName}{Name of the view to be dropped.}
533
534\wxheading{Remarks}
535
d0c6b305 536If the view does not exist, this function will return TRUE. Note that views are not supported with all data sources.
3ca6a5f0
BP
537
538\membersection{wxDb::ExecSql}\label{wxdbexecsql}
539
540\func{bool}{ExecSql}{\param{char *}{pSqlStmt}}
541
542Allows 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.
543
544\wxheading{Parameters}
545
546\docparam{pSqlStmt}{Pointer to the SQL statement to be executed.}
547
548\wxheading{Remarks}
549
550This member extends the wxDb class and allows you to build and execute ANY VALID
551SQL statement against the data source. This allows you to extend the class
552library by being able to issue any SQL statement that the data source is capable
553of processing.
554
555\wxheading{See also}
556
557\helpref{wxDb::GetData}{wxdbgetdata}, \helpref{wxDb::GetNext}{wxdbgetnext}
558
3ca6a5f0
BP
559\membersection{wxDb::FwdOnlyCursors}\label{wxdbfwdonlycursors}
560
561\func{bool}{FwdOnlyCursors}{\void}
562
563Indicates whether this connection to the datasource only allows forward scrolling cursors or not. This state is set at connection creation time.
564
d0c6b305
GT
565\wxheading{Remarks}
566
567In 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.
3ca6a5f0 568
d0c6b305 569\wxheading{See also}
3ca6a5f0 570
d0c6b305 571\helpref{wxDb::IsFwdOnlyCursors}{wxdbisfwdonlycursors}, \helpref{wxDb::wxDb}{wxdbconstr}, \helpref{wxDbGetConnection}{wxdbfunctions}
3ca6a5f0
BP
572
573\membersection{wxDb::GetCatalog}\label{wxdbgetcatalog}
574
575\func{wxDbInf *}{GetCatalog}{\param{char *}{userID}}
576
577Returns 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.
578
579\wxheading{Parameters}
580
d0c6b305 581\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:}
3ca6a5f0
BP
582
583\begin{verbatim}
584 userID == NULL ... UserID is ignored (DEFAULT)
585 userID == "" ... UserID set equal to 'this->uid'
586 userID != "" ... UserID set equal to 'userID'
587\end{verbatim}
588
589\wxheading{Remarks}
590
591The 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.
592
3ca6a5f0
BP
593\membersection{wxDb::GetColumnCount}\label{wxdbgetcolumncount}
594
595\func{int}{GetColumnCount}{\param{char *}{tableName}, \param{const char *}{userID}}
596
597\wxheading{Parameters}
598
599\docparam{tableName}{A table name you wish to obtain column information about.}
d0c6b305
GT
600
601\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:}
3ca6a5f0
BP
602
603\begin{verbatim}
604 userID == NULL ... UserID is ignored (DEFAULT)
605 userID == "" ... UserID set equal to 'this->uid'
606 userID != "" ... UserID set equal to 'userID'
607\end{verbatim}
608
609\wxheading{Return value}
610
611Returns 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.
612
3ca6a5f0
BP
613\membersection{wxDb::GetColumns}\label{wxdbgetcolumns}
614
615\func{wxDbColInf *}{GetColumns}{\param{char *}{tableName}, \param{int *}{numCols}, \param{const char *}{userID=NULL}}
616
617\func{wxDbColInf *}{GetColumns}{\param{char *}{tableName[]}, \param{const char *}{userID}}
618
619\wxheading{Parameters}
620
621\docparam{tableName}{A table name you wish to obtain column information about.}
d0c6b305
GT
622\docparam{numCols}{A pointer to a integer which will hold a count of the number of columns returned by this function}
623\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.}
624\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:}
3ca6a5f0
BP
625
626\begin{verbatim}
627 userID == NULL ... UserID is ignored (DEFAULT)
628 userID == "" ... UserID set equal to 'this->uid'
629 userID != "" ... UserID set equal to 'userID'
630\end{verbatim}
631
632\wxheading{Return value}
633
634This function returns an array of wxDbColInf structures. This allows you to obtain
635information regarding the columns of your table(s). If no columns were found, or
d0c6b305 636an error occurred, this pointer will be zero (null).
3ca6a5f0
BP
637
638THE CALLING FUNCTION IS RESPONSIBLE FOR DELETING THE {\it wxDbColInf} MEMORY WHEN IT IS
639FINISHED WITH IT.
640
641\normalbox{ALL column bindings associated with this wxDb instance are unbound
642by this function. This function should use its own wxDb instance
643to avoid undesired unbinding of columns.}
644
645\wxheading{See also}
646
647\helpref{wxDbColInf}{wxdbcolinf}
648
649\wxheading{Example}
d0c6b305 650
3ca6a5f0
BP
651\begin{verbatim}
652 char *tableList[] = {"PARTS", 0};
653 wxDbColInf *colInf = pDb->GetColumns(tableList);
654 if (colInf)
655 {
656 // Use the column inf
657 .......
658 // Destroy the memory
659 delete [] colInf;
660 }
661\end{verbatim}
662
663
664\membersection{wxDb::GetData}\label{wxdbgetdata}
665
666\func{bool}{GetData}{\param{UWORD}{ colNo}, \param{SWORD}{ cType}, \param{PTR}{ pData}, \param{SDWORD}{ maxLen}, \param{SDWORD FAR *}{ cbReturned} }
667
668Used to retrieve result set data without binding column values to memory variables (i.e. not using a wxDbTable instance to access table data).
669
670\wxheading{Parameters}
671
672\docparam{colNo}{Ordinal number of column in the result set to be returned.}
673\docparam{cType}{The C data type that is to be returned.}
674\docparam{pData}{Memory buffer which will hold the data returned by the call to this function.}
675\docparam{maxLen}{Maximum size of the buffer that will hold the returned value.}
676\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.}
677
678\wxheading{See also}
679
680\helpref{wxDb::GetNext}{wxdbgetnext}, \helpref{wxDb::ExecSql}{wxdbexecsql}
681
682\wxheading{Example}
d0c6b305 683
3ca6a5f0 684\begin{verbatim}
eea22fd5
GT
685 SDWORD cb;
686 ULONG reqQty;
687 wxString sqlStmt;
688 sqlStmt = "SELECT SUM(REQUIRED_QTY - PICKED_QTY) FROM ORDER_TABLE WHERE \
d0c6b305 689 PART_RECID = 1450 AND REQUIRED_QTY > PICKED_QTY";
3ca6a5f0 690
eea22fd5
GT
691 // Perform the query
692 if (!pDb->ExecSql(sqlStmt.c_str()))
693 {
694 // ERROR
695 return(0);
696 }
697
698 // Request the first row of the result set
699 if (!pDb->GetNext())
700 {
701 // ERROR
702 return(0);
703 }
704
705 Read column #1 of this row of the result set and store the value in 'reqQty'
706 if (!pDb->GetData(1, SQL_C_ULONG, &reqQty, 0, &cb))
707 {
708 // ERROR
709 return(0);
710 }
711
712 // Check for a NULL result
713 if (cb == SQL_NULL_DATA)
714 return(0);
3ca6a5f0
BP
715\end{verbatim}
716
717\wxheading{Remarks}
718
719When requesting multiple columns to be returned from the result set (for example, the SQL query
eea22fd5 720requested 3 columns be returned), the calls to this function must request the columns in ordinal
3ca6a5f0
BP
721sequence (1,2,3 or 1,3 or 2,3).
722
3ca6a5f0
BP
723\membersection{wxDb::GetDatabaseName}\label{wxdbgetdatabasename}
724
eea22fd5 725\func{const char *}{GetDatabaseName}{\void}
3ca6a5f0
BP
726
727Returns the name of the database engine.
728
3ca6a5f0
BP
729\membersection{wxDb::GetDataSource}\label{wxdbgetdatasource}
730
eea22fd5 731\func{const char *}{GetDataSource}{\void}
3ca6a5f0
BP
732
733Returns the ODBC datasource name.
734
3ca6a5f0
BP
735\membersection{wxDb::GetHDBC}\label{wxdbgethdbc}
736
737\func{HDBC}{GetHDBC}{\void}
738
739Returns the ODBC handle to the database connection.
740
3ca6a5f0
BP
741\membersection{wxDb::GetHENV}\label{wxdbgethenv}
742
743\func{HENV}{GetHENV}{\void}
744
745Returns the ODBC environment handle.
746
3ca6a5f0
BP
747\membersection{wxDb::GetHSTMT}\label{wxdbgethstmt}
748
749\func{HSTMT}{GetHSTMT}{\void}
750
751Returns the ODBC statement handle associated with this database connection.
752
3ca6a5f0
BP
753\membersection{wxDb::GetKeyFields}\label{wxdbgetkeyfields}
754
755\func{int}{GetKeyFields}{\param{char *}{tableName}, \param{wxDbColInf *}{colInf}, \param{int}{nocols}}
756
757Used 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.
758
d0c6b305 759This function is primarily for use by the \helpref{wxDb::GetColumns}{wxdbgetcolumns} function, but may be called if desired from the client application.
3ca6a5f0
BP
760
761\wxheading{Parameters}
762
763\docparam{tableName}{Name of the table for which the columns will be evaluated as to their inclusion in any indexes.}
d0c6b305 764\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.}
3ca6a5f0
BP
765\docparam{nocols}{Number of columns defined in the instance of colInf.}
766
767\wxheading{Return value}
768
769Currently always returns TRUE.
770
771\wxheading{See also}
772
773\helpref{wxDbColInf}{wxdbcolinf}, \helpref{wxDb::GetColumns}{wxdbgetcolumns}
774
3ca6a5f0
BP
775\membersection{wxDb::GetNext}\label{wxdbgetnext}
776
d0c6b305 777\func{bool}{GetNext}{\void}
3ca6a5f0 778
eea22fd5 779Requests the next row in the result set obtained by issuing a query through a direct request using wxDb::ExecSql().
3ca6a5f0
BP
780
781\wxheading{See also}
782
783\helpref{wxDb::ExecSql}{wxdbexecsql}, \helpref{wxDb::GetData}{wxdbgetdata}
784
3ca6a5f0
BP
785\membersection{wxDb::GetNextError}\label{wxdbgetnexterror}
786
787\func{bool}{GetNextError}{\param{HENV}{ aHenv}, \param{HDBC}{ aHdbc = SQL_NULL_HDBC}, \param{HSTMT}{ aHstmt = SQL_NULL_HSTMT}}
788
789\wxheading{Parameters}
790
791\docparam{aHenv}{A handle to the ODBC environment.}
792\docparam{aHdbc}{A handle to the ODBC connection. Pass this in if the ODBC function call that
793erred out required a hdbc or hstmt argument.}
794\docparam{AHstmt}{A handle to the ODBC statement being executed against. Pass this in if the
795ODBC function call that erred out requires a hstmt argument.}
796
797\wxheading{See also}
798
799\helpref{wxDb::DispNextError}{wxdbdispnexterror}, \helpref{wxDb::DispAllErrors}{wxdbdispallerrors}
800
801\wxheading{Example}
d0c6b305 802
3ca6a5f0
BP
803\begin{verbatim}
804 if (SQLExecDirect(hstmt, (UCHAR FAR *) pSqlStmt, SQL_NTS) != SQL_SUCCESS)
805 {
806 // Display all ODBC errors for this stmt
807 return(db.DispAllErrors(db.henv, db.hdbc, hstmt));
808 }
809\end{verbatim}
810
eea22fd5 811
3ca6a5f0
BP
812\membersection{wxDb::GetPassword}\label{wxdbgetpassword}
813
eea22fd5 814\func{const char *}{GetPassword}{\void}
3ca6a5f0
BP
815
816Returns the password used to connect to the datasource.
817
3ca6a5f0
BP
818\membersection{wxDb::GetTableCount}\label{wxdbgettablecount}
819
820\func{int}{GetTableCount}{\void}
821
822Returns the number of wxDbTable() instances currently using this data source connection.
823
eea22fd5 824
3ca6a5f0
BP
825\membersection{wxDb::GetUsername}\label{wxdbgetusername}
826
eea22fd5 827\func{const char *}{GetUsername}{\void}
3ca6a5f0
BP
828
829Returns the user name used to access the datasource.
830
eea22fd5 831
3ca6a5f0
BP
832\membersection{wxDb::Grant}\label{wxdbgrant}
833
834\func{bool}{Grant}{\param{int}{ privileges}, \param{char *}{tableName}, \param{char *}{userList = "PUBLIC"}}
835
836Use this member function to GRANT privileges to users for accessing tables in the datasource.
837
838\wxheading{Parameters}
839
d0c6b305 840\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:}
eea22fd5 841
3ca6a5f0
BP
842\begin{verbatim}
843 DB_GRANT_SELECT = 1
844 DB_GRANT_INSERT = 2
845 DB_GRANT_UPDATE = 4
846 DB_GRANT_DELETE = 8
847 DB_GRANT_ALL = DB_GRANT_SELECT | DB_GRANT_INSERT |
848 DB_GRANT_UPDATE | DB_GRANT_DELETE
849\end{verbatim}
eea22fd5 850
3ca6a5f0 851\docparam{tableName}{The name of the table you wish to grant privileges on.}
d0c6b305 852\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.}
3ca6a5f0
BP
853
854\wxheading{Remarks}
855
856Some 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.
857
858\wxheading{Example}
d0c6b305 859
3ca6a5f0
BP
860\begin{verbatim}
861 db.Grant(DB_GRANT_SELECT | DB_GRANT_INSERT, "PARTS", "mary, sue");
862\end{verbatim}
863
864
d0c6b305
GT
865\membersection{wxDb::IsFwdOnlyCursors}\label{wxdbisfwdonlycursors}
866
867\func{bool}{IsFwdOnlyCursors}{\void}
868
eea22fd5
GT
869This setting indicates whether this database connection was created
870as being capable of using only forward scrolling cursors. This function
871does NOT indicate if the ODBC driver or datasource supports backward
872scrolling cursors. There is no standard way of detecting if the driver
873or datasource can support backward scrolling cursors.
874
875If a wxDb instance was created as being forward only cursors, then even if
876the datasource and ODBC driver support backward scrolling cursors, then
877tables using this database connection can only use forward scrolling
878cursors.
879
880The default setting of whether a wxDb connection to a database allows
881forward-only or also backward scrolling cursors is defined in setup.h by
882the wxODBC_FWD_ONLY_CURSORS value. This default setting can be overridden
883when the wxDb connection is initially created (see \helpref{wxDb constructor}{wxdbconstr}).
884
885\wxheading{Return value}
886
887Returns TRUE if this datasource connection is defined as using only forward
888scrolling cursors, or FALSE if the connection is defined as being capable
889of supporting backward scrolling cursors (see note above).
d0c6b305
GT
890
891\wxheading{Remarks}
892
eea22fd5
GT
893Added as of wxWindows v2.4 release, this function is a renamed version of
894wxDb::FwdOnlyCursors() to match the normal wxWindows naming conventions for
895class member functions.
d0c6b305
GT
896
897This function is not available in versions prior to v2.4. You should use \helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors} for wxWindows versions priori to 2.4.
898
899\wxheading{See also}
900
eea22fd5
GT
901\helpref{wxDb constructor}{wxdbconstr}, \helpref{wxDbGetConnection}{wxdbfunctions}
902
d0c6b305 903
3ca6a5f0
BP
904\membersection{wxDb::IsOpen}\label{wxdbisopen}
905
906\func{bool}{IsOpen}{\void}
907
eea22fd5
GT
908Indicates whether the database connection to the datasource is currently
909opened.
910
911\wxheading{Remarks}
912
913This function may indicate that the database is open, but the call to
914\helpref{wxDb::Open}{wxdbopen} may have failed to fully initialize the connection
915correctly. The connection to the database {\it is} open and can be used via
916the direct SQL commands, but other functions which depend on the \helpref{wxDb::Open}{wxdbopen}
917to have completed correctly may not function as expected. See \helpref{wxDb::Open}{wxdbopen}
918for more details on partial failures to open a connection instance.
919
920
921\membersection{wxDb::LogError}\label{wxdblogerror}
922
923\func{void}{LogError}{\param{const char *}{errMsg} \param{const char *}{SQLState=0}}
924
925\docparam{errMsg}{Free-form text to display describing the error to be logged.}
926\docparam{SQLState}{Native SQL state error}
927
928\wxheading{Remarks}
929
930Calling this function will enter a log message in the error list maintained
931for the database connection. This log message is free form and can be
932anything the programmer wants to enter in the error list.
933
934If SQL logging is turned on, the call to this function will also log the
935text into the SQL log file.
936
937\wxheading{See also}
938
939\helpref{wxDb::WriteSqlLog}{wxdbwritesqllog}
940
3ca6a5f0 941
3ca6a5f0
BP
942\membersection{wxDb::Open}\label{wxdbopen}
943
944\func{bool}{Open}{\param{char *}{Dsn}, \param{char *}{Uid}, \param{char *}{AuthStr}}
eea22fd5
GT
945\func{bool}{Open}{\param{wxDb *}{copyDb}}
946
947Opens a connection to the datasource, sets behaviors of all databases to
948confirm to the accepted behaviors (e.g. cursor position maintained on commits),
949and queries the datasource for its representations of the basic datatypes to
950determine the form that data going to/from columns in the data tables are
951to be handled.
952
953The second form of this function which accepts a "wxDb *" as a parameter
954can be used to avoid the overhead (execution time, database load, network
955traffic) which are needed to determine the data types and representations
956of data that are necessary for cross-datasource support by these classes.
957Normally the first form of the wxDb::Open() function will open the connection
958and then send a series of queries to the datasource asking it for its
959representation of data types, and all the features it supports. If one
960connection to the datasource has already been made previously, the information
961gathered when that connection was created can just be copied to any new
962connections to the same datasource by passing a pointer to the first
963connection in as a parameter to the wxDb::Open() function. Note that this
964new connection created from the first connections information will use the
965same Dsn/Uid/AuthStr as the first connection used.
3ca6a5f0
BP
966
967\wxheading{Parameters}
968
969\docparam{Dsn}{Data source name. The name of the ODBC data source as
970assigned when the data source is initially set up through the ODBC data
971source manager.}
972\docparam{Uid}{User ID. The name (ID) of the user you wish to connect as
973to the data source. The user name (ID) determines what objects you
974have access to in the datasource and what datasource privileges you have.
975Privileges include being able to create new objects, update objects, delete
976objects and so on. Users and privileges are normally administered by the
977database administrator.}
eea22fd5
GT
978\docparam{AuthStr}{The password associated with the Uid.}
979\docparam{copyDb}{Already completely configured and opened datasource
980connection from which all Dsn, Uid, AuthStr, and data typing information is
981to be copied from for use by this datasource connection.}
982
983\wxheading{Remarks}
984
985After a wxDb instance is created, it must then be opened. When opening a
986data source, there must be hree pieces of information passed. The data
987source name, user name (ID) and the password for the user. No database
988activity on the data source can be performed until it is opened. This
989would normally be done at program startup and the data source would remain
990open for the duration of the program run.
991
992It is possible to have multiple data sources open at the same time to
993support distributed database connections by having separate instances of wxDb
994objects that use different Dsn/Uid/AuthStr settings.
995
996If this function returns a value of FALSE, it does not necessarily mean that
997the connection to the datasource was not opened. It may mean that some
998portion of the initialization of the connection failed (such as a datatype not
999being able to be determined how the datasource represents it). To determine
1000if the connection to the database failed, use the \helpref{wxDb::IsOpen}{wxdbisopen}
1001function after receiving a FALSE result back from this function to determine if
1002the connection was opened or not. If this function returns FALSE, but \helpref{wxDb::IsOpen}{wxdbisopen}
1003returns TRUE, then direct SQL commands may be passed to the database
1004connection and they can be successfully executed, but use of the datatypes
1005that are normally determined during open will not be accessible to any
1006wxDbTable objects using this connection.
3ca6a5f0
BP
1007
1008\wxheading{Example}
d0c6b305 1009
3ca6a5f0
BP
1010\begin{verbatim}
1011 wxDb sampleDB(Db.Henv);
1012 if (!sampleDB.Open("Oracle 7.1 HP/UX", "gtasker", "myPassword"))
1013 {
1014 // Error opening data source
1015 }
1016\end{verbatim}
1017
1018
1019\membersection{wxDb::RollbackTrans}\label{wxdbrollbacktrans}
1020
1021\func{bool}{RollbackTrans}{\void}
1022
1023Function 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.
1024
1025\wxheading{Remarks}
1026
1027Transactions 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.
1028
1029\normalbox{Calling this member function rolls back ALL open (uncommitted) transactions on this ODBC connection.}
1030
1031\wxheading{See also}
1032
1033\helpref{wxDb::CommitTrans}{wxdbcommittrans} for a special note on cursors
1034
eea22fd5
GT
1035
1036\membersection{wxDb::SetDebugErrorMessages}\label{wxdbsetdebugerrormessages}
1037
1038\func{void}{SetDebugErrorMessages}{\param{bool }{state}}
1039
1040\docparam{state}{Either TRUE (debug messages are displayed) or FALSE (debug
1041messages are not displayed.}
1042
1043\wxheading{Remarks}
1044
1045Turns on/off debug error messages from the ODBC class library. When
1046this function is passed TRUE, errors are reported to the user automatically
1047in a text or pop-up dialog when an ODBC error occurs. When passed FALSE,
1048errors are silently handled.
1049
1050When compiled in release mode (FINAL=1), this setting has no affect.
1051
1052\wxheading{See also}
1053
1054\helpref{wxDb constructor}{wxdbconstr}
1055
1056
3ca6a5f0
BP
1057\membersection{wxDb::SetSqlLogging}\label{wxdbsetsqllogging}
1058
eea22fd5 1059\func{bool}{SetSqlLogging}{\param{wxDbSqlLogState}{ state}, \param{const wxChar *}{filename = SQL_LOG_FILENAME}, \param{bool }{ append = FALSE}}
3ca6a5f0
BP
1060
1061\wxheading{Parameters}
1062
d0c6b305 1063\docparam{state}{Either sqlLogOFF or sqlLogON (see \helpref{enum wxDbSqlLogState}{wxdbcolfor}). Turns logging of SQL commands sent to the data source OFF or ON.}
3ca6a5f0
BP
1064\docparam{filename}{{\it OPTIONAL}. Name of the file to which the log text is to be written.}
1065\docparam{append}{{\it OPTIONAL}. Whether the file is appended to or overwritten.}
1066
1067\wxheading{Remarks}
1068
1069When 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.
1070
1071When called with {\it sqlLogOFF}, the logging file is closed, and any calls to WriteSqlLog() are ignored.
1072
eea22fd5 1073
3ca6a5f0
BP
1074\membersection{wxDb::TableExists}\label{wxdbtablexists}
1075
1076\func{bool}{TableExists}{\param{const char *}{tableName}, \param{const char *}{userID=NULL}, \param{const char *}{path=NULL}}
1077
eea22fd5
GT
1078Checks the ODBC data source for the existence of a table. If a {\it userID}
1079is specified, then the table must be accessible by that user (user must have
1080at least minimal privileges to the table).
3ca6a5f0
BP
1081
1082\wxheading{Parameters}
1083
1084\docparam{tableName}{Name of the table to check for the existence of}
1085\docparam{userID}{Owner of the table. Specify a userID when the datasource you are connected
1086to allows multiple unique tables with the same name to be owned by different users. {\it userID}
1087is evaluated as follows:}
1088
1089\begin{verbatim}
1090 userID == NULL ... UserID is ignored (DEFAULT)
1091 userID == "" ... UserID set equal to 'this->uid'
1092 userID != "" ... UserID set equal to 'userID'
1093\end{verbatim}
1094
1095\wxheading{Remarks}
1096
1097{\it tableName} may refer to a table, view, alias or synonym.
1098
d0c6b305 1099This function does not indicate whether or not the user has privileges to query or perform other functions on the table.
3ca6a5f0 1100
eea22fd5
GT
1101\wxheading{See also}
1102
1103\helpref{wxDb::TablePrivileges}{wxdbtableprivileges}
1104
1105
1106\membersection{wxDb::TablePrivileges}\label{wxdbtableprivileges}
1107
1108\func{bool}{TablePrivileges}{\param{const char *}{tableName}, \param{const char *}{priv}, \param{const char *}{userID=NULL}, \param{const char *}{path=""}}
1109
1110Checks the ODBC data source for the existence of a table. If a {\it userID}
1111is specified, then the table must be accessible by that user (user must have
1112at least minimal privileges to the table).
1113
1114\wxheading{Parameters}
1115
1116\docparam{tableName}{Name of the table on which to check privileges.
1117{\it tableName} may refer to a table, view, alias or synonym.}
1118\docparam{priv}{The table privilege being evaluated. May be one of the
1119following (or a data source specific privilege):}
1120
1121\begin{verbatim}
1122 SELECT : The connected user is permitted to retrieve data for one
1123 or more columns of the table.
1124
1125 INSERT : The connected user is permitted to insert new rows
1126 containing data for one or more columns into the table.
1127
1128 UPDATE : The connected user is permitted to update the data in one
1129 or more columns of the table.
1130
1131 DELETE : The connected user is permitted to delete rows of data
1132 from the table.
1133
1134 REFERENCES : Is the connected user permitted to refer to one or more
1135 columns of the table within a constraint (for example, a
1136 unique, referential, or table check constraint).
1137\end{verbatim}
1138\docparam{userID}{Owner of the table. Specify a userID when the datasource
1139you are connected to allows multiple unique tables with the same name to be
1140owned by different users. {\it userID} is evaluated as follows:
1141
1142\begin{verbatim}
1143 userID == NULL ... UserID is ignored (DEFAULT)
1144 userID == "" ... UserID set equal to 'this->uid'
1145 userID != "" ... UserID set equal to 'userID'
1146\end{verbatim}
1147}
1148\docparam{path}{{\it OPTIONAL.} Path to the table. Default is "".
1149Currently unused.}
1150
1151\wxheading{Remarks}
1152
1153The scope of privilege allowed to the connected user by a given table
1154privilege is data source dependent.
1155
1156For example, the privilege UPDATE might allow the connected user to update
1157all columns in a table on one data source, but only those columns for
1158which the grantor (the user that granted the connected user) has the UPDATE
1159privilege on another data source.
1160
1161
3ca6a5f0
BP
1162\membersection{wxDb::TranslateSqlState}\label{wxdbtranslatesqlstate}
1163
1164\func{int}{TranslateSqlState}{\param{const wxChar *}{SQLState}}
1165
1166\wxheading{Parameters}
1167
1168\docparam{SQLState}{Converts an ODBC sqlstate to an internal error code.}
1169
1170\wxheading{Return value}
1171
d0c6b305 1172Returns the internal class DB_ERR code. See \helpref{wxDb::DB_STATUS}{wxdb} definition.
3ca6a5f0 1173
eea22fd5 1174
3ca6a5f0
BP
1175\membersection{wxDb::WriteSqlLog}\label{wxdbwritesqllog}
1176
1177\func{bool}{WriteSqlLog}{\param{const wxChar *}{logMsg}}
1178
1179\wxheading{Parameters}
1180
1181\docparam{logMsg}{Free form string to be written to the log file.}
1182
1183\wxheading{Remarks}
1184
1185Very useful debugging tool that may be turned on/off during run time. The
1186passed in string {\it logMsg} will be written to a log file if SQL logging
1187is turned on (see \helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging} for details on turning logging on/off).
1188
1189\wxheading{Return value}
1190
1191If SQL logging is off when a call to WriteSqlLog() is made, or there is a
1192failure to write the log message to the log file, the function returns
1193FALSE without performing the requested log, otherwise TRUE is returned.
1194
1195\wxheading{See also}
1196
1197\helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging}
1198
3ca6a5f0 1199
eea22fd5 1200\section{\class{wxDbColDataPtr}}\label{wxdbcoldataptr}
3ca6a5f0 1201
eea22fd5
GT
1202Pointer to dynamic column definitions for use with a wxDbTable instance.
1203Currently there are no member functions for this class.
3ca6a5f0 1204
3ca6a5f0 1205\begin{verbatim}
eea22fd5
GT
1206 void *PtrDataObj;
1207 int SzDataObj;
1208 int SqlCtype;
3ca6a5f0
BP
1209\end{verbatim}
1210
3ca6a5f0 1211
eea22fd5 1212\section{\class{wxDbColDef}}\label{wxdbcoldef}
3ca6a5f0 1213
eea22fd5
GT
1214This class is used to hold information about the columns bound to an
1215instance of a wxDbTable object.
3ca6a5f0 1216
eea22fd5
GT
1217Each instance of this class describes one column in the wxDbTable
1218object. When calling the \helpref{wxDb constructor}{wxdbconstr}, a
1219parameter passed in indicates the number of columns that will be defined for
1220the wxDbTable object. The constructor uses this information to allocate
1221adequate memory for all of the column descriptions in your wxDbTable object.
1222Private member wxDbTable::colDefs is a pointer to this chunk of memory
1223maintained by the wxDbTable class (and can be retrieved using the
1224\helpref{wxDbTable::GetColDefs}{wxdbtablegetcoldefs} function).
1225To access the nth column definition of your wxDbTable object, just reference
1226wxDbColDefs element [n - 1].
3ca6a5f0 1227
eea22fd5 1228Currently there are no member functions for this class.
3ca6a5f0 1229
eea22fd5
GT
1230Typically, \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs} takes care of
1231populating an array of these data structures for the wxDbTable instance.
3ca6a5f0 1232
eea22fd5
GT
1233\begin{verbatim}
1234 char ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name
1235 int DbDataType; - Logical Data Type; e.g. DB_DATA_TYPE_INTEGER
1236 int SqlCtype; - C data type; e.g. SQL_C_LONG
1237 void *PtrDataObj; - Address of the data object
1238 int SzDataObj; - Size, in bytes, of the data object
1239 bool KeyField; - Is column part of the PRIMARY KEY for the
1240 table? -- Date fields should NOT be KeyFields
1241 bool Updateable; - Column is updateable?
1242 bool InsertAllowed; - Column included in INSERT statements?
1243 bool DerivedCol; - Column is a derived value?
1244 SDWORD CbValue; - !!!Internal use only!!!
1245 bool Null; - NOT FULLY IMPLEMENTED
1246 Allows NULL values in Inserts and Updates
1247\end{verbatim}
3ca6a5f0
BP
1248
1249\wxheading{See also}
1250
eea22fd5 1251\helpref{wxDbTable::GetColDefs}{wxdbtablegetcoldefs}, \helpref{wxDb constructor}{wxdbconstr}
3ca6a5f0 1252
3ca6a5f0 1253
d0c6b305
GT
1254\section{\class{wxDbColInf}}\label{wxdbcolinf}
1255
1256Used with the \helpref{wxDb::GetColumns}{wxdbgetcolumns} functions for obtaining all retrievable information about a columns definition.
1257
eea22fd5 1258
d0c6b305
GT
1259\section{\class{wxDbColFor}}\label{wxdbcolfor}
1260
1261Beginning support for handling international formatting specifically on dates and floats.
1262
1263Only one function is provided with this class currently:
1264
1265\membersection{wxDbColFor::Format}\label{wxdbcolforformat}
1266
1267\func{int}{Format}{\param{int }{Nation}, \param{int }{dbDataType}, \param{SWORD }{sqlDataType}, \param{short }{columnSize}, \param{short }{decimalDigits}}\label{wxdbcolforformat}
1268
1269Work in progress, and should be inter-related with wxLocale
1270
eea22fd5
GT
1271
1272\section{\class{wxDbIdxDef}}\label{wxdbidxdef}
1273
1274Used in creation of non-primary indexes. Currently there are no member
1275functions for this class.
1276
1277\begin{verbatim}
1278 char ColName[DB_MAX_COLUMN_NAME_LEN+1] - Name of column
1279 bool Ascending - Are the values in the index in ASCENDING sequence?
1280\end{verbatim}
1281
1282
d0c6b305
GT
1283\section{\class{wxDbInf}}\label{wxdbinf}
1284
1285Contains information regarding the database connection (data source name,
1286number of tables, etc). A pointer to a wxDbTableInf is included in this
1287class so a program can create a wxDbTableInf array instance to maintain all
1288information about all tables in the datasource to have all the datasource's
1289information in one memory structure.
1290
eea22fd5 1291
d0c6b305
GT
1292\section{\class{wxDbTable}}\label{wxdbtable}
1293
1294A wxDbTable instance provides re-usable access to rows of data in
1295a table contained within the associated ODBC data source
1296
1297\wxheading{Include files}
1298
1299<wx/dbtable.h>\\
1300<wx/db.h>
1301
1302\latexignore{\rtfignore{\wxheading{Members}}}
1303\wxheading{Helper classes and data structures}
1304
1305The following classes and structs are defined in dbtable.cpp/.h for use with the wxDbTable class.
eea22fd5
GT
1306\begin{itemize}\itemsep=0pt
1307\item \helpref{wxDbColDef}{wxdbcoldef}
1308\item \helpref{wxDbColDataPtr}{wxdbcoldataptr}
1309\item \helpref{wxDbIdxDef}{wxdbidxdef}
1310\end{itemize}
d0c6b305
GT
1311
1312\wxheading{Constants}
eea22fd5 1313
d0c6b305
GT
1314\begin{verbatim}
1315 wxDB_DEFAULT_CURSOR Index number of the cursor that each table will use
1316 by default.
3ca6a5f0 1317
d0c6b305
GT
1318 wxDB_QUERY_ONLY Used to indicate whether a table that is opened is
1319 for query only, or if insert/update/deletes will
1320 be performed on the table. Less overhead (cursors
1321 and memory) are allocated for query only tables, plus
1322 read access times are faster with some datasources.
3ca6a5f0 1323
d0c6b305
GT
1324 wxDB_ROWID_LEN [Oracle specific] - Used when CanUpdateByRowID() is
1325 true. Optimizes updates so they are faster by
1326 updating on the Oracle-specific ROWID column rather
1327 than some other index.
3ca6a5f0 1328
3ca6a5f0 1329
d0c6b305
GT
1330 wxDB_DISABLE_VIEW Use to indicate when a database view should not be
1331 if a table is normally set up to use a view.
1332 [Currently unsupported.]
1333
1334\end{verbatim}
3ca6a5f0 1335
d0c6b305 1336\wxheading{See also}
3ca6a5f0 1337
d0c6b305
GT
1338\helpref{wxDbTable}{wxdbtable}
1339
1340\latexignore{\rtfignore{\wxheading{Members}}}
1341
1342\membersection{wxDbTable::wxDbTable}\label{wxdbtableconstr}
1343
eea22fd5 1344\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}}
d0c6b305
GT
1345
1346Default constructor.
1347
1348\wxheading{Parameters}
1349
eea22fd5
GT
1350\docparam{pwxDb}{Pointer to the wxDb instance to be used by this wxDbTable
1351instance.}
1352\docparam{tblName}{The name of the table in the RDBMS.}
1353\docparam{nCols}{The number of columns in the table. (Do NOT include the ROWID
1354column in the count if using Oracle).}
1355\docparam{qryTblName}{{\it OPTIONAL}. The name of the table or view to base
1356your queries on. This argument allows you to specify a table/view other than
1357the base table for this object to base your queries on. This allows you to
1358query on a view for example, but all of the INSERT, UPDATE and DELETES will
1359still be performed on the base table for this wxDbTable object. Basing your
1360queries on a view can provide a substantial performance increase in cases where
1361your queries involve many tables with many joins. Default is 0 (NULL)}
1362\docparam{qryOnly}{{\it OPTIONAL}. Indicates whether the table will be
1363accessible for query purposes only, or should the table create the necessary
1364cursors to be able to insert, update, and delete data from the table.
1365Default is !wxDB_QUERY_ONLY.}
1366\docparam{tblPath}{{\it OPTIONAL}. Some data sources (such as dBase)
1367require a path to where the table is stored on the system. Default is NULL.}
d0c6b305
GT
1368
1369\membersection{wxDbTable::wxDbTable}\label{wxdbtabledestr}
1370
1371\func{virtual}{\destruct{wxDbTable}}{}
1372
1373Virtual default destructor.
1374
1375
1376\membersection{wxDbTable::BuildDeleteStmt}\label{wxdbtablebuilddeletestmt}
1377
eea22fd5
GT
1378\func{void}{BuildDeleteStmt}{\param{char *}{pSqlStmt}, \param{int }{typeOfDel}, \param{const char *}{pWhereClause=0}}
1379
1380Constructs the full SQL statement that can be used to delete all rows matching
1381the criteria in the pWhereClause.
d0c6b305
GT
1382
1383\wxheading{Parameters}
1384
eea22fd5
GT
1385\docparam{pSqlStmt}{Pointer to storage for the SQL statement retrieved. To be
1386sure you have adequate space allocated for the SQL statement, allocate
1387DB_MAX_STATEMENT_LEN bytes.}
1388\docparam{typeOfDel}{The type of delete statement being performed. Can be one
1389of three values: DB_DEL_KEYFIELDS, DB_DEL_WHERE or DB_DEL_MATCHING}
1390\docparam{pWhereClause}{{\it OPTIONAL}. If the typeOfDel is DB_DEL_WHERE,
1391then you must also pass in a SQL WHERE clause in this argument. Default
1392is 0 (NULL).}
1393
1394\wxheading{Remarks}
1395
1396This member function allows you to see what the SQL DELETE statement looks like
1397that the ODBC class library builds. This can be used for debugging purposes if
1398you are having problems executing your SQL statement.
1399
1400WHERE and FROM clauses specified in \helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
1401and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by
1402this function.
d0c6b305
GT
1403
1404
1405\membersection{wxDbTable::BuildSelectStmt}\label{wxdbtablebuildselectstmt}
1406
1407\func{void}{BuildSelectStmt}{\param{char *}{pSqlStmt}, \param{int }{typeOfSelect}, \param{bool }{distinct}}
1408
eea22fd5
GT
1409Constructs the full SQL statement that can be used to select all rows matching
1410the criteria in the pWhereClause. Internal to the wxDbTable class, this
1411function is called whenever the function \helpref{wxDbTable::Query}{wxdbtablequery}
1412is called.
1413
1414NOTE: Only the columns specified in \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}
1415statements are included in the list of columns returned by the SQL statement
1416created by a call to this function.
1417
d0c6b305
GT
1418\wxheading{Parameters}
1419
eea22fd5
GT
1420\docparam{pSqlStmt}{Pointer to storage for the SQL statement retrieved. To be
1421sure you have adequate space allocated for the SQL statement, allocate
1422DB_MAX_STATEMENT_LEN bytes.}
1423\docparam{typeOfSelect}{The type of select statement being performed. Can be
1424one of four values: DB_SELECT_KEYFIELDS, DB_SELECT_WHERE, DB_SELECT_MATCHING
1425or DB_SELECT_STATEMENT.}
1426\docparam{distinct}{Whether to select distinct records only.}
1427
1428\wxheading{Remarks}
1429
1430This member function allows you to see what the SQL SELECT statement looks like
1431that the ODBC class library builds. This can be used for debugging purposes if
1432you are having problems executing your SQL statement.
1433
1434WHERE and FROM clauses specified in \helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
1435and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by
1436this function.
d0c6b305
GT
1437
1438
1439\membersection{wxDbTable::BuildUpdateStmt}\label{wxdbtablebuildupdatestmt}
1440
1441\func{void}{BuildSelectStmt}{\param{char *}{pSqlStmt}, \param{int }{typeOfUpd}, \param{const char *}{pWhereClause=0}}
1442
eea22fd5
GT
1443Constructs the full SQL statement that can be used to update all rows matching
1444the criteria in the pWhereClause.
1445
1446If typeOfUpd is DB_UPD_KEYFIELDS, then the current values in the bound columns
1447are used to determine which row(s) in the table are to be updated. The
1448exception to this is when a data source supports ROW IDs (Oracle). The ROW ID
1449column is used for efficiency purposes when available.
1450
1451NOTE: Only the columns specified in \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}
1452statements are included in the list of columns updated by the SQL statement
1453created by a call to this function. Any column definitions that were defined
1454as being non-updateable will be excluded from the SQL UPDATE statement created
1455by this function.
1456
d0c6b305
GT
1457\wxheading{Parameters}
1458
eea22fd5
GT
1459\docparam{pSqlStmt}{Pointer to storage for the SQL statement retrieved. To be
1460sure you have adequate space allocated for the SQL statement, allocate
1461DB_MAX_STATEMENT_LEN bytes.}
1462\docparam{typeOfUpd}{The type of update statement being performed. Can be one
1463of two values: DB_UPD_KEYFIELDS or DB_UPD_WHERE.}
1464\docparam{pWhereClause}{{\it OPTIONAL}. If the typeOfUpd is DB_UPD_WHERE,
1465then you must also pass in a SQL WHERE clause in this argument. Default
1466is 0 (NULL).}
1467
1468\wxheading{Remarks}
1469
1470This member function allows you to see what the SQL UPDATE statement looks like
1471that the ODBC class library builds. This can be used for debugging purposes if
1472you are having problems executing your SQL statement.
1473
1474WHERE and FROM clauses specified in \helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
1475and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by
1476this function.
d0c6b305
GT
1477
1478
1479\membersection{wxDbTable::BuildWhereStmt}\label{wxdbtablebuildwherestmt}
1480
1481\func{void}{BuildSelectStmt}{\param{char *}{pWhereClause}, \param{int }{typeOfWhere}, \param{const char *}{qualTableName=0}, \param{const char *}{useLikeComparison=FALSE}}
1482
eea22fd5
GT
1483Constructs the portion of a SQL statement which would follow the word 'WHERE'
1484in the SQL statement to be passed to the data source. The returned string
1485does NOT include the word 'WHERE'.
1486
d0c6b305
GT
1487\wxheading{Parameters}
1488
eea22fd5
GT
1489\docparam{pWhereClause}{Pointer to storage for the SQL statement retrieved.
1490To be sure you have adequate space allocated for the SQL statement, allocate
1491DB_MAX_STATEMENT_LEN bytes.}
1492\docparam{typeOfWhere}{The type of where clause to generate. Can be one of
1493two values: DB_WHERE_KEYFIELDS or DB_WHERE_MATCHING.}
1494\docparam{qualTableName}{{\it OPTIONAL}. Prepended to all base table
1495column names. For use when a FROM clause has been specified with the
1496\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause},
1497to clarify which table a column name reference belongs to. Default is 0
1498(NULL).}
1499\docparam{useLikeComparison}{{\it OPTIONAL}. Should the constructed WHERE
1500clause utilize the LIKE comparison operator. If FALSE, then the '='
1501operator is used. Default is FALSE.}
1502
1503\wxheading{Remarks}
1504
1505This member function allows you to see what the SQL WHERE clause looks like
1506that the ODBC class library builds. This can be used for debugging purposes
1507if you are having problems executing your SQL statements.
1508
1509If using 'typeOfWhere' set to DB_WHERE_MATCHING, any bound columns currently
1510containing a NULL value are not included in the WHERE clause's list of
1511columns to use in the comparison.
d0c6b305
GT
1512
1513
1514\membersection{wxDbTable::CanSelectForUpdate}\label{wxdbtablecanselectforupdate}
1515
1516\func{bool}{CanSelectForUpdate}{\void}
1517
eea22fd5
GT
1518Use this function to determine if the data source supports SELECT ... FOR UPDATE.
1519When the keywords "FOR UPDATE" are included as part of your SQL SELECT statement,
1520all records retrieved from the query are locked.
1521
d0c6b305
GT
1522\wxheading{Remarks}
1523
eea22fd5
GT
1524Not all data sources support the "FOR UPDATE" clause, so you must use this
1525member function to determine if the data source currently connected to supports
1526this behavior or not before trying to select using "FOR UPDATE".
1527
d0c6b305
GT
1528
1529\membersection{wxDbTable::CanUpdateByROWID}\label{wxdbtablecanupdatebyrowid}
1530
1531\func{bool}{CanUpdateByROWID}{\void}
1532
eea22fd5
GT
1533CURRENTLY ONLY POSSIBLE IF USING ORACLE.
1534
1535--- CURRENTLY DISABLED FOR *ALL* DATASOURCES --- NOV 1 2000 - gt
1536
1537Every Oracle table has a hidden column named ROWID. This is a pointer to the
1538physical location of the record in the data store and allows for very fast
1539updates and deletes. The key is to retrieve this ROWID during your query so
1540it is available during an update or delete operation.
1541
1542This is always handled by the class library except in the case of
1543QueryBySqlStatement(). Since you are passing in the SQL SELECT statement,
1544it is up to you to include the ROWID column in your query. If you do not,
1545the application will still work, but may not be as optimized. The ROWID is
1546always the last column in the column list in your SQL SELECT statement.
1547The ROWID is not a column in the normal sense and should not be considered
1548part of the column definitions for the wxDbTable object.
1549
d0c6b305
GT
1550\wxheading{Remarks}
1551
eea22fd5
GT
1552The decision to include the ROWID in your SQL SELECT statement must be
1553deferred until runtime since it depends on whether you are connected
1554to an Oracle data source or not.
1555
1556\wxheading{Example}
1557
1558\begin{verbatim}
1559 // Incomplete code sample
1560 wxDbTable parts;
1561 .....
1562 if (parts.CanUpdByROWID())
1563 begin
1564 // Note that the ROWID column must always be the last column selected
1565 sqlStmt = "SELECT PART_NO, PART_DESC, ROWID" FROM PARTS";
1566 end
1567 else
1568 sqlStmt = "SELECT PART_NO, PART_DESC" FROM PARTS";
1569\end{verbatim}
1570
d0c6b305
GT
1571
1572\membersection{wxDbTable::ClearMemberVars}\label{wxdbtableclearmembervars}
1573
1574\func{void}{ClearMemberVars}{\void}
1575
eea22fd5
GT
1576Initializes all of the bound columns of the wxDbTable instance to zero.
1577In the case of a string, zero is copied to the first byte of the string.
1578
d0c6b305
GT
1579\wxheading{Remarks}
1580
eea22fd5
GT
1581This is useful before calling \helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
1582\helpref{wxDbTable::DeleteMatching}{wxdbtabledeletematching} since these
1583functions build their WHERE clauses from non-zero columns. To call either
1584\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
1585\helpref{wxDbTable::DeleteMatching}{wxdbtabledeletematching} use this sequence:
1586
1587\begin{verbatim}
15881) ClearMemberVars()
15892) Assign columns values you wish to match on
15903) Call wxDbTable::QueryMatching() or wxDbTable::DeleteMatching()
1591\end{verbatim}
d0c6b305
GT
1592
1593\membersection{wxDbTable::CloseCursor}\label{wxdbtableclosecursor}
1594
1595\func{bool}{CloseCursor}{\param{HSTMT}{cursor}}
1596
eea22fd5
GT
1597Closes the specified cursor associated with the wxDbTable object.
1598
d0c6b305
GT
1599\wxheading{Parameters}
1600
eea22fd5 1601\docparam{cursor}{The cursor to be closed.}
d0c6b305
GT
1602
1603\wxheading{Remarks}
1604
eea22fd5
GT
1605Typically handled internally by the ODBC class library, but may be used by the
1606programmer if desired.
1607
d0c6b305
GT
1608
1609\membersection{wxDbTable::Count}\label{wxdbtablecount}
1610
1611\func{ULONG}{Count}{\param{const char *}{args="*"}}
1612
eea22fd5
GT
1613Returns the number of records which would be in the result set using the
1614current query parameters specified in the WHERE and FROM clauses.
1615
d0c6b305
GT
1616\wxheading{Parameters}
1617
eea22fd5
GT
1618\docparam{args}{{\it OPTIONAL}. This arguement allows the use of the
1619DISTINCT keyword against a column name to cause the returned count to
1620only indicate the number of rows in the result set that have a unique
1621value in the specified column. An example is shown below. Default is "*",
1622meaning a count of the total number of rows is returned, regardless of
1623uniqueness.}
d0c6b305
GT
1624
1625\wxheading{Remarks}
1626
eea22fd5
GT
1627This function can be called before or after an actual query to obtain the
1628count of records in the result set. Count() uses its own cursor, so result
1629set cursor positioning is not affected by calls to Count().
1630
1631\wxheading{Example}
1632
1633\begin{verbatim}
1634
1635 USERS TABLE
1636
1637 FIRST_NAME LAST_NAME
1638 ----------- ----------
1639 John Doe
1640 Richard Smith
1641 Michael Jones
1642 John Carpenter
1643
1644 // Incomplete code sample
1645 wxDbTable users;
1646 .....
1647 users.SetWhereClause("");
1648
1649 // This Count() will return 4, as there are four users listed above
1650 // that match the query parameters
1651 totalNumberOfUsers = users.Count();
1652
1653 // This Count() will return 3, as there are only 3 unique first names
1654 // in the table above - John, Richard, Michael.
1655 totalNumberOfUniqueFirstNames = users.Count("DISTINCT FIRST_NAME");
1656\end{verbatim}
1657
d0c6b305
GT
1658
1659\membersection{wxDbTable::CreateIndex}\label{wxdbtablecreateindex}
1660
eea22fd5
GT
1661\func{bool}{CreateIndex}{\param{const char *}{idxName}, \param{bool }{unique}, \param{int }{noIdxCols}, \param{wxDbIdxDef *}{pIdxDefs}, \param{bool }{attemptDrop=TRUE}}
1662
1663This member function allows you to create secondary (non primary) indexes on
1664your tables. You first create your table, normally specifying a primary
1665index, and then create any secondary indexes on the table. Indexes in
1666relational model are not required. You do not need indexes to look up records
1667in a table or to join two tables together. In the relational model, indexes,
1668if available, provide a quicker means to look up data in a table. To enjoy
1669the performance benefits of indexes, the indexes must be defined on the
1670appropriate columns and your SQL code must be written in such a way as to
1671take advantage of those indexes.
d0c6b305
GT
1672
1673\wxheading{Parameters}
1674
eea22fd5
GT
1675\docparam{idxName}{Name of the Index. Name must be unique within the table space of the datasource.}
1676\docparam{unique}{Indicates if this index is unique.}
1677\docparam{noIdxCols}{Number of columns in the index.}
1678\docparam{pIdxDefs}{A pointer to an array wxDbIdxDef structures. }
1679\docparam{attemptDrop}{{\it OPTIONAL}. Indicates if the function should try
1680to execute a \helpref{wxDbTable::DropIndex}{wxdbtabledropindex} on the index
1681name provided before trying to create the index name. Default is TRUE.}
d0c6b305
GT
1682
1683\wxheading{Remarks}
1684
eea22fd5
GT
1685The first parameter, index name, must be unique and should be given a
1686meaningful name. Common practice is to include the table name as a prefix
1687in the index name (e.g. PARTS_IDX1). This will allow you to easily view all
1688of the indexes defined for a given table grouped together alphabetically.
1689
1690The second parameter indicates if the index is unique or not. Uniqueness
1691is enforced at the RDBMS level controlling whether duplicates cannot be
1692inserted into the table for unique indices.
1693
1694In the third parameter, specify how many columns are in your index. This
1695number must match the number of columns defined in the 'pIdxDefs' parameter.
1696
1697The fourth parameter specifies which columns make up the index using the
1698wxDbIdxDef structure. For each column in the index, you must specify two
1699things, the column name and the sort order (ascending / descending). See
1700the example below to see how to build and pass in the wxDbIdxDef structure.
1701
1702The fifth parameter is provided as many datasources will not automatically
1703overwrite existing indexes with the same name. They require that the
1704existing index must be dropped first, so this is the default behavior.
1705
1706Some datasources (MySQL, and possibly others) require columns which are to be
1707part of an index to be defined as NOT NULL. When this function is called, if
1708a column is not defined to be NOT NULL, this function will modify the column
1709definition to change the column to be NOT NULL.
1710
1711PostGres is unable to handle index definitions which specify whether the index
1712is ascending or descending, and defaults to the system default when the index
1713is created.
1714
1715It is not necessary to call \helpref{wxDb::CommitTrans}{wxdbcommittrans}
1716after executing this function.
1717
1718\wxheading{Example}
1719
1720\begin{verbatim}
1721 // Create a secondary index on the PARTS table
1722 wxDbIdxDef idxDef[2]; // 2 columns make up the index
1723
1724 strcpy(idxDef[0].ColName, "PART_DESC"); // Column 1
1725 idxDef[0].Ascending = TRUE;
1726
1727 strcpy(idxDef[1].ColName, "SERIAL_NO"); // Column 2
1728 idxDef[1].Ascending = FALSE;
1729
1730 // Create a name for the index based on the table's name
1731 wxString indexName;
1732 indexName.sprintf("%s_IDX1",parts->GetTableName());
1733 parts->CreateIndex(indexName.c_str(), TRUE, 2, idxDef);
1734\end{verbatim}
1735
1736
d0c6b305
GT
1737\membersection{wxDbTable::CreateTable}\label{wxdbtablecreatetable}
1738
1739\func{bool}{CreateTable}{\param{bool }{attemptDrop=TRUE}}
1740
eea22fd5
GT
1741Creates a table based on the definitions previously defined for this
1742wxDbTable instance.
1743
d0c6b305
GT
1744\wxheading{Parameters}
1745
eea22fd5 1746\docparam{attemptDrop}{{\it OPTIONAL}. Default is TRUE.}
d0c6b305
GT
1747
1748\wxheading{Remarks}
1749
eea22fd5
GT
1750This function creates the table and primary index (if any) in the table space
1751associated with the connected data source. The owner of these objects will
1752be the user id that was given when \helpref{wxDb::Open}{wxdbopen} was called. The objects will
1753be created in the default schema for that user.
d0c6b305 1754
eea22fd5
GT
1755In your derived wxDbTable object constructor, the columns and primary index
1756of the table are described through the wxDbColDef structure.
1757\helpref{wxDbTable::CreateTable}{wxdbtablecreatetable} uses this information to create the table and to add
1758the primary index. See \helpref{wxDbTable}{wxdbtable} ctor and wxDbColDef
1759description for additional information on describing the columns of the table.
d0c6b305 1760
eea22fd5
GT
1761It is not necessary to call \helpref{wxDb::CommitTrans}{wxdbcommittrans}
1762after executing this function.
d0c6b305 1763
d0c6b305 1764
eea22fd5 1765\membersection{wxDbTable::DB_STATUS}\label{wxdbtabledbstatus}
d0c6b305 1766
eea22fd5 1767\func{bool}{DB_STATUS}{\void}
d0c6b305 1768
eea22fd5
GT
1769Accessor function that returns the wxDb private member variable DB_STATUS for
1770the database connection used by this instance of wxDbTable.
d0c6b305 1771
d0c6b305
GT
1772
1773\membersection{wxDbTable::Delete}\label{wxdbtabledelete}
1774
1775\func{bool}{Delete}{\void}
1776
eea22fd5
GT
1777Deletes the current record from the data source.
1778
d0c6b305
GT
1779\wxheading{Remarks}
1780
eea22fd5
GT
1781Use \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst}, \helpref{wxDbTable::GetLast}{wxdbtablegetlast},
1782\helpref{wxDbTable::GetNext}{wxdbtablegetnext} or
1783\helpref{wxDbTable::GetPrev}{wxdbtablegetprev} to position the cursor to
1784a valid record. Once positioned on a record, call this function to delete
1785the row from the table.
1786
1787A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
1788\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
1789this function to commit or rollback the deletion.
1790
1791NOTE: Most datasources have a limited size "rollback" segment. This means
1792that it is only possible to insert/update/delete a finite number of rows
1793without performing a \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
1794\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans}. Size of the rollback
1795segment varies from database to database, and is user configurable in
1796most databases. Therefore it is usually best to try to perform a commit
1797or rollback at relatively small intervals when processing a larger number
1798of actions that insert/update/delete rows in a table.
1799
1800
d0c6b305
GT
1801\membersection{wxDbTable::DeleteCursor}\label{wxdbtabledeletecursor}
1802
eea22fd5
GT
1803\func{bool}{DeleteCursor}{\param{HSTMT *}{hstmtDel}}
1804
1805Allows a program to delete a cursor.
d0c6b305
GT
1806
1807\wxheading{Parameters}
1808
eea22fd5
GT
1809\docparam{hstmtDel}{Handle of the cursor to delete.}
1810
1811\wxheading{Remarks}
1812
1813For default cursors associated with the instance of wxDbTable, it is not
1814necessary to specifically delete the cursors. This is automatically done
1815in the wxDbTable destructor.
1816
1817NOTE: If the cursor could not be deleted for some reason, an error is logged
1818indicating the reason. Even if the cursor could not be deleted, the HSTMT
1819that is passed in is deleted, and the pointer is set to NULL.
1820
1821
1822\membersection{wxDbTable::DeleteMatching}\label{wxdbtabledeletematching}
1823
1824\func{bool}{DeleteMatching}{\void}
1825
1826This member function allows you to delete records from your wxDbTable object
1827by specifying the data to match in the columns to match on.
d0c6b305
GT
1828
1829\wxheading{Remarks}
1830
eea22fd5
GT
1831To delete all users with a first name of "JOHN", do the following:
1832
1833\begin{verbatim}
1834 1) Clear all "columns" using \helpref{wxDbTable::ClearMemberVars}{wxdbtableclearmembervars}.
1835 2) Set the FIRST_NAME column equal to "JOHN".
1836 3) Call \helpref{wxDbTable::DeleteMatching}{wxdbtabledeletematching}.
1837\end{verbatim}
1838
1839The WHERE clause is built by the ODBC class library based on all non-zero
1840columns. This allows deletion of records by matching on any column(s)
1841in your wxDbTable instance, without having to write the SQL WHERE clause.
1842
1843A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
1844\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
1845this function to commit or rollback the deletion.
1846
1847NOTE: Row(s) should be locked before deleting them to make sure they are
1848not already in use. This can be achieved by calling \helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching},
1849and then scrolling through the records locking each as you go. After the
1850row(s) have been successfully locked, call this function.
1851
1852NOTE: Most datasources have a limited size "rollback" segment. This means
1853that it is only possible to insert/update/delete a finite number of rows
1854without performing a \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
1855\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans}. Size of the rollback
1856segment varies from database to database, and is user configurable in
1857most databases. Therefore it is usually best to try to perform a commit
1858or rollback at relatively small intervals when processing a larger number
1859of actions that insert/update/delete rows in a table.
1860
1861
1862\wxheading{Example}
1863
1864\begin{verbatim}
1865 // Incomplete code sample to delete all users with a first name
1866 // of "JOHN"
1867 users.ClearMemberVars();
1868 strcpy(users.FirstName,"JOHN");
1869 users.DeleteMatching();
1870\end{verbatim}
1871
1872
d0c6b305
GT
1873\membersection{wxDbTable::DeleteWhere}\label{wxdbtabledeletewhere}
1874
1875\func{bool}{DeleteWhere}{\param{const char *}{pWhereClause}}
1876
eea22fd5
GT
1877Deletes all rows from the table which match the criteria specified in the
1878WHERE clause that is passed in as the sole parameter.
1879
d0c6b305
GT
1880\wxheading{Parameters}
1881
eea22fd5
GT
1882\docparam{pWhereClause}{SQL WHERE clause. This WHERE clause determines which
1883records will be deleted from the table interfaced through the wxDbTable
1884instance. The WHERE clause passed in must be compliant with the SQL 92
1885grammar. Do not include the keyword 'WHERE'
1886}
d0c6b305
GT
1887
1888\wxheading{Remarks}
1889
eea22fd5
GT
1890This is the most powerful form of the wxDbTable delete functions. This
1891function gives access to the full power of SQL. This function can be used
1892to delete records by passing a valid SQL WHERE clause. Sophisticated
1893deletions can be performed based on multiple criteria using the full
1894functionality of the SQL language.
d0c6b305 1895
eea22fd5
GT
1896A \helpref{wxDb::CommitTrans}{wxdbcommittrans} must be called after use of
1897this function to commit the deletions.
1898
1899Note: This function is limited to deleting records from the table associated
1900with this wxDbTable object only. Deletions on joined tables is not possible.
1901
1902NOTE: Most datasources have a limited size "rollback" segment. This means
1903that it is only possible to insert/update/delete a finite number of rows
1904without performing a \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
1905\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans}. Size of the rollback
1906segment varies from database to database, and is user configurable in
1907most databases. Therefore it is usually best to try to perform a commit
1908or rollback at relatively small intervals when processing a larger number
1909of actions that insert/update/delete rows in a table.
1910
1911\wxheading{Example}
1912
1913\begin{verbatim}
1914 // Delete parts 1 thru 10 from containers 'X', 'Y' and 'Z' that
1915 // are magenta in color
1916 parts.DeleteWhere("(PART_NUMBER BETWEEN 1 AND 10) AND \
1917 CONTAINER IN ('X', 'Y', 'Z') AND \
1918 UPPER(COLOR) = 'MAGENTA'");
1919\end{verbatim}
d0c6b305 1920
d0c6b305
GT
1921
1922\membersection{wxDbTable::DropIndex}\label{wxdbtabledropindex}
1923
1924\func{bool}{DropIndex}{\param{const char *}{idxName}}
1925
eea22fd5
GT
1926Allows an index on the associated table to be dropped (deleted) if the user
1927login has sufficient privileges to do so.
1928
d0c6b305
GT
1929\wxheading{Parameters}
1930
eea22fd5 1931\docparam{idxName}{Name of the index to be dropped.}
d0c6b305
GT
1932
1933\wxheading{Remarks}
1934
eea22fd5
GT
1935If the index specified in the 'idxName' parameter does not exist, an error
1936will be logged, and the function will return a result of FALSE.
1937
1938It is not necessary to call \helpref{wxDb::CommitTrans}{wxdbcommittrans}
1939after executing this function.
1940
1941
d0c6b305
GT
1942\membersection{wxDbTable::DropTable}\label{wxdbtabledroptable}
1943
1944\func{bool}{DropTable}{\void}
1945
eea22fd5
GT
1946Deletes the associated table if the user has sufficient privileges to do so.
1947
d0c6b305
GT
1948\wxheading{Remarks}
1949
eea22fd5
GT
1950This function returns TRUE if the table does not exist, but only for
1951supported databases (see \helpref{wxDb::Dbms}{wxdbdbms}). If a datasource
1952is not specifically supported, and this function is called, the function
1953will return FALSE.
1954
1955Some datasources/ODBC drivers will delete any indexes associated with the
1956table automatically, and others may not. Check the documentation for your
1957database to determine the behavior.
1958
1959It is not necessary to call \helpref{wxDb::CommitTrans}{wxdbcommittrans}
1960after executing this function.
1961
1962
1963\membersection{wxDbTable::From}\label{wxdbtablefrom}
1964
1965\func{const char *}{From}{}
1966\func{void}{From}{\param{const wxString &}{From}}
1967
1968Accessor function for the private class member wxDbTable::from. Can be used
1969as a synonym for \helpref{wxDbTable::GetFromClause}{wxdbtablegetfromclause}
1970(the first form of this function) or
1971\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} (the second form
1972of this function).
1973
1974\wxheading{Parameters}
1975
1976\docparam{From}{A comma separated list of table names that are to be outer
1977joined with the base table's columns so that the joined table's columns
1978may be returned in the result set or used as a portion of a comparison with
1979the base table's columns. NOTE that the base tables name must NOT be included
1980in the FROM clause, as it is automatically included by the wxDbTable class
1981in constructing query statements.}
1982
1983\wxheading{Return value}
1984
1985The first form of this function returns the current value of the wxDbTable
1986member variable ::from.
1987
1988The second form of the function has no return value.
1989
1990\wxheading{See also}
1991
1992\helpref{wxDbTable::GetFromClause}{wxdbtablegetfromclause},
1993\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}
1994
1995
d0c6b305
GT
1996\membersection{wxDbTable::GetColDefs}\label{wxdbtablegetcoldefs}
1997
1998\func{wxDbColDef *}{GetColDefs}{}
1999
eea22fd5
GT
2000Accessor function that returns a pointer to the array of column definitions
2001that are bound to the columns that this wxDbTable instance is associated
2002with.
2003
2004To determine the number of elements pointed to by the returned
2005\helpref{wxDbColDef}{wxdbcoldef} pointer, use the
2006\helpref{wxDbTable::GetNumberOfColumns}{wxdbtablegetnumberofcolumns} function.
2007
d0c6b305
GT
2008\wxheading{Remarks}
2009
eea22fd5
GT
2010These column definitions must not be manually redefined after they have been
2011set.
2012
2013
d0c6b305
GT
2014\membersection{wxDbTable::GetCursor}\label{wxdbtablegetcursor}
2015
2016\func{HSTMT}{GetCursor}{\void}
2017
eea22fd5
GT
2018Returns the HSTMT value of the current cursor for this wxDbTable object.
2019
d0c6b305
GT
2020\wxheading{Remarks}
2021
eea22fd5
GT
2022This function is typically used just before changing to use a different cursor
2023so that after the program is finished using the other cursor, the current
2024cursor can be set back to being the cursor in use.
2025
2026\wxheading{See also}
2027
2028\helpref{wxDbTable::SetCursor}{wxdbtablesetcursor}, \helpref{wxDbTable::GetNewCursor}{wxdbtablegetnewcursor}
2029
2030
d0c6b305
GT
2031\membersection{wxDbTable::GetDb}\label{wxdbtablegetdb}
2032
2033\func{wxDb *}{GetDb}{}
2034
eea22fd5
GT
2035Accessor function for the private member variable pDb which is a pointer to
2036the datasource connection that this wxDbTable instance uses.
d0c6b305 2037
d0c6b305
GT
2038
2039\membersection{wxDbTable::GetFirst}\label{wxdbtablegetfirst}
2040
2041\func{bool}{GetFirst}{\void}
2042
eea22fd5
GT
2043Retrieves the FIRST row in the record set as defined by the current query.
2044Before retrieving records, a query must be performed using
2045\helpref{wxDbTable::Query}{wxdbtablequery},
2046\helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields},
2047\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
2048\helpref{wxDbTable::QueryBySqlStmt}{wxdbtablequerybysqlstmt}.
2049
d0c6b305
GT
2050\wxheading{Remarks}
2051
eea22fd5
GT
2052This function can only be used if the datasource connection used by the
2053wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the
2054connection does not allow backward scrolling cursors, this function will
2055return FALSE, and the data contained in the bound columns will be undefined.
d0c6b305
GT
2056
2057\wxheading{See also}
2058
2059\helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors}
2060
eea22fd5 2061
d0c6b305
GT
2062\membersection{wxDbTable::GetFromClause}\label{wxdbtablegetfromclause}
2063
2064\func{const char *}{GetFromClause}{}
2065
eea22fd5
GT
2066Accessor function that returns the current FROM setting assigned with the
2067\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}.
2068
2069\wxheading{See also}
2070
2071\helpref{wxDbTable::From}{wxdbtablefrom}
2072
d0c6b305
GT
2073
2074\membersection{wxDbTable::GetLast}\label{wxdbtablegetlast}
2075
2076\func{bool}{GetLast}{\void}
2077
eea22fd5
GT
2078Retrieves the LAST row in the record set as defined by the current query.
2079Before retrieving records, a query must be performed using
2080\helpref{wxDbTable::Query}{wxdbtablequery},
2081\helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields},
2082\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
2083\helpref{wxDbTable::QueryBySqlStmt}{wxdbtablequerybysqlstmt}.
2084
d0c6b305
GT
2085\wxheading{Remarks}
2086
eea22fd5
GT
2087This function can only be used if the datasource connection used by the
2088wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the
2089connection does not allow backward scrolling cursors, this function will
2090return FALSE, and the data contained in the bound columns will be undefined.
d0c6b305
GT
2091
2092\wxheading{See also}
2093
2094\helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors}
2095
eea22fd5 2096
d0c6b305
GT
2097\membersection{wxDbTable::GetNewCursor}\label{wxdbtablegetnewcursor}
2098
2099\func{HSTMT *}{GetNewCursor}{\param{bool }{setCursor=FALSE}, \param{bool }{bindColumns=TRUE}}
2100
eea22fd5
GT
2101\begin{comment}
2102% George: @@@@@@@@STILL TO DO
2103\end{comment}
2104
d0c6b305
GT
2105\wxheading{Parameters}
2106
eea22fd5
GT
2107\docparam{setCursor}{{\it OPTIONAL}. Default is FALSE.}
2108\docparam{bindColumns}{{\it OPTIONAL}. Default is TRUE.}
d0c6b305
GT
2109
2110\wxheading{Remarks}
2111
eea22fd5 2112
d0c6b305
GT
2113\membersection{wxDbTable::GetNext}\label{wxdbtablegetnext}
2114
2115\func{bool}{GetNext}{\void}
2116
eea22fd5
GT
2117Retrieves the NEXT row in the record set after the current cursor position
2118as defined by the current query. Before retrieving records, a query must be
2119performed using \helpref{wxDbTable::Query}{wxdbtablequery},
2120\helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields},
2121\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
2122\helpref{wxDbTable::QueryBySqlStmt}{wxdbtablequerybysqlstmt}.
2123
2124\wxheading{Return value}
2125
2126This function returns FALSE when the current cursor has reached the end of
2127the result set. When FALSE is returned, data in the bound columns is
2128undefined.
2129
2130\wxheading{See also}
2131\helpref{wxDbTable::++}{wxdbtableplusplus}
d0c6b305
GT
2132
2133
2134\membersection{wxDbTable::GetNumberOfColumns}\label{wxdbtablegetnumberofcolumns}
2135
2136\func{bool}{GetNumberOfColumns}{}
2137
eea22fd5
GT
2138Accessor function that returns the number of columns that are statically
2139bound for access by the wxDbTable instance.
2140
d0c6b305
GT
2141
2142\membersection{wxDbTable::GetOrderByClause}\label{wxdbtablegetorderbyclause}
2143
2144\func{const char *}{GetOrderByClause}{}
2145
eea22fd5
GT
2146Accessor function that returns the current ORDER BY setting assigned with
2147the \helpref{wxDbTable::SetOrderByClause}{wxdbtablesetorderbyclause}.
2148
2149\wxheading{See also}
2150
2151\helpref{wxDbTable::OrderBy}{wxdbtableorderby}
2152
d0c6b305
GT
2153
2154\membersection{wxDbTable::GetPrev}\label{wxdbtablegetprev}
2155
2156\func{bool}{GetPrev}{\void}
2157
eea22fd5
GT
2158Retrieves the PREVIOUS row in the record set before the current cursor
2159position as defined by the current query. Before retrieving records, a
2160query must be performed using \helpref{wxDbTable::Query}{wxdbtablequery},
2161\helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields},
2162\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
2163\helpref{wxDbTable::QueryBySqlStmt}{wxdbtablequerybysqlstmt}.
2164
2165\wxheading{Return value}
2166
2167This function returns FALSE when the current cursor has reached the beginning
2168of the result set and there are now other rows prior to the cursors current
2169position. When FALSE is returned, data in the bound columns is undefined.
2170
d0c6b305
GT
2171\wxheading{Remarks}
2172
eea22fd5
GT
2173This function can only be used if the datasource connection used by the
2174wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the
2175connection does not allow backward scrolling cursors, this function will
2176return FALSE, and the data contained in the bound columns will be undefined.
d0c6b305
GT
2177
2178\wxheading{See also}
2179
eea22fd5
GT
2180\helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors},
2181\helpref{wxDbTable::--}{wxdbtableminusminus}
d0c6b305
GT
2182
2183
2184\membersection{wxDbTable::GetQueryTableName}\label{wxdbtablegetquerytablename}
2185
2186\func{const char *}{GetQueryTableName}{}
2187
eea22fd5
GT
2188Accessor function that returns the name of the table/view that was indicated
2189as being the table/view to query against when this wxDbTable instance was
2190created.
2191
2192\wxheading{See also}
2193
2194\helpref{wxDbTable constructor}{wxdbtableconstr}
2195
d0c6b305
GT
2196
2197\membersection{wxDbTable::GetRowNum}\label{wxdbtablegetrownum}
2198
2199\func{UWORD}{GetRowNum}{\void}
2200
eea22fd5
GT
2201Returns the ODBC row number for performing positioned updates and deletes.
2202
d0c6b305
GT
2203\wxheading{Remarks}
2204
eea22fd5
GT
2205This function is not being used within the ODBC class library and may be a
2206candidate for removal if no use is found for it.
2207
2208
d0c6b305
GT
2209\membersection{wxDbTable::GetTableName}\label{wxdbtablegettablename}
2210
2211\func{const char *}{GetTableName}{}
2212
eea22fd5
GT
2213Accessor function that returns the name of the table that was indicated
2214as being the table that this wxDbTable instance was associated with.
2215
d0c6b305
GT
2216
2217\membersection{wxDbTable::GetTablePath}\label{wxdbtablegettablepath}
2218
2219\func{const char *}{GetTablePath}{}
2220
eea22fd5
GT
2221Accessor function that returns the path to the data table that was indicated
2222during creation of this wxDbTable instance.
2223
d0c6b305
GT
2224\wxheading{Remarks}
2225
eea22fd5
GT
2226Currently only applicable to dBase and MS-Access datasources.
2227
2228
d0c6b305
GT
2229\membersection{wxDbTable::GetWhereClause}\label{wxdbtablegetwhereclause}
2230
2231\func{const char *}{GetWhereClause}{}
2232
eea22fd5
GT
2233Accessor function that returns the current WHERE setting assigned with the
2234\helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
2235
2236\wxheading{See also}
2237
2238\helpref{wxDbTable::Where}{wxdbtablewhere}
2239
d0c6b305
GT
2240
2241\membersection{wxDbTable::Insert}\label{wxdbtableinsert}
2242
2243\func{int}{Insert}{\void}
2244
eea22fd5
GT
2245Inserts a new record into the table being referenced by this wxDbTable
2246instance. The values in the member variables of the wxDbTable instance are
2247inserted into the columns of the new row in the database
2248
2249\wxheading{Return value}
2250
2251\begin{verbatim}
2252 DB_SUCCESS Record inserted successfully (value = 1)
2253
2254 DB_FAILURE Insert failed (value = 0)
2255
2256 DB_ERR_INTEGRITY_CONSTRAINT_VIOL
2257 The insert failed due to an integrity
2258 constraint violation (duplicate non-unique
2259 index entry) is attempted.
2260\end{verbatim}
2261
2262\wxheading{Remarks}
2263
2264A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
2265\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
2266this function to commit or rollback the insertion.
2267
2268\wxheading{Example}
2269
2270\begin{verbatim}
2271 // Incomplete code snippet
2272 strcpy(parts->PartName, "10");
2273 strcpy(parts->PartDesc, "Part #10");
2274 parts->Qty = 1000;
2275 RETCODE retcode = parts.Insert();
2276 switch(retcode)
2277 {
2278 case DB_SUCCESS:
2279 parts->GetDb()->CommitTrans();
2280 return(TRUE);
2281 case DB_ERR_INTEGRITY_CONSTRAINT_VIOL:
2282 // Current data would result in a duplicate key
2283 // on one or more indexes that do not allow duplicates
2284 parts->GetDb()->RollbackTrans();
2285 return(FALSE);
2286 default:
2287 // Insert failed for some unexpected reason
2288 parts->GetDb()->RollbackTrans();
2289 return(FALSE);
2290 }
2291\end{verbatim}
2292
2293
2294\membersection{wxDbTable::IsColNull}\label{wxdbtableiscolnull}
2295
2296\func{bool}{IsColNull}{\param{int }{colNo}}
2297
2298Used primarily in the ODBC class library to determine if a column is equal
2299to "NULL". Works for all data types supported by the ODBC class library.
2300
2301\wxheading{Parameters}
2302
2303\docparam{colNo}{The column number of the bound column as defined by the
2304\helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}
2305calls which defined the columns accesible to this wxDbTable instance.}
2306
d0c6b305
GT
2307\wxheading{Remarks}
2308
eea22fd5
GT
2309NULL column support is currently not fully implemented as of wxWindows 2.4
2310
2311
d0c6b305
GT
2312\membersection{wxDbTable::IsCursorClosedOnCommit}\label{wxdbtableiscursorclosedoncommit}
2313
2314\func{bool}{IsCursorClosedOnCommit}{\void}
2315
eea22fd5
GT
2316Accessor function to return information collected during the opening of the
2317datasource connection that is used by this wxDbTable instance.
2318
2319\wxheading{Return value}
2320
2321Returns TRUE if the cursor associated with this wxDbTable object is closed
2322after a commit or rollback operation. Returns FALSE otherwise.
2323
d0c6b305
GT
2324
2325\membersection{wxDbTable::IsQueryOnly}\label{wxdbtableisqueryonly}
2326
2327\func{bool}{IsQueryOnly}{}
2328
eea22fd5
GT
2329Accessor function that returns a value indicating if this wxDbTable instance
2330was created to allow only queries to be performed on the bound columns. If
2331this function returns TRUE, then no actions may be performed using this
2332wxDbTable instance that would modify (insert/delete/update) the table's data.
2333
d0c6b305
GT
2334
2335\membersection{wxDbTable::Open}\label{wxdbtableopen}
2336
2337\func{bool}{Open}{\void}
2338
eea22fd5
GT
2339Every wxDbTable instance must be opened before it can be used. This function
2340checks for the existence of the requested table, binds columns to the
2341internal cursors needed (insert/update/select) and constructs the insert
2342statement that is used for inserting data to the columns of a new row in
2343the datasource.
2344
d0c6b305
GT
2345\wxheading{Remarks}
2346
eea22fd5
GT
2347If the function returns a FALSE value due to the table not existing, a log
2348entry is recorded for the datasource connection indicating the problem
2349that was detected when checking for table existence. Note that it is usually
2350best for the calling routine to check for the existence of the table and for
2351sufficent user privileges to access the table in the mode (wxDB_QUERY_ONLY or
2352!wxDB_QUERY_ONLY) before trying to open the table for the best possible
2353return results as to why a table cannot be opened.
2354
2355\wxheading{See also}
2356
2357\helpref{wxDb::TableExists}{wxdbtableexists}, \helpref{wxDb::TablePrivileges}{wxdbtableprivileges}
2358
2359
2360\membersection{wxDbTable::OrderBy}\label{wxdbtableorderby}
2361
2362\func{const char *}{OrderBy}{}
2363\func{void}{OrderBy}{\param{const wxString &}{OrderBy}}
2364
2365Accessor function for the private class member wxDbTable::orderBy. Can be
2366used as a synonym for \helpref{wxDbTable::GetOrderByClause}{wxdbtablegetorderbyclause}
2367(the first form of this function) or \helpref{wxDbTable::SetOrderByClause}{wxdbtablesetorderbyclause}
2368(the second form of this function).
2369
2370\wxheading{Parameters}
2371
2372\docparam{OrderBy}{A comma separated list of column names that indicate the
2373alphabetized sorting sequence that the result set is to be returned in. If
2374a FROM clause has also been specified, each column name specified in the
2375ORDER BY clause should be prefaced with the table name to which the column
2376belongs using DOT notation (TABLE.COLUMN).}
2377
2378\wxheading{Return value}
2379
2380The first form of this function returns the current value of the wxDbTable
2381member variable ::orderBy.
2382
2383The second form of the function has no return value.
2384
2385\wxheading{See also}
2386
2387\helpref{wxDbTable::GetOrderByClause}{wxdbtablegetorderbyclause},
2388\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}
2389
2390
d0c6b305
GT
2391\membersection{wxDbTable::Query}\label{wxdbtablequery}
2392
eea22fd5 2393\func{virtual bool}{Query}{\param{bool }{forUpdate=FALSE}, \param{bool }{distinct=FALSE}}
d0c6b305
GT
2394
2395\wxheading{Parameters}
2396
eea22fd5
GT
2397\docparam{forUpdate}{{\it OPTIONAL}. Gives you the option of locking records
2398as they are queried (SELECT ... FOR UPDATE). If the RDBMS is not capable of
2399the FOR UPDATE clause, this argument is ignored. See
2400\helpref{wxDbTable::CanSelectForUpdate}{wxdbtablecanselectforupdate} for
2401additional information regarding this argument. Default is FALSE.}
2402\docparam{distinct}{{\it OPTIONAL}. Allows selection of only distinct values
2403from the query (SELECT DISTINCT ... FROM ...). The notion of DISTINCT
2404applies to all columns returned in the result set, not individual columns.
2405Default is FALSE.}
2406
2407\wxheading{Remarks}
2408
2409This function queries records from the datasource based on the three
2410wxDbTable members: "where", "orderBy", and "from". Use
2411\helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause} to filter on
2412records to be retrieved (e.g. All users with a first name of "JOHN").
2413Use \helpref{wxDbTable::SetOrderByClause}{wxdbtablesetorderbyclause} to
2414change the sequence in which records are returned in the result set from
2415the datasource (e.g. Ordered by LAST_NAME). Use
2416\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} to allow outer
2417joining of the base table (the one being associated with this instance of
2418wxDbTable) with other tables which share a related field.
2419
2420After each of these clauses are set/cleared, call wxDbTable::Query() to
2421fetch the result set from the datasource.
2422
2423This scheme has an advantage if you have to requery your record set
2424frequently in that you only have to set your WHERE, ORDER BY, and FROM
2425clauses once. Then to refresh the record set, simply call wxDbTable::Query()
2426as frequently as needed.
2427
2428Note that repeated calls to wxDbTable::Query() may tax the database
2429server and make your application sluggish if done too frequently or
2430unnecessarily.
2431
2432The base table name is automatically prepended to the base column names in
2433the event that the FROM clause has been set (is non-null) using
2434\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}.
2435
2436The cursor for the result set is positioned {\it before} the first record in
2437the record set after the query. To retrieve the first record, call
2438\helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} or
2439\helpref{wxDbTable::GetNext}{wxdbtablegetnext}. Typically, no data from the
2440result set is returned to the client driver until a request to such as
2441\helpref{wxDbTable::GetNext}{wxdbtablegetnext} is performed, so network
2442traffic and database load are not overwhelmed transmitting data until the
2443data is actually requested by the client. This behavior is solely dependent
2444on the ODBC driver though, so refer to the ODBC driver's reference material
2445for information on its behaviors.
2446
2447The wxDbTable::Query() function is defined as "virtual" so that it may be
2448overridden for application specific purposes.
2449
2450\normalbox{Be sure and set the wxDbTable's "where", "orderBy", and "from"
2451member variables to "" if they are not being used in the query. Otherwise,
2452the results returned may have unexpected results (or no results) due to
2453improper or incorrect query parameters constructed from the uninitialized
2454clauses.}
2455
2456\wxheading{Example}
2457
2458\begin{verbatim}
2459 // Incomplete code sample
2460 parts->SetWhereClause("DESCRIPTION = 'FOOD'");
2461 parts->SetOrderByClause("EXPIRATION_DATE");
2462 parts->SetFromClause("");
2463 // Query the records based on the where, orderBy and from clauses
2464 // specified above
2465 parts->Query();
2466 // Display all records queried
2467 while(parts->GetNext())
2468 dispPart(parts); // user defined function
2469\end{verbatim}
d0c6b305 2470
d0c6b305
GT
2471
2472\membersection{wxDbTable::QueryBySqlStmt}\label{wxdbtablequerybysqlstmt}
2473
2474\func{bool}{QueryBySqlStmt}{\param{const char *}{pSqlStmt}}
2475
eea22fd5
GT
2476Performs a query against the datasource by accepting and passing verbatim the
2477SQL SELECT statement passed to the function.
2478
d0c6b305
GT
2479\wxheading{Parameters}
2480
eea22fd5 2481\docparam{pSqlStmt}{A pointer to the SQL SELECT statement to be executed.}
d0c6b305
GT
2482
2483\wxheading{Remarks}
2484
eea22fd5
GT
2485This is the most powerful form of the query functions available. This member
2486function allows a programmer to write their own custom SQL SELECT statement
2487for requesting data from the data source. This gives the programmer access
2488to the full power of SQL for performing operations such as scalar functions,
2489aggregate functions, table joins, and sub-queries, as well as datasource
2490specific function calls.
2491
2492The requirements of the SELECT statement are the following:
2493
2494\begin{verbatim}
2495 1. Must return the correct number of columns. In the derived wxDbTable
2496 constructor, it is specified how many columns are in the wxDbTable
2497 object. The SELECT statement must return exactly that many columns.
2498
2499 2. The columns must be returned in the same sequence as specified
2500 when defining the bounds columns using wxDbTable::SetColDefs(), and
2501 the columns returned must be of the proper data type. For example,
2502 if column 3 is defined in the wxDbTable bound column definitions to be a float,
2503 the SELECT statement must return a float for column 3 (e.g.
2504 PRICE * 1.10 to increase the price by 10%).
2505
2506 3. The ROWID can be included in your SELECT statement as the last column
2507 selected, if the datasource supports it. Use wxDbTable::CanUpdByROWID()
2508 to determine if the ROWID can be selected from the datasource. If it
2509 can, much better performance can be achieved on updates and deletes
2510 by including the ROWID in the SELECT statement.
2511\end{verbatim}
2512
2513Even though data can be selected from multiple tables in your select
2514statement (joins), only the base table associated with this wxDbTable object
2515is automatically updated through the ODBC class library. Data from multiple
2516tables can be selected for display purposes however. Include columns in
2517the wxDbTable object and mark them as non-updateable (See
2518\helpref{wxDbColDef}{wxdbcoldef} for details). This way columns can be
2519selected and displayed from other tables, but only the base table will be
2520updated automatically through the \helpref{wxDbTable::Update}{wxdbtableupdate}
2521function. To update tables other than the base table, use the
2522\helpref{wxDbTable::Update}{wxdbtableupdate} function passing a SQL statement.
2523
2524After this function has been called, the cursor is positioned before the
2525first record in the record set. To retrieve the first record, call
2526either \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} or
2527\helpref{wxDbTable::GetNext}{wxdbtablegetnext}.
2528
2529\wxheading{Example}
2530
2531\begin{verbatim}
2532 // Incomplete code samples
2533 strcpy(sqlStmt, "SELECT * FROM PARTS WHERE STORAGE_DEVICE = 'SD98' \
2534 AND CONTAINER = 12");
2535 // Query the records using the SQL SELECT statement above
2536 parts->QueryBySqlStmt(sqlStmt);
2537 // Display all records queried
2538 while(parts->GetNext())
2539 dispPart(&parts);
2540
2541 Example SQL statements
2542 ----------------------
2543
2544 // Table Join returning 3 columns
2545 SELECT part_no, part_desc, sd_name
2546 from parts, storage_devices
2547 where parts.storage_device_id = storage_devices.storage_device_id
2548
2549 // Aggregate function returning total number of parts in container 99
2550 SELECT count(*) from PARTS where container = 99
2551
2552 // Order by clause; ROWID, scalar function
2553 SELECT part_no, substring(part_desc, 1, 10), qty_on_hand + 1, ROWID
2554 from parts
2555 where warehouse = 10
2556 order by part_no desc // descending order
2557
2558 // Subquery
2559 SELECT * from parts
2560 where container in (select container
2561 from storage_devices
2562 where device_id = 12)
2563\end{verbatim}
2564
2565
d0c6b305
GT
2566\membersection{wxDbTable::QueryMatching}\label{wxdbtablequerymatching}
2567
eea22fd5
GT
2568\func{virtual bool}{QueryMatching}{\param{bool }{forUpdate=FALSE}, \param{bool }{distinct=FALSE}}
2569
2570QueryMatching allows querying of records from the table associated with
2571the wxDbTable object by matching "columns" to values.
2572
2573For example: To query the datasource for the row with a PART_NUMBER column
2574value of "32", clear all column variables of the wxDbTable object, set the
2575PartNumber variable that is bound to the PART_NUMBER column in the wxDbTable
2576object to "32", and then call wxDbTable::QueryMatching().
d0c6b305
GT
2577
2578\wxheading{Parameters}
2579
eea22fd5
GT
2580\docparam{forUpdate}{{\it OPTIONAL}. Gives you the option of locking records
2581as they are queried (SELECT ... FOR UPDATE). If the RDBMS is not capable of
2582the FOR UPDATE clause, this argument is ignored. See
2583\helpref{wxDbTable::CanSelectForUpdate}{wxdbtablecanselectforupdate} for
2584additional information regarding this argument. Default is FALSE.}
2585\docparam{distinct}{{\it OPTIONAL}. Allows selection of only distinct values
2586from the query (SELECT DISTINCT ... FROM ...). The notion of DISTINCT
2587applies to all columns returned in the result set, not individual columns.
2588Default is FALSE.}
d0c6b305
GT
2589
2590\wxheading{Remarks}
2591
eea22fd5
GT
2592The SQL WHERE clause is built by the ODBC class library based on all
2593non-zero/non-NULL columns in your wxDbTable object. Matches can be on one,
2594many or all of the wxDbTable's columns. The base table name is prepended
2595to the column names in the event that the wxDbTable's FROM clause is non-null.
2596
2597This function cannot be used to perform queries which will check for
2598columns that are 0 or NULL, as the automatically constructed WHERE clause
2599only will contain comparisons on column member variables that are
2600non-zero/non-NULL.
2601
2602The primary difference between this function and \helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields}
2603is that this function can query on any column(s) in the wxDbTable object.
2604Note however that this may not always be very efficient. Searching on
2605non-indexed columns will always require a full table scan.
2606
2607The cursor is positioned before the first record in the record set after
2608the query is performed. To retrieve the first record, the program must call
2609either \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} or
2610\helpref{wxDbTable::GetNext}{wxdbtablegetnext}.
2611
2612\wxheading{Example}
2613
2614\begin{verbatim}
2615 // Incomplete code sample
2616 parts->ClearMemberVars(); // Set all columns to zero
2617 strcpy(parts->PartNumber,"32"); // Set columns to query on
2618 parts->OnHold = TRUE;
2619 parts->QueryMatching(); // Query
2620 // Display all records queried
2621 while(parts->GetNext())
2622 dispPart(parts); // Some application defined function
2623\end{verbatim}
2624
2625
d0c6b305
GT
2626\membersection{wxDbTable::QueryOnKeyFields}\label{wxdbtablequeryonkeyfields}
2627
eea22fd5
GT
2628\func{bool}{QueryOnKeyFields}{\param{bool }{forUpdate=FALSE}, \param{bool }{distinct=FALSE}}
2629
2630QueryOnKeyFields provides an easy mechanism to query records in the table
2631associated with the wxDbTable object by the primary index column(s). Simply
2632assign the primary index column(s) values and then call this member function
2633to retrieve the record.
2634
2635Note that since primary indexes are always unique, this function implicitly
2636always returns a single record from the database. The base table name is
2637prepended to the column names in the event that the wxDbTable's FROM clause
2638is non-null.
d0c6b305
GT
2639
2640\wxheading{Parameters}
2641
eea22fd5
GT
2642\docparam{forUpdate}{{\it OPTIONAL}. Gives you the option of locking records
2643as they are queried (SELECT ... FOR UPDATE). If the RDBMS is not capable of
2644the FOR UPDATE clause, this argument is ignored. See
2645\helpref{wxDbTable::CanSelectForUpdate}{wxdbtablecanselectforupdate} for
2646additional information regarding this argument. Default is FALSE.}
2647\docparam{distinct}{{\it OPTIONAL}. Allows selection of only distinct values
2648from the query (SELECT DISTINCT ... FROM ...). The notion of DISTINCT
2649applies to all columns returned in the result set, not individual columns.
2650Default is FALSE.}
d0c6b305
GT
2651
2652\wxheading{Remarks}
2653
eea22fd5
GT
2654The cursor is positioned before the first record in the record set after
2655the query is performed. To retrieve the first record, the program must call
2656either \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} or
2657\helpref{wxDbTable::GetNext}{wxdbtablegetnext}.
2658
2659\wxheading{Example}
2660
2661\begin{verbatim}
2662 // Incomplete code sample
2663 strcpy(parts->PartNumber, "32");
2664 parts->QueryOnKeyFields();
2665 // Display all records queried
2666 while(parts->GetNext())
2667 dispPart(parts); // Some application defined function
2668\end{verbatim}
2669
2670
d0c6b305
GT
2671\membersection{wxDbTable::Refresh}\label{wxdbtablerefresh}
2672
2673\func{bool}{Refresh}{\void}
2674
eea22fd5
GT
2675Refreshes (re-reads into the bound columns) the current record for the
2676current active cursor of the wxDbTable object.
2677
2678The cursor position and result set are unaffected by calls to this function.
2679(The one exception is in the case where the record to be refreshed has been
2680deleted by some other user or transaction since it was originally retrieved
2681as part of the result set. For most datasources, the default behavior in
2682this situation is to return the value that was originally queried for the
2683result set, even though it has been deleted from the database. But this is
2684datasource dependent, and should be tested before relying on this behavior.)
2685
d0c6b305
GT
2686\wxheading{Remarks}
2687
eea22fd5
GT
2688This routine is only guaranteed to work if the table has a unique primary
2689index defined for it. Otherwise, more than one record may be fetched and
2690there is no guarantee that the correct record will be refreshed. The
2691table's columns are refreshed to reflect the current data in the database.
2692
2693
d0c6b305
GT
2694\membersection{wxDbTable::SetColDefs}\label{wxdbtablesetcoldefs}
2695
2696\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}}
2697
2698\func{wxDbColDataPtr *}{SetColDefs}{\param{wxDbColInf *}{colInfs}, \param{ULONG }{numCols}}
2699
2700\wxheading{Parameters}
2701
eea22fd5
GT
2702\docparam{index}{Column number (0 to n-1, where n is the number of columns
2703specified as being defined for this wxDbTable instance when the
2704wxDbTable constructor was called.}
2705\docparam{fieldName}{Column name from the associated data table.}
2706\docparam{dataType}{Logical data type. Valid logical types include:}
d0c6b305 2707
eea22fd5
GT
2708\begin{verbatim}
2709 DB_DATA_TYPE_VARCHAR : strings
2710 DB_DATA_TYPE_INTEGER : non-floating point numbers
2711 DB_DATA_TYPE_FLOAT : floating point numbers
2712 DB_DATA_TYPE_DATE : dates
2713\end{verbatim}
2714
2715\docparam{pData}{Pointer to the data object that will hold the column's
2716value when a row of data is returned from the datasource.}
2717\docparam{cType}{SQL C Type. This defines the data type that the SQL
2718representation of the data is converted to to be stored in {\it pData}.
2719Other valid types are available also, but these are the most common ones:}
2720
2721\begin{verbatim}
2722 SQL_C_CHAR // strings
2723 SQL_C_LONG
2724 SQL_C_ULONG
2725 SQL_C_SHORT
2726 SQL_C_USHORT
2727 SQL_C_FLOAT
2728 SQL_C_DOUBLE
2729 SQL_C_NUMERIC
2730 SQL_C_TIMESTAMP
2731
2732 SQL_C_BOOLEAN // defined in db.h
2733 SQL_C_ENUM // defined in db.h
2734\end{verbatim}
2735
2736\docparam{size}{Maximum size in bytes of the {\it pData} object.}
2737\docparam{keyField}{{\it OPTIONAL}. Indicates if this column is part of the
2738primary index. Default is FALSE.}
2739\docparam{upd}{{\it OPTIONAL}. Are updates allowed on this column?
2740Default is TRUE.}
2741\docparam{insAllow}{{\it OPTIONAL}. Inserts allowed on this column?
2742Default is TRUE.}
2743\docparam{derivedCol}{{\it OPTIONAL}. Is this a derived column (non base
2744table column for query only)? Default is FALSE.}
2745
2746\docparam{colInfs}{Pointer to an array of wxDbColInf instances which contains
2747all the information necessary to create {\it numCols} column definitions.}
2748\docparam{numCols}{Number of elements of wxDbColInf type that are pointed
2749to by {\it colInfs}, which are to have column definitions created from them.}
d0c6b305
GT
2750
2751\wxheading{Remarks}
2752
eea22fd5
GT
2753If {\it pData} is to hold a string of characters, be sure to include enough
2754space for the NULL terminator in pData and in the byte count of {\it size}.
2755
2756Both forms of this function provide a shortcut for defining the columns in
2757your wxDbTable object. Use this function in any derived wxDbTable
2758constructor when describing the column/columns in the wxDbTable object.
2759
2760The second form of this function is primarily used when the
2761\helpref{wxDb::GetColumns}{wxdbgetcolumns} function was used to query the
2762datasource for the column definitions, so that the column definitions are
2763already stored in wxDbColInf form. One example use of using
2764\helpref{wxDb::GetColumns}{wxdbgetcolumns} then using this function is if
2765a data table existed in one datasource, and the table's column definitions
2766were to be copied over to another datasource or table.
2767
2768\wxheading{Example}
2769
2770\begin{verbatim}
2771 // Long way not using this function
2772 strcpy(colDefs[0].ColName, "PART_NO");
2773 colDefs[0].DbDataType = DB_DATA_TYPE_VARCHAR;
2774 colDefs[0].PtrDataObj = PartNumber;
2775 colDefs[0].SqlCtype = SQL_C_CHAR;
2776 colDefs[0].SzDataObj = PART_NUMBER_LEN;
2777 colDefs[0].KeyField = TRUE;
2778 colDefs[0].Updateable = FALSE;
2779 colDefs[0].InsertAllowed= TRUE;
2780 colDefs[0].DerivedCol = FALSE;
2781
2782 // Shortcut using this function
2783 SetColDefs(0, "PART_NUMBER", DB_DATA_TYPE_VARCHAR, PartNumber,
2784 SQL_C_CHAR, PART_NUMBER_LEN, TRUE, FALSE,TRUE,FALSE);
2785\end{verbatim}
2786
2787
d0c6b305
GT
2788\membersection{wxDbTable::SetCursor}\label{wxdbtablesetcursor}
2789
2790\func{bool}{Open}{\param{HSTMT *}{hstmtActivate = (void **) wxDB_DEFAULT_CURSOR}}
2791
2792\wxheading{Parameters}
2793
eea22fd5
GT
2794\docparam{hstmtActivate}{{\it OPTIONAL}. Pointer to the cursor that is to
2795become the current cursor. Passing no cursor handle will reset the cursor
2796back to the wxDbTable's default (original) cursor that was created when the
2797wxDbTable instance was first created. Default is wxDB_DEFAULT_CURSOR.}
d0c6b305
GT
2798
2799\wxheading{Remarks}
2800
eea22fd5
GT
2801When swapping between cursors, the member variables of the wxDbTable object
2802are automatically refreshed with the column values of the row that the
2803current cursor is positioned at (if any). If the cursor is not positioned,
2804then the data in member variables is undefined.
2805
2806The only way to return back to the cursor that was in use before this
2807function was called is to programmatically determine the current cursor
2808BEFORE calling this function using \helpref{wxDbTable::GetCursor}{wxdbtablegetcursor}
2809and saving a pointer to that cursor.
2810
2811\wxheading{See also}
2812
2813\helpref{wxDbTable::GetNewCursor}{wxdbtablegetnewcursor}, \helpref{wxDbTable::GetCursor}{wxdbtablegetcursor},
2814\helpref{wxDbTable::SetCursor}{wxdbtablesetcursor}
2815
2816
d0c6b305
GT
2817\membersection{wxDbTable::SetFromClause}\label{wxdbtablesetfromclause}
2818
eea22fd5
GT
2819\func{void}{SetFromClause}{\param{const wxString &}{From}}
2820
2821Accessor function for setting the private class member wxDbTable::from
2822that indicates what other tables should be outer joined with the wxDbTable's
2823base table for access to the columns in those other tables.
2824
2825Synonym to this function is one form of \helpref{wxDbTable::From}{wxdbtablefrom}
d0c6b305
GT
2826
2827\wxheading{Parameters}
2828
eea22fd5
GT
2829\docparam{From}{A comma separated list of table names that are to be outer
2830joined with the base table's columns so that the joined table's columns
2831may be returned in the result set or used as a portion of a comparison with
2832the base table's columns. NOTE that the base tables name must NOT be included
2833in the FROM clause, as it is automatically included by the wxDbTable class
2834in constructing query statements.}
2835
2836\wxheading{Remarks}
2837
2838Used by the \helpref{wxDbTable::Query}{wxdbtablequery} and
2839\helpref{wxDbTable::Count}{wxdbtablecount} member functions to allow outer
2840joining of records from multiple tables.
2841
2842Do {\bf not} include the keyword "FROM" when setting the FROM clause.
2843
2844If using the FROM clause when performing a query, be certain to include in
2845the corresponding WHERE clause a comparison of a column from either the base
2846table or one of the other joined tables to each other joined table to ensure
2847the datasource knows on which column values the tables should be joined on.
2848
2849\wxheading{Example}
2850
2851\begin{verbatim}
2852 ...
2853 // Base table is the "LOCATION" table, and it is being
2854 // outer joined to the "PART" table via the the field "PART_NUMBER"
2855 // that can be related between the two tables.
2856 location->SetWhereClause("LOCATION.PART_NUMBER = PART.PART_NUMBER")
2857 location->SetFromClause("PART");
2858 ...
2859\end{verbatim}
2860
2861\wxheading{See also}
2862
2863\helpref{wxDbTable::From}{wxdbtablefrom},
2864\helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
2865
d0c6b305
GT
2866
2867\membersection{wxDbTable::SetNull}\label{wxdbtablesetnull}
2868
2869\func{bool}{SetNull}{\param{int }{colNo}}
2870
2871\func{bool}{SetNull}{\param{const char *}{colName}}
2872
eea22fd5
GT
2873Both forms of this function allow a member variable representing a column
2874in the table associated with this wxDbTable object to be set to NULL.
2875
2876The first form allows the column to be set by the index into the column
2877definitions used to create the wxDbTable instance, while the second allows
2878the actual column name to be specified.
2879
d0c6b305
GT
2880\wxheading{Parameters}
2881
eea22fd5
GT
2882\docparam{colNo}{Index into the column definitions used when first defining
2883this wxDbTable object.}
2884\docparam{colName}{Actual data table column name that is to be set to NULL.}
d0c6b305
GT
2885
2886\wxheading{Remarks}
2887
eea22fd5
GT
2888No database updates are done by this function. It only operates on the
2889member variables in memory. Use and insert or update function to store this
2890value to disk.
2891
2892
d0c6b305
GT
2893\membersection{wxDbTable::SetOrderByClause}\label{wxdbtablesetorderbyclause}
2894
eea22fd5
GT
2895\func{void}{SetOrderByClause}{\param{const wxString &}{OrderBy}}
2896
2897Accessor function for setting the private class member wxDbTable::orderBy
2898which determines sequence/ordering of the rows returned in the result set
2899of a query.
2900
2901Synonym to this function is one form of \helpref{wxDbTable::OrderBy}{wxdbtableorderby}
d0c6b305
GT
2902
2903\wxheading{Parameters}
2904
eea22fd5
GT
2905\docparam{OrderBy}{A comma separated list of column names that indicate the
2906alphabetized sorting sequence that the result set is to be returned in. If
2907a FROM clause has also been specified, each column name specified in the
2908ORDER BY clause should be prefaced with the table name to which the column
2909belongs using DOT notation (TABLE.COLUMN).}
2910
2911\wxheading{Remarks}
2912
2913Do {\bf not} include the keywords "ORDER BY" when setting the ORDER BY clause.
2914
2915\wxheading{Example}
2916
2917\begin{verbatim}
2918 ...
2919 parts->SetOrderByClause("PART_DESCRIP, QUANTITY");
2920 ...
2921
2922 ...
2923 location->SetOrderByClause("LOCATION.POSITION, PART.PART_NUMBER);
2924 ...
2925\end{verbatim}
2926
2927\wxheading{See also}
2928
2929\helpref{wxDbTable::OrderBy}{wxdbtableorderby},
2930\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}
2931
d0c6b305
GT
2932
2933\membersection{wxDbTable::SetQueryTimeout}\label{wxdbtablesetquerytimeout}
2934
2935\func{bool}{SetQueryTimeout}{\param{UDWORD }{nSeconds}}
2936
eea22fd5
GT
2937Allows a time period to be set as the timeout period for queries.
2938
d0c6b305
GT
2939\wxheading{Parameters}
2940
eea22fd5
GT
2941\docparam{nSeconds}{The number of seconds to wait for the query to complete
2942before timing out.}
d0c6b305
GT
2943
2944\wxheading{Remarks}
2945
eea22fd5
GT
2946Neither Oracle or Access support this function as of yet. Other databases
2947should be evaluated for support before depending on this function working
2948correctly.
2949
2950
d0c6b305
GT
2951\membersection{wxDbTable::SetWhereClause}\label{wxdbtablesetwhereclause}
2952
eea22fd5
GT
2953\func{void}{SetWhereClause}{\param{const wxString &}{Where}}
2954
2955Accessor function for setting the private class member wxDbTable::where
2956that determines which rows are returned in the result set by the datasource.
2957
2958Synonym to this function is one form of \helpref{wxDbTable::Where}{wxdbtablewhere}
d0c6b305
GT
2959
2960\wxheading{Parameters}
2961
eea22fd5
GT
2962\docparam{Where}{SQL "where" clause. This clause can contain any SQL language
2963that is legal in standard where clauses. If a FROM clause has also been
2964specified, each column name specified in the ORDER BY clause should be
2965prefaced with the table name to which the column belongs using DOT notation
2966(TABLE.COLUMN).}
2967
2968\wxheading{Remarks}
2969
2970Do {\bf not} include the keywords "WHERE" when setting the WHERE clause.
2971
2972\wxheading{Example}
2973
2974\begin{verbatim}
2975 ...
2976 // Simple where clause
2977 parts->SetWhereClause("PART_NUMBER = '32'");
2978 ...
2979 // Any comparison operators
2980 parts->SetWhereClause("PART_DESCRIP LIKE 'HAMMER%'");
2981 ...
2982 // Multiple comparisons, including a function call
2983 parts->Where("QTY > 0 AND {fn UCASE(PART_DESCRIP)} LIKE '%DRILL%'");
2984 ...
2985 // Using parameters and multiple logical combinations
2986 parts->Where("((QTY > 10) OR (ON_ORDER > 0)) AND ON_HOLD = 0");
2987 ...
2988 // This query uses an outer join (requiring a FROM clause also)
2989 // that joins the PART and LOCATION table on he common field
2990 // PART_NUMBER.
2991 parts->Where("PART.ON_HOLD = 0 AND \
2992 PART.PART_NUMBER = LOCATION.PART_NUMBER AND \
2993 LOCATION.PART_NUMBER > 0");
2994\end{verbatim}
2995
d0c6b305
GT
2996
2997\membersection{wxDbTable::Update}\label{wxdbtableupdate}
2998
2999\func{bool}{Update}{\void}
3000
3001\func{bool}{Update}{\param{const char *}{pSqlStmt}}
3002
eea22fd5
GT
3003This member function
3004
3005The first form of this function will update the row that the current cursor
3006is currently positioned at with the values in the memory variables that
3007are bound to the columns. The actual SQL statement to perform the update
3008is automatically created by the ODBC class, and then executed.
3009
3010The second form of the function allows full access through SQL statements for
3011updating records in the database. Write any valid SQL UPDATE statement and
3012submit it to this function for execution. Sophisticated updates can be
3013performed using the full power of the SQL dialect. The full SQL statement
3014must have the exact syntax required by the driver/datasource for performing
3015the update. This usually is in the form of:
3016
3017\begin{verbatim}
3018 UPDATE tablename SET col1=X, col2=Y, ... where ...
3019\end{verbatim}
3020
d0c6b305
GT
3021\wxheading{Parameters}
3022
eea22fd5 3023\docparam{pSqlStmt}{Pointer to SQL UPDATE statement to be executed.}
d0c6b305
GT
3024
3025\wxheading{Remarks}
3026
eea22fd5
GT
3027Note that using this function when it is associated with the table that the
3028wxDbTable instance is associated with does not prevent updating
3029columns in any other table in the database for which the connected user
3030has update privileges on. Constructing the appropriate full SQL statement,
3031columns in other tables can also be updated as well.
3032
3033A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
3034\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
3035this function to commit or rollback the update.
3036
3037\wxheading{Example}
3038
3039\begin{verbatim}
3040 strcpy(sqlStmt, "update PART set QTY = 0 where PART_NUMBER = '32'");
3041\end{verbatim}
3042
3043
d0c6b305
GT
3044\membersection{wxDbTable::UpdateWhere}\label{wxdbtableupdatewhere}
3045
3046\func{bool}{UpdateWhere}{\param{const char *}{pWhereClause}}
3047
eea22fd5
GT
3048Performs updates to the base table of the wxDbTable object, updating only the
3049rows which match the criteria specified in the {\it pWhereClause}.
3050
3051All columns that are bound to member variables for this wxDbTable instance
3052that were defined with the "updateable" parameter set to TRUE will be updated
3053with the information currently held in the memory variable.
3054
d0c6b305
GT
3055\wxheading{Parameters}
3056
eea22fd5
GT
3057\docparam{pWhereClause}{Pointer to a valid SQL WHERE clause. Do not
3058include the keyword 'WHERE'.}
d0c6b305
GT
3059
3060\wxheading{Remarks}
3061
eea22fd5
GT
3062Care should be used when updating columns that are part of indexes with
3063this function so as not to violate an unique key constraints.
3064
3065A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
3066\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
3067this function to commit or rollback the update(s).
3068
3069
d0c6b305
GT
3070\membersection{wxDbTable::operator $++$}\label{wxdbtableplusplus}
3071
3072\func{bool}{operator $++$}{\void}
3073
eea22fd5 3074Synonym for \helpref{wxDbTable::GetNext}{wxdbtablegetnext}
d0c6b305
GT
3075
3076\wxheading{See also}
3077
3078\helpref{wxDbTable::GetNext}{wxdbtablegetnext}
3079
eea22fd5 3080
d0c6b305
GT
3081\membersection{wxDbTable::operator $--$}\label{wxdbtableminusminus}
3082
3083\func{bool}{operator $--$}{\void}
3084
eea22fd5 3085Synonym for \helpref{wxDbTable::GetPrev}{wxdbtablegetprev}
d0c6b305
GT
3086
3087\wxheading{See also}
3088
3089\helpref{wxDbTable::GetPrev}{wxdbtablegetprev}
3090
eea22fd5 3091
d0c6b305
GT
3092\section{\class{wxDbTableInf}}\label{wxdbtableinf}
3093
3094Currently only used by wxDb::GetCatalog() internally and wxDbInf class,
3095but may be used in future releases for user functions. Contains information
3096describing the table (Name, type, etc). A pointer to a wxDbColInf array
3097instance is included so a program can create a wxDbColInf array instance
3098(using \helpref{wxDb::GetColumns}{wxdbgetcolumns}) to maintain all information about the columns
3099of a table in one memory structure.
3ca6a5f0 3100