]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/db.tex
Wine fixes
[wxWidgets.git] / docs / latex / wx / db.tex
CommitLineData
3ca6a5f0 1\section{\class{wxDb}}\label{wxdb}
f6bcfd97 2
c67d6048 3A wxDb instance is a connection to an ODBC datasource 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
c67d6048
GT
6datasource, as well as allowing access to any tables/views defined in
7the datasource to which the user has sufficient privileges.
f6bcfd97 8
2564094b
JS
9See the \helpref{database classes overview}{odbcoverview} for
10an introduction to using the ODBC classes.
11
f6bcfd97
BP
12\wxheading{Include files}
13
f6bcfd97
BP
14<wx/db.h>
15
d0c6b305
GT
16\wxheading{Helper classes and data structures}
17
18The following classes and structs are defined in db.cpp/.h for use with the wxDb class.
19
20\begin{itemize}\itemsep=0pt
21\item \helpref{wxDbColFor}{wxdbcolfor}
22\item \helpref{wxDbColInf}{wxdbcolinf}
23\item \helpref{wxDbTableInf}{wxdbtableinf}
24\item \helpref{wxDbInf}{wxdbinf}
25\end{itemize}
26
27\wxheading{Constants}
28
a98f98ac 29NOTE: In a future release, all ODBC class constants will be prefaced with 'wx'.
d0c6b305
GT
30
31\begin{verbatim}
c67d6048 32 wxDB_PATH_MAX Maximum path length allowed to be passed to
107ffdc1 33 the ODBC driver to indicate where the data
c67d6048 34 file(s) are located.
d0c6b305 35
107ffdc1 36 DB_MAX_COLUMN_NAME_LEN Maximum supported length for the name of a
c67d6048 37 column
d0c6b305 38
107ffdc1
RD
39 DB_MAX_ERROR_HISTORY Maximum number of error messages retained in
40 the queue before being overwritten by new
c67d6048 41 errors.
d0c6b305 42
107ffdc1 43 DB_MAX_ERROR_MSG_LEN Maximum supported length of an error message
c67d6048 44 returned by the ODBC classes
d0c6b305 45
107ffdc1 46 DB_MAX_STATEMENT_LEN Maximum supported length for a complete SQL
c67d6048 47 statement to be passed to the ODBC driver
d0c6b305 48
107ffdc1 49 DB_MAX_TABLE_NAME_LEN Maximum supported length for the name of a
c67d6048 50 table
d0c6b305 51
107ffdc1 52 DB_MAX_WHERE_CLAUSE_LEN Maximum supported WHERE clause length that
c67d6048 53 can be passed to the ODBC driver
d0c6b305 54
107ffdc1 55 DB_TYPE_NAME_LEN Maximum length of the name of a column's
c67d6048 56 data type
d0c6b305
GT
57\end{verbatim}
58
c67d6048 59\subsection{Enumerated types}\label{wxdbenumeratedtypes}
a98f98ac 60
55842641 61\wxheading{Enumerated types}
3ca6a5f0 62
d0c6b305 63\docparam{enum {\bf wxDbSqlLogState}}{sqlLogOFF, sqlLogON}
3ca6a5f0
BP
64
65{\it enum {\bf wxDBMS}}
66
d0c6b305 67These 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 68
998abc15
GT
69\begin{itemize}\itemsep=0pt
70\item DB2
71\item DBase (IV, V)**
72\item Firebird
73\item INFORMIX
74\item Interbase
75\item MS SQL Server (v7 - minimal testing)
76\item MS Access (97, 2000, 2002, and 2003)
77\item MySQL (2.x and 3.5 - use the 2.5x drivers though)
78\item Oracle (v7, v8, v8i)
79\item Pervasive SQL
80\item PostgreSQL
81\item Sybase (ASA and ASE)
82\item XBase Sequiter
83\item VIRTUOSO
84\end{itemize}
3ca6a5f0 85
d0c6b305 86See the remarks in \helpref{wxDb::Dbms}{wxdbdbms} for exceptions/issues with each of these database engines.
3ca6a5f0
BP
87
88\wxheading{Public member variables}
89
d0c6b305 90\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 91
c67d6048 92\docparam{int {\bf wxDb::DB\_STATUS}}{The last ODBC error/status that occurred on this data connection. Possible codes are:}
3ca6a5f0
BP
93
94\begin{verbatim}
95 DB_ERR_GENERAL_WARNING // SqlState = '01000'
96 DB_ERR_DISCONNECT_ERROR // SqlState = '01002'
97 DB_ERR_DATA_TRUNCATED // SqlState = '01004'
98 DB_ERR_PRIV_NOT_REVOKED // SqlState = '01006'
99 DB_ERR_INVALID_CONN_STR_ATTR // SqlState = '01S00'
100 DB_ERR_ERROR_IN_ROW // SqlState = '01S01'
101 DB_ERR_OPTION_VALUE_CHANGED // SqlState = '01S02'
102 DB_ERR_NO_ROWS_UPD_OR_DEL // SqlState = '01S03'
103 DB_ERR_MULTI_ROWS_UPD_OR_DEL // SqlState = '01S04'
104 DB_ERR_WRONG_NO_OF_PARAMS // SqlState = '07001'
105 DB_ERR_DATA_TYPE_ATTR_VIOL // SqlState = '07006'
106 DB_ERR_UNABLE_TO_CONNECT // SqlState = '08001'
107 DB_ERR_CONNECTION_IN_USE // SqlState = '08002'
108 DB_ERR_CONNECTION_NOT_OPEN // SqlState = '08003'
109 DB_ERR_REJECTED_CONNECTION // SqlState = '08004'
110 DB_ERR_CONN_FAIL_IN_TRANS // SqlState = '08007'
111 DB_ERR_COMM_LINK_FAILURE // SqlState = '08S01'
112 DB_ERR_INSERT_VALUE_LIST_MISMATCH // SqlState = '21S01'
113 DB_ERR_DERIVED_TABLE_MISMATCH // SqlState = '21S02'
114 DB_ERR_STRING_RIGHT_TRUNC // SqlState = '22001'
115 DB_ERR_NUMERIC_VALUE_OUT_OF_RNG // SqlState = '22003'
116 DB_ERR_ERROR_IN_ASSIGNMENT // SqlState = '22005'
117 DB_ERR_DATETIME_FLD_OVERFLOW // SqlState = '22008'
118 DB_ERR_DIVIDE_BY_ZERO // SqlState = '22012'
119 DB_ERR_STR_DATA_LENGTH_MISMATCH // SqlState = '22026'
120 DB_ERR_INTEGRITY_CONSTRAINT_VIOL // SqlState = '23000'
121 DB_ERR_INVALID_CURSOR_STATE // SqlState = '24000'
122 DB_ERR_INVALID_TRANS_STATE // SqlState = '25000'
123 DB_ERR_INVALID_AUTH_SPEC // SqlState = '28000'
124 DB_ERR_INVALID_CURSOR_NAME // SqlState = '34000'
125 DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL // SqlState = '37000'
126 DB_ERR_DUPLICATE_CURSOR_NAME // SqlState = '3C000'
127 DB_ERR_SERIALIZATION_FAILURE // SqlState = '40001'
128 DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL2 // SqlState = '42000'
129 DB_ERR_OPERATION_ABORTED // SqlState = '70100'
130 DB_ERR_UNSUPPORTED_FUNCTION // SqlState = 'IM001'
131 DB_ERR_NO_DATA_SOURCE // SqlState = 'IM002'
132 DB_ERR_DRIVER_LOAD_ERROR // SqlState = 'IM003'
133 DB_ERR_SQLALLOCENV_FAILED // SqlState = 'IM004'
134 DB_ERR_SQLALLOCCONNECT_FAILED // SqlState = 'IM005'
135 DB_ERR_SQLSETCONNECTOPTION_FAILED // SqlState = 'IM006'
136 DB_ERR_NO_DATA_SOURCE_DLG_PROHIB // SqlState = 'IM007'
137 DB_ERR_DIALOG_FAILED // SqlState = 'IM008'
138 DB_ERR_UNABLE_TO_LOAD_TRANSLATION_DLL // SqlState = 'IM009'
139 DB_ERR_DATA_SOURCE_NAME_TOO_LONG // SqlState = 'IM010'
140 DB_ERR_DRIVER_NAME_TOO_LONG // SqlState = 'IM011'
141 DB_ERR_DRIVER_KEYWORD_SYNTAX_ERROR // SqlState = 'IM012'
142 DB_ERR_TRACE_FILE_ERROR // SqlState = 'IM013'
143 DB_ERR_TABLE_OR_VIEW_ALREADY_EXISTS // SqlState = 'S0001'
144 DB_ERR_TABLE_NOT_FOUND // SqlState = 'S0002'
145 DB_ERR_INDEX_ALREADY_EXISTS // SqlState = 'S0011'
146 DB_ERR_INDEX_NOT_FOUND // SqlState = 'S0012'
147 DB_ERR_COLUMN_ALREADY_EXISTS // SqlState = 'S0021'
148 DB_ERR_COLUMN_NOT_FOUND // SqlState = 'S0022'
149 DB_ERR_NO_DEFAULT_FOR_COLUMN // SqlState = 'S0023'
150 DB_ERR_GENERAL_ERROR // SqlState = 'S1000'
151 DB_ERR_MEMORY_ALLOCATION_FAILURE // SqlState = 'S1001'
152 DB_ERR_INVALID_COLUMN_NUMBER // SqlState = 'S1002'
153 DB_ERR_PROGRAM_TYPE_OUT_OF_RANGE // SqlState = 'S1003'
154 DB_ERR_SQL_DATA_TYPE_OUT_OF_RANGE // SqlState = 'S1004'
155 DB_ERR_OPERATION_CANCELLED // SqlState = 'S1008'
156 DB_ERR_INVALID_ARGUMENT_VALUE // SqlState = 'S1009'
157 DB_ERR_FUNCTION_SEQUENCE_ERROR // SqlState = 'S1010'
158 DB_ERR_OPERATION_INVALID_AT_THIS_TIME // SqlState = 'S1011'
159 DB_ERR_INVALID_TRANS_OPERATION_CODE // SqlState = 'S1012'
160 DB_ERR_NO_CURSOR_NAME_AVAIL // SqlState = 'S1015'
161 DB_ERR_INVALID_STR_OR_BUF_LEN // SqlState = 'S1090'
162 DB_ERR_DESCRIPTOR_TYPE_OUT_OF_RANGE // SqlState = 'S1091'
163 DB_ERR_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1092'
164 DB_ERR_INVALID_PARAM_NO // SqlState = 'S1093'
165 DB_ERR_INVALID_SCALE_VALUE // SqlState = 'S1094'
166 DB_ERR_FUNCTION_TYPE_OUT_OF_RANGE // SqlState = 'S1095'
167 DB_ERR_INF_TYPE_OUT_OF_RANGE // SqlState = 'S1096'
168 DB_ERR_COLUMN_TYPE_OUT_OF_RANGE // SqlState = 'S1097'
169 DB_ERR_SCOPE_TYPE_OUT_OF_RANGE // SqlState = 'S1098'
170 DB_ERR_NULLABLE_TYPE_OUT_OF_RANGE // SqlState = 'S1099'
171 DB_ERR_UNIQUENESS_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1100'
172 DB_ERR_ACCURACY_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1101'
173 DB_ERR_DIRECTION_OPTION_OUT_OF_RANGE // SqlState = 'S1103'
174 DB_ERR_INVALID_PRECISION_VALUE // SqlState = 'S1104'
175 DB_ERR_INVALID_PARAM_TYPE // SqlState = 'S1105'
176 DB_ERR_FETCH_TYPE_OUT_OF_RANGE // SqlState = 'S1106'
177 DB_ERR_ROW_VALUE_OUT_OF_RANGE // SqlState = 'S1107'
178 DB_ERR_CONCURRENCY_OPTION_OUT_OF_RANGE // SqlState = 'S1108'
179 DB_ERR_INVALID_CURSOR_POSITION // SqlState = 'S1109'
180 DB_ERR_INVALID_DRIVER_COMPLETION // SqlState = 'S1110'
181 DB_ERR_INVALID_BOOKMARK_VALUE // SqlState = 'S1111'
182 DB_ERR_DRIVER_NOT_CAPABLE // SqlState = 'S1C00'
183 DB_ERR_TIMEOUT_EXPIRED // SqlState = 'S1T00'
184\end{verbatim}
185
107ffdc1
RD
186\docparam{struct {\bf wxDb::dbInf}}{This structure is internal to the
187wxDb class and contains details of the ODBC datasource that the current
188instance of the wxDb is connected to in its members. When the datasource
189is opened, all of the information contained in the dbInf structure is
190queried from the datasource. This information is used almost exclusively
191within the ODBC class library. Where there may be a need for particular
192portions of this information outside of the class library, member
193functions (e.g.
194\helpref{wxDbTable::IsCursorClosedOnCommit}{wxdbtableiscursorclosedoncommit})
59990c22 195have been added for ease of use.}
3ca6a5f0
BP
196
197\begin{verbatim}
9fe17bd3
GT
198 wxChar dbmsName[40] - Name of the dbms product
199 wxChar dbmsVer[64] - Version # of the dbms product
200 wxChar driverName[40] - Driver name
201 wxChar odbcVer[60] - ODBC version of the driver
202 wxChar drvMgrOdbcVer[60] - ODBC version of the driver manager
203 wxChar driverVer[60] - Driver version
204 wxChar serverName[80] - Server Name, typically a connect string
205 wxChar databaseName[128] - Database filename
206 wxChar outerJoins[2] - Does datasource support outer joins
107ffdc1 207 wxChar procedureSupport[2] - Does datasource support stored
c67d6048 208 procedures
107ffdc1 209 UWORD maxConnections - Maximum # of connections datasource
c67d6048 210 supports
3ca6a5f0
BP
211 UWORD maxStmts - Maximum # of HSTMTs per HDBC
212 UWORD apiConfLvl - ODBC API conformance level
213 UWORD cliConfLvl - Is datasource SAG compliant
214 UWORD sqlConfLvl - SQL conformance level
215 UWORD cursorCommitBehavior - How cursors are affected on db commit
107ffdc1 216 UWORD cursorRollbackBehavior - How cursors are affected on db
c67d6048 217 rollback
107ffdc1 218 UWORD supportNotNullClause - Does datasource support NOT NULL
c67d6048 219 clause
107ffdc1 220 wxChar supportIEF[2] - Integrity Enhancement Facility (Ref.
c67d6048
GT
221 Integrity)
222 UDWORD txnIsolation - Transaction isolation level supported by
223 driver
107ffdc1 224 UDWORD txnIsolationOptions - Transaction isolation level options
c67d6048 225 available
3ca6a5f0
BP
226 UDWORD fetchDirections - Fetch directions supported
227 UDWORD lockTypes - Lock types supported in SQLSetPos
107ffdc1 228 UDWORD posOperations - Position operations supported in
c67d6048 229 SQLSetPos
3ca6a5f0 230 UDWORD posStmts - Position statements supported
107ffdc1 231 UDWORD scrollConcurrency - Scrollable cursor concurrency options
c67d6048 232 supported
3ca6a5f0 233 UDWORD scrollOptions - Scrollable cursor options supported
107ffdc1 234 UDWORD staticSensitivity - Can additions/deletions/updates be
c67d6048 235 detected
107ffdc1 236 UWORD txnCapable - Indicates if datasource supports
c67d6048 237 transactions
107ffdc1 238 UDWORD loginTimeout - Number seconds to wait for a login
c67d6048 239 request
3ca6a5f0
BP
240\end{verbatim}
241
e7240349 242\docparam{wxChar {\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 243
e7240349 244\docparam{wxChar {\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.}
3ca6a5f0 245
107ffdc1
RD
246\docparam{SDWORD {\bf wxDb::nativeError}}{Set by wxDb::DispAllErrors,
247wxDb::GetNextError, and wxDb::DispNextError. It contains the
248datasource-specific error code returned by the datasource to the ODBC driver.
9fe17bd3 249Used for reporting ODBC errors.}
3ca6a5f0 250
107ffdc1
RD
251\docparam{wxChar {\bf wxDb::sqlState}[20]}{Set by wxDb::TranslateSqlState().
252Indicates the error state after a failed ODBC operation. Used for reporting
9fe17bd3 253ODBC errors.}
3ca6a5f0 254
d0c6b305 255\wxheading{Remarks}
3ca6a5f0 256
e7240349 257Default cursor scrolling is defined by wxODBC\_FWD\_ONLY\_CURSORS in setup.h
fc2171bd 258when the wxWidgets library is built. This behavior can be overridden when
b236c10f 259an instance of a wxDb is created (see \helpref{wxDb constructor}{wxdbctor}).
cc81d32f 260Default setting of this value true, as not all databases/drivers support
c67d6048 261both types of cursors.
3ca6a5f0 262
d0c6b305 263\wxheading{See also}
3ca6a5f0 264
107ffdc1
RD
265\helpref{wxDbColFor}{wxdbcolfor}, \helpref{wxDbColInf}{wxdbcolinf},
266\helpref{wxDbTable}{wxdbtable}, \helpref{wxDbTableInf}{wxdbtableinf},
9fe17bd3 267\helpref{wxDbInf}{wxdbinf}
3ca6a5f0 268
d0c6b305 269\subsection{Associated non-class functions}\label{wxdbfunctions}
3ca6a5f0 270
d0c6b305 271The following functions are used in conjunction with the wxDb class.
3ca6a5f0 272
6a498e2d
GT
273\func{void}{wxDbCloseConnections}{\void}
274
275\wxheading{Remarks}
276
107ffdc1
RD
277Closes all cached connections that have been made through use of the
278\helpref{wxDbGetConnection}{wxdbfunctions} function.
6a498e2d 279
107ffdc1
RD
280NOTE: These connections are closed regardless of whether they are in use
281or not. This function should only be called after the program has
282finished using the connections and all wxDbTable instances that use any of
6a498e2d
GT
283the connections have been closed.
284
107ffdc1
RD
285This function performs a \helpref{wxDb::CommitTrans}{wxdbcommittrans}
286on the connection before closing it to commit any changes that are still
287pending, as well as to avoid any function sequence errors upon closing
6a498e2d
GT
288each connection.
289
290
291\func{int }{wxDbConnectionsInUse}{\void}
292
293\wxheading{Remarks}
294
107ffdc1
RD
295Returns a count of how many database connections are currently free ( not
296being used) that have been cached through use of the \helpref{wxDbGetConnection}{wxdbfunctions}
6a498e2d
GT
297function.
298
299
300\func{bool}{wxDbFreeConnection}{\param{wxDb *}{pDb}}
301
302\wxheading{Remarks}
303
107ffdc1 304Searches the list of cached database connections connection for one matching
6a498e2d
GT
305the passed in wxDb instance. If found, that cached connection is freed.
306
107ffdc1
RD
307Freeing a connection means that it is marked as available (free) in the
308cache of connections, so that a call to \helpref{wxDbGetConnection}{wxdbfunctions}
309is able to return a pointer to the wxDb instance for use. Freeing a
310connection does NOT close the connection, it only makes the connection
6a498e2d 311available again.
6a498e2d 312
107ffdc1
RD
313
314\func{wxDb *}{wxDbGetConnection}{\param{wxDbConnectInf *}{pDbConfig},
e7240349 315\param{bool }{FwdOnlyCursors=(bool)wxODBC\_FWD\_ONLY\_CURSORS}}
3ca6a5f0 316
c67d6048
GT
317\wxheading{Remarks}
318
107ffdc1
RD
319This function is used to request a "new" wxDb instance for use by the program.
320The wxDb instance returned is also opened (see \helpref{wxDb::Open}{wxdbopen}).
c67d6048 321
107ffdc1 322This function (along with wxDbFreeConnection() and wxDbCloseConnection())
dbd94b75 323maintain a cache of wxDb instances for user/re-use by a program. When a
107ffdc1
RD
324program needs a wxDb instance, it may call this function to obtain a wxDb
325instance. If there is a wxDb instance in the cache that is currently unused
326that matches the connection requirements specified in {\it'pDbConfig'} then
327that cached connection is marked as no longer being free, and a pointer to
c67d6048
GT
328the wxDb instance is returned.
329
107ffdc1
RD
330If there are no connections available in the cache that meet the requirements
331given in {\it'pDbConfig'}, then a new wxDb instance is created to connect
332to the datasource specified in {\it'pDbConfig'} using the userID and password
c67d6048
GT
333given in {\it'pDbConfig'}.
334
107ffdc1
RD
335NOTE: The caching routine also uses the \helpref{wxDb::Open}{wxdbopen}
336connection datatype copying code. If the call to wxDbGetConnection()
337requests a connection to a datasource, and there is not one available in the
338cache, a new connection is created. But when the connection is opened,
339instead of polling the datasource over again for its datatypes, if a
340connection to the same datasource (using the same userID/password) has already
341been done previously, the new connection skips querying the datasource for
342its datatypes, and uses the same datatypes determined previously by the
343other connection(s) for that same datasource. This cuts down greatly on
c67d6048
GT
344network traffic, database load, and connection creation time.
345
107ffdc1
RD
346When the program is done using a connection created through a call to
347wxDbGetConnection(), the program should call wxDbFreeConnection() to release
348the wxDb instance back to the cache. DO NOT DELETE THE wxDb INSTANCE!
349Deleting the wxDb instance returned can cause a crash/memory corruption
c67d6048
GT
350later in the program when the cache is cleaned up.
351
107ffdc1 352When exiting the program, call wxDbCloseConnections() to close all the
c67d6048
GT
353cached connections created by calls to wxDbGetConnection().
354
355
6a498e2d 356\func{const wxChar *}{wxDbLogExtendedErrorMsg}{\param{const wxChar *}{userText}, \param{wxDb *}{pDb}, \param{wxChar *}{ErrFile}, \param{int }{ErrLine}}
c67d6048 357
107ffdc1 358Writes a message to the wxLog window (stdout usually) when an internal
f9af4e76 359error situation occurs.
c67d6048 360
7af3ca16 361\func{bool}{wxDbSqlLog}{\param{wxDbSqlLogState }{state}, \param{const wxString \&}{filename = SQL\_LOG\_FILENAME}}
f6bcfd97 362
c67d6048
GT
363\wxheading{Remarks}
364
365This function sets the sql log state for all open wxDb objects
366
e7240349 367\func{bool}{wxDbGetDataSource}{\param{HENV }{henv}, \param{wxChar *}{Dsn}, \param{SWORD }{DsnMax}, \param{wxChar *}{DsDesc}, \param{SWORD }{DsDescMax}, \param{UWORD }{direction = SQL\_FETCH\_NEXT}}
f6bcfd97 368
c67d6048
GT
369\wxheading{Remarks}
370
107ffdc1
RD
371This routine queries the ODBC driver manager for a list of available
372datasources. Repeatedly call this function to obtain all the datasources
c67d6048
GT
373available through the ODBC driver manager on the current workstation.
374
2564094b 375\begin{verbatim}
9919dac1 376 wxArrayString strArray;
c67d6048 377
107ffdc1 378 while (wxDbGetDataSource(DbConnectInf.GetHenv(), Dsn, SQL_MAX_DSN_LENGTH+1, DsDesc, 255))
9919dac1 379 strArray.Add(Dsn);
2564094b 380\end{verbatim}
c67d6048 381
d0c6b305 382\latexignore{\rtfignore{\wxheading{Members}}}
f6bcfd97 383
b236c10f 384\membersection{wxDb::wxDb}\label{wxdbctor}
3ca6a5f0
BP
385
386\func{}{wxDb}{\void}
f6bcfd97
BP
387
388Default constructor.
389
7af3ca16 390\func{}{wxDb}{\param{const HENV \&}{aHenv}, \param{bool }{FwdOnlyCursors=(bool)wxODBC\_FWD\_ONLY\_CURSORS}}
f6bcfd97 391
c67d6048 392Constructor, used to create an ODBC connection to a datasource.
f6bcfd97
BP
393
394\wxheading{Parameters}
395
107ffdc1 396\docparam{aHenv}{Environment handle used for this connection. See
9fe17bd3 397\helpref{wxDConnectInf::AllocHenv}{wxdbconnectinfallochenv}}
d0c6b305 398
107ffdc1 399\docparam{FwdOnlyCursors}{Will cursors created for use with this datasource
9fe17bd3 400connection only allow forward scrolling cursors.}
f6bcfd97
BP
401
402\wxheading{Remarks}
403
3ca6a5f0 404This is the constructor for the wxDb class. The wxDb object must
f6bcfd97
BP
405be created and opened before any database activity can occur.
406
407\wxheading{Example}
d0c6b305 408
f6bcfd97 409\begin{verbatim}
3ca6a5f0
BP
410 wxDbConnectInf ConnectInf;
411 ....Set values for member variables of ConnectInf here
f6bcfd97 412
9fe17bd3
GT
413 wxDb sampleDB(ConnectInf.GetHenv());
414 if (!sampleDB.Open(ConnectInf.GetDsn(), ConnectInf.GetUserID(),
415 ConnectInf.GetPassword()))
f6bcfd97 416 {
c67d6048 417 // Error opening datasource
f6bcfd97
BP
418 }
419\end{verbatim}
420
c67d6048
GT
421\wxheading{See also}
422
2564094b 423\helpref{wxDbGetConnection}{wxdbfunctions}
f6bcfd97 424
3ca6a5f0 425\membersection{wxDb::Catalog}\label{wxdbcatalog}
f6bcfd97 426
107ffdc1 427\func{bool}{Catalog}{\param{wxChar *}{ userID}, \param{const wxString \&}{fileName =
e7240349 428SQL\_CATALOG\_FILENAME}}
f6bcfd97 429
107ffdc1
RD
430Allows a data "dictionary" of the datasource to be created, dumping pertinent
431information about all data tables to which the user specified in userID has
432access.
3ca6a5f0 433
f6bcfd97
BP
434\wxheading{Parameters}
435
107ffdc1 436\docparam{userID}{Database user name to use in accessing the database. All
9fe17bd3 437tables to which this user has rights will be evaluated in the catalog.}
f6bcfd97 438
107ffdc1 439\docparam{fileName}{{\it OPTIONAL}. Name of the text file to create and write
e7240349 440the DB catalog to. Default is SQL\_CATALOG\_FILENAME.}
f6bcfd97 441
3ca6a5f0 442\wxheading{Return value}
f6bcfd97 443
cc81d32f 444Returns true if the catalog request was successful, or false if there was some
c67d6048 445reason that the catalog could not be generated.
f6bcfd97
BP
446
447\wxheading{Example}
d0c6b305 448
f6bcfd97
BP
449\begin{verbatim}
450============== ============== ================ ========= =======
451TABLE NAME COLUMN NAME DATA TYPE PRECISION LENGTH
452============== ============== ================ ========= =======
453EMPLOYEE RECID (0008)NUMBER 15 8
454EMPLOYEE USER_ID (0012)VARCHAR2 13 13
455EMPLOYEE FULL_NAME (0012)VARCHAR2 26 26
456EMPLOYEE PASSWORD (0012)VARCHAR2 26 26
457EMPLOYEE START_DATE (0011)DATE 19 16
458\end{verbatim}
459
460
3ca6a5f0 461\membersection{wxDb::Close}\label{wxdbclose}
f6bcfd97
BP
462
463\func{void}{Close}{\void}
464
3ca6a5f0
BP
465Closes the database connection.
466
f6bcfd97
BP
467\wxheading{Remarks}
468
107ffdc1
RD
469At the end of your program, when you have finished all of your database work,
470you must close the ODBC connection to the datasource. There are actually
471four steps involved in doing this as illustrated in the example.
3ca6a5f0 472
107ffdc1 473Any wxDbTable instances which use this connection must be deleted before
9fe17bd3 474closing the database connection.
f6bcfd97
BP
475
476\wxheading{Example}
d0c6b305 477
f6bcfd97 478\begin{verbatim}
c67d6048 479 // Commit any open transactions on the datasource
f6bcfd97
BP
480 sampleDB.CommitTrans();
481
d0c6b305 482 // Delete any remaining wxDbTable objects allocated with new
f6bcfd97
BP
483 delete parts;
484
3ca6a5f0 485 // Close the wxDb connection when finished with it
f6bcfd97 486 sampleDB.Close();
f6bcfd97
BP
487\end{verbatim}
488
3ca6a5f0
BP
489
490\membersection{wxDb::CommitTrans}\label{wxdbcommittrans}
491
492\func{bool}{CommitTrans}{\void}
493
107ffdc1 494Permanently "commits" changes (insertions/deletions/updates) to the database.
3ca6a5f0
BP
495
496\wxheading{Return value}
497
cc81d32f 498Returns true if the commit was successful, or false if the commit failed.
3ca6a5f0
BP
499
500\wxheading{Remarks}
501
107ffdc1
RD
502Transactions begin implicitly as soon as you make a change to the database
503with an insert/update/delete, or any other direct SQL command that performs
504one of these operations against the datasource.
505At any time thereafter, to save the changes to disk permanently, "commit"
c67d6048
GT
506them by calling this function.
507
107ffdc1
RD
508Calling this member function commits ALL open transactions on this ODBC
509connection. For example, if three different wxDbTable instances used the
510same connection to the datasource, committing changes made on one of those
511wxDbTable instances commits any pending transactions on all three wxDbTable
c67d6048
GT
512instances.
513
107ffdc1 514Until a call to wxDb::CommitTrans() is made, no other user or cursor is able
55842641 515to see any changes made to the row(s) that have been inserted/modified/deleted.
c67d6048 516
3ca6a5f0
BP
517
518\wxheading{Special Note : {\it Cursors} }
519
107ffdc1
RD
520\normalbox{It is important to understand that different database/ODBC driver
521combinations handle transactions differently. One thing in particular that
522you must pay attention to is cursors, in regard to transactions. Cursors are
523what allow you to scroll through records forward and backward and to
524manipulate records as you scroll through them. When you issue a query, a
525cursor is created behind the scenes. The cursor keeps track of the query and
526keeps track of the current record pointer. After you commit or rollback a
527transaction, the cursor may be closed automatically. This is database
528dependent, and with some databases this behavior can be controlled through
529management functions. This means you would need to requery the datasource
530before you can perform any additional work using this cursor. This is only
531necessary however if the datasource closes the cursor after a commit or
532rollback. Use the
533\helpref{wxDbTable::IsCursorClosedOnCommit}{wxdbtableiscursorclosedoncommit}
534member function to determine the datasource's transaction behavior. Note, in
535many situations it is very inefficient to assume the cursor is closed and
536always requery. This could put a significant, unnecessary load on datasources
9fe17bd3 537that leave the cursors open after a transaction.}
3ca6a5f0
BP
538
539
540\membersection{wxDb::CreateView}\label{wxdbcreateviews}
541
107ffdc1 542\func{bool}{CreateView}{\param{const wxString \&}{ viewName},
7af3ca16 543\param{const wxString \&}{ colList}, \param{const wxString \&}{pSqlStmt}}
3ca6a5f0 544
107ffdc1
RD
545Creates a SQL VIEW of one or more tables in a single datasource. Note that
546this function will only work against databases which support views (currently
c67d6048 547only Oracle as of November 21 2000).
3ca6a5f0
BP
548
549\wxheading{Parameters}
550
e7240349 551\docparam{viewName}{The name of the view. e.g. PARTS\_V}
d0c6b305 552
107ffdc1
RD
553\docparam{colList}{{\it OPTIONAL} Pass in a comma delimited list of column
554names if you wish to explicitly name each column in the result set. If not
555desired, pass in an empty string and the column names from the associated
c67d6048 556table(s) will be used.}
d0c6b305 557
107ffdc1 558\docparam{pSqlStmt}{Pointer to the select statement portion of the CREATE
9fe17bd3 559VIEW statement. Must be a complete, valid SQL SELECT statement.}
3ca6a5f0
BP
560
561\wxheading{Remarks}
562
107ffdc1
RD
563A 'view' is a logical table that derives columns from one or more other
564tables or views. Once the view is created, it can be queried exactly like
9fe17bd3 565any other table in the database.
3ca6a5f0 566
107ffdc1 567NOTE: Views are not available with all datasources. Oracle is one example
9fe17bd3 568of a datasource which does support views.
3ca6a5f0
BP
569
570\wxheading{Example}
d0c6b305 571
3ca6a5f0
BP
572\begin{verbatim}
573 // Incomplete code sample
107ffdc1 574 db.CreateView("PARTS_SD1", "PN, PD, QTY",
998abc15 575 "SELECT PART_NUM, PART_DESC, QTY_ON_HAND * 1.1 FROM PARTS \
d0c6b305 576 WHERE STORAGE_DEVICE = 1");
3ca6a5f0
BP
577
578 // PARTS_SD1 can now be queried just as if it were a data table.
579 // e.g. SELECT PN, PD, QTY FROM PARTS_SD1
580\end{verbatim}
581
582
eea22fd5
GT
583\membersection{wxDb::Dbms}\label{wxdbdbms}
584
585\func{wxDBMS }{Dbms}{\void}
586
587\wxheading{Remarks}
588
589The return value will be of the enumerated type wxDBMS. This enumerated
590type contains a list of all the currently tested and supported databases.
591
c67d6048 592Additional databases may work with these classes, but the databases
107ffdc1 593returned by this function have been tested and confirmed to work with
eea22fd5
GT
594these ODBC classes.
595
107ffdc1 596Possible values returned by this function can be viewed in the
c67d6048 597\helpref{Enumerated types}{wxdbenumeratedtypes} section of wxDb.
eea22fd5
GT
598
599There are known issues with conformance to the ODBC standards with several
fc2171bd 600datasources supported by the wxWidgets ODBC classes. Please see the overview
c67d6048 601for specific details on which datasource have which issues.
eea22fd5
GT
602
603\wxheading{Return value}
604
107ffdc1 605The return value will indicate which of the supported datasources is
eea22fd5
GT
606currently connected to by this connection. In the event that the
607datasource is not recognized, a value of 'dbmsUNIDENTIFIED' is returned.
608
609
3ca6a5f0
BP
610\membersection{wxDb::DispAllErrors}\label{wxdbdispallerrors}
611
7af3ca16 612\func{bool}{DispAllErrors}{\param{HENV}{ aHenv}, \param{HDBC}{ aHdbc = SQL\_NULL\_HDBC}, \param{HSTMT}{ aHstmt = SQL\_NULL\_HSTMT}}
3ca6a5f0 613
107ffdc1
RD
614Used to log all database errors that occurred as a result of an executed
615database command. This logging is automatic and also includes debug logging
616when compiled in debug mode via \helpref{wxLogDebug}{wxlogdebug}. If logging
617is turned on via \helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging}, then an
c67d6048 618entry is also logged to the defined log file.
3ca6a5f0
BP
619
620\wxheading{Parameters}
621
c67d6048 622\docparam{aHenv}{Handle to the ODBC environment.}
d0c6b305 623
107ffdc1 624\docparam{aHdbc}{Handle to the ODBC connection. Pass this in if the ODBC
9fe17bd3 625function call that erred required a hdbc or hstmt argument.}
d0c6b305 626
e626d7c7 627\docparam{aHstmt}{Handle to the ODBC statement being executed against. Pass
feaca34f 628this in if the ODBC function call that failed required a hstmt argument.}
3ca6a5f0
BP
629
630\wxheading{Remarks}
631
107ffdc1
RD
632This member function will log all of the ODBC error messages for the last
633ODBC function call that was made. This function is normally used internally
634within the ODBC class library, but can be used programmatically after calling
c67d6048
GT
635ODBC functions directly (i.e. SQLFreeEnv()).
636
637\wxheading{Return value}
638
cc81d32f 639The function always returns false, so a call to this function can be made
107ffdc1 640in the return statement of a code block in the event of a failure to
c67d6048 641perform an action (see the example below).
3ca6a5f0
BP
642
643\wxheading{See also}
644
d0c6b305 645\helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging}, wxDbSqlLog
3ca6a5f0
BP
646
647\wxheading{Example}
d0c6b305 648
3ca6a5f0
BP
649\begin{verbatim}
650 if (SQLExecDirect(hstmt, (UCHAR FAR *) pSqlStmt, SQL_NTS) != SQL_SUCCESS)
651 // Display all ODBC errors for this stmt
652 return(db.DispAllErrors(db.henv, db.hdbc, hstmt));
653\end{verbatim}
654
3ca6a5f0
BP
655\membersection{wxDb::DispNextError}\label{wxdbdispnexterror}
656
657\func{void}{DispNextError}{\void}
658
659\wxheading{Remarks}
660
661This function is normally used internally within the ODBC class library.
c67d6048 662It could be used programmatically after calling ODBC functions directly. This
3ca6a5f0
BP
663function works in conjunction with \helpref{wxDb::GetNextError}{wxdbgetnexterror} when errors (or
664sometimes informational messages) returned from ODBC need to be analyzed
665rather than simply displaying them as an error. GetNextError() retrieves
666the next ODBC error from the ODBC error queue. The wxDb member variables
667"sqlState", "nativeError" and "errorMsg" could then be evaluated. To
668display the error retrieved, DispNextError() could then be called.
669The combination of GetNextError() and DispNextError() can be used to
670iteratively step through the errors returned from ODBC evaluating each
671one in context and displaying the ones you choose.
672
673\wxheading{Example}
d0c6b305 674
3ca6a5f0
BP
675\begin{verbatim}
676 // Drop the table before attempting to create it
677 sprintf(sqlStmt, "DROP TABLE %s", tableName);
678 // Execute the drop table statement
679 if (SQLExecDirect(hstmt,(UCHAR FAR *)sqlStmt,SQL_NTS) != SQL_SUCCESS)
680 {
681 // Check for sqlState = S0002, "Table or view not found".
682 // Ignore this error, bomb out on any other error.
683 pDb->GetNextError(henv, hdbc, hstmt);
9fe17bd3 684 if (wxStrcmp(pDb->sqlState, "S0002"))
3ca6a5f0
BP
685 {
686 pDb->DispNextError(); // Displayed error retrieved
687 pDb->DispAllErrors(henv, hdbc, hstmt); // Display all other errors, if any
688 pDb->RollbackTrans(); // Rollback the transaction
689 CloseCursor(); // Close the cursor
cc81d32f 690 return(false); // Return Failure
3ca6a5f0
BP
691 }
692 }
693\end{verbatim}
694
695
696\membersection{wxDb::DropView}\label{wxdbdropview}
697
7af3ca16 698\func{bool}{DropView}{\param{const wxString \&}{viewName}}
3ca6a5f0
BP
699
700Drops the data table view named in 'viewName'.
701
702\wxheading{Parameters}
703
704\docparam{viewName}{Name of the view to be dropped.}
705
706\wxheading{Remarks}
707
cc81d32f 708If the view does not exist, this function will return true. Note that views are not supported with all datasources.
3ca6a5f0 709
9eb11d19
VZ
710\membersection{wxDb::EscapeSqlChars}\label{wxdbescapesqlchars}
711
712\func{wxString}{EscapeSqlChars}{\param{const wxString\& }{value}}
713
714This function is used internally by wxWidgets while building SQL statements.
715It has been provided to help users who wish to explicity construct SQL
716statements to be sent to the server. The function takes the value passed and
717returns it with any special characters escaped. Which characters are
718considered special depends on what type of datasource the object is connected
719to. For example, most database servers use a backslash as the escape
720character; if the value passed contains a backlash it will be replaced with a
721double backslash before it is passed to the server. This function can be used
722to avoid passing statements with syntax errors to the server as well as prevent
723SQL injection attacks.
724
725\wxheading{Parameters}
726
727\docparam{value}{The value to be escaped.}
728
3ca6a5f0
BP
729\membersection{wxDb::ExecSql}\label{wxdbexecsql}
730
7af3ca16 731\func{bool}{ExecSql}{\param{const wxString \&}{pSqlStmt}}
3ca6a5f0 732
2b3c8795
VZ
733\func{bool}{ExecSql}{\param{const wxString \&}{pSqlStmt}, \param{wxDbColInf **}{columns}, \param{short \&}{numcols}}
734
3ca6a5f0
BP
735Allows 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.
736
2b3c8795
VZ
737To get column amount and column names or other information about returned columns, pass {\it 'columns'} and {\it 'numcols'} parameters to the function also.
738
3ca6a5f0
BP
739\wxheading{Parameters}
740
741\docparam{pSqlStmt}{Pointer to the SQL statement to be executed.}
742
2b3c8795
VZ
743\docparam{columns}{On success, this function will set this pointer to point to array of \helpref{wxDbColInf}{wxdbcolinf} objects, holding information about columns returned by the query. You need to call delete[] for the pointer you pass here after you don't use it anymore to prevent memory leak.}
744
745\docparam{numcols}{Reference to variable where amount of objects in {\it 'columns'}-parameter will be set.}
746
3ca6a5f0
BP
747\wxheading{Remarks}
748
749This member extends the wxDb class and allows you to build and execute ANY VALID
107ffdc1 750SQL statement against the datasource. This allows you to extend the class
c67d6048 751library by being able to issue any SQL statement that the datasource is capable
3ca6a5f0
BP
752of processing.
753
754\wxheading{See also}
755
756\helpref{wxDb::GetData}{wxdbgetdata}, \helpref{wxDb::GetNext}{wxdbgetnext}
757
19320af4
GT
758\membersection{wxDb::FwdOnlyCursors}\label{wxdbfwdonlycursors}
759
760\func{bool}{IsFwdOnlyCursors}{\void}
761
fc2171bd 762Older form (pre-2.3/2.4 of wxWidgets) of the
107ffdc1 763\helpref{wxDb::IsFwdOnlyCursors}{wxdbisfwdonlycursors}. This method is
2edb0bde 764provided for backward compatibility only. The method
107ffdc1
RD
765\helpref{wxDb::IsFwdOnlyCursors}{wxdbisfwdonlycursors} should be
766used in place of this method.
19320af4
GT
767
768
769\func{wxDbInf *}{GetCatalog}{\param{const wxChar *}{userID}}
770
3ca6a5f0
BP
771\membersection{wxDb::GetCatalog}\label{wxdbgetcatalog}
772
9fe17bd3 773\func{wxDbInf *}{GetCatalog}{\param{const wxChar *}{userID}}
3ca6a5f0 774
107ffdc1
RD
775Returns a \helpref{wxDbInf}{wxdbinf} pointer that points to the catalog
776(datasource) name, schema, number of tables accessible to the current user,
777and a wxDbTableInf pointer to all data pertaining to all tables in the users
c67d6048 778catalog.
3ca6a5f0
BP
779
780\wxheading{Parameters}
781
c67d6048 782\docparam{userID}{Owner/Schema 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
783
784\begin{verbatim}
785 userID == NULL ... UserID is ignored (DEFAULT)
786 userID == "" ... UserID set equal to 'this->uid'
787 userID != "" ... UserID set equal to 'userID'
788\end{verbatim}
789
790\wxheading{Remarks}
791
c67d6048 792The 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 to the connected user (permissions apply) via this connection will be returned.
3ca6a5f0 793
3ca6a5f0
BP
794\membersection{wxDb::GetColumnCount}\label{wxdbgetcolumncount}
795
7af3ca16 796\func{int }{GetColumnCount}{\param{const wxString \&}{tableName}, \param{const wxChar *}{userID}}
3ca6a5f0
BP
797
798\wxheading{Parameters}
799
c67d6048 800\docparam{tableName}{The table name you wish to obtain column information about.}
d0c6b305 801
107ffdc1
RD
802\docparam{userID}{Name of the user that owns the table(s) (also referred to as schema).
803Required for some datasources for situations where there may be multiple tables with the
804same name in the datasource, but owned by different users. {\it userID } is
19320af4 805evaluated in the following manner:}
3ca6a5f0
BP
806
807\begin{verbatim}
808 userID == NULL ... UserID is ignored (DEFAULT)
809 userID == "" ... UserID set equal to 'this->uid'
810 userID != "" ... UserID set equal to 'userID'
811\end{verbatim}
812
813\wxheading{Return value}
814
107ffdc1 815Returns a count of how many columns are in the specified table. If an error
c67d6048 816occurs retrieving the number of columns, this function will return a -1.
3ca6a5f0 817
3ca6a5f0
BP
818\membersection{wxDb::GetColumns}\label{wxdbgetcolumns}
819
7af3ca16 820\func{wxDbColInf *}{GetColumns}{\param{const wxString \&}{tableName}, \param{UWORD *}{numCols}, \param{const wxChar *}{userID=NULL}}
3ca6a5f0 821
9fe17bd3 822\func{wxDbColInf *}{GetColumns}{\param{wxChar *}{tableName[]}, \param{const wxChar *}{userID}}
3ca6a5f0
BP
823
824\wxheading{Parameters}
825
c67d6048 826\docparam{tableName}{The table name you wish to obtain column information about.}
0715c838 827\docparam{numCols}{Pointer to a UWORD which will hold a count of the number of columns returned by this function}
d0c6b305 828\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.}
c67d6048 829\docparam{userID}{Name of the user that owns the table(s) (also referred to as schema). 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
830
831\begin{verbatim}
832 userID == NULL ... UserID is ignored (DEFAULT)
833 userID == "" ... UserID set equal to 'this->uid'
834 userID != "" ... UserID set equal to 'userID'
835\end{verbatim}
836
837\wxheading{Return value}
838
107ffdc1
RD
839This function returns a pointer to an array of \helpref{wxDbColInf}{wxdbcolinf}
840structures, allowing you to obtain information regarding the columns of the
841named table(s). If no columns were found, or an error occurred, this pointer
c67d6048 842will be NULL.
3ca6a5f0
BP
843
844THE CALLING FUNCTION IS RESPONSIBLE FOR DELETING THE {\it wxDbColInf} MEMORY WHEN IT IS
845FINISHED WITH IT.
846
847\normalbox{ALL column bindings associated with this wxDb instance are unbound
107ffdc1 848by this function, including those used by any wxDbTable instances that use
c67d6048 849this wxDb instance. This function should use its own wxDb instance
3ca6a5f0
BP
850to avoid undesired unbinding of columns.}
851
852\wxheading{See also}
853
854\helpref{wxDbColInf}{wxdbcolinf}
855
856\wxheading{Example}
d0c6b305 857
3ca6a5f0 858\begin{verbatim}
9fe17bd3 859 wxChar *tableList[] = {"PARTS", 0};
3ca6a5f0
BP
860 wxDbColInf *colInf = pDb->GetColumns(tableList);
861 if (colInf)
862 {
863 // Use the column inf
864 .......
865 // Destroy the memory
866 delete [] colInf;
867 }
868\end{verbatim}
869
3ca6a5f0
BP
870\membersection{wxDb::GetData}\label{wxdbgetdata}
871
998abc15 872\func{bool}{GetData}{\param{UWORD}{ colNumber}, \param{SWORD}{ cType},
9fe17bd3 873\param{PTR}{ pData}, \param{SDWORD}{ maxLen}, \param{SDWORD FAR *}{ cbReturned} }
3ca6a5f0 874
107ffdc1 875Used to retrieve result set data without binding column values to memory
9fe17bd3 876variables (i.e. not using a wxDbTable instance to access table data).
3ca6a5f0
BP
877
878\wxheading{Parameters}
879
998abc15 880\docparam{colNumber}{Ordinal number of the desired column in the result set to be
9fe17bd3 881returned.}
107ffdc1 882\docparam{cType}{The C data type that is to be returned. See a partial list
9fe17bd3 883in \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}}
107ffdc1 884\docparam{pData}{Memory buffer which will hold the data returned by the call
9fe17bd3 885to this function.}
107ffdc1
RD
886\docparam{maxLen}{Maximum size of the buffer {\it 'pData'} in characters.
887NOTE: Not UNICODE safe. If this is a numeric field, a value of 0 may be
888passed for this parameter, as the API knows the size of the expected return
9fe17bd3 889value.}
107ffdc1
RD
890\docparam{cbReturned}{Pointer to the buffer containing the length of the
891actual data returned. If this value comes back as SQL\_NULL\_DATA, then the
19320af4 892\helpref{wxDb::GetData}{wxdbgetdata} call has failed.}
3ca6a5f0
BP
893
894\wxheading{See also}
895
896\helpref{wxDb::GetNext}{wxdbgetnext}, \helpref{wxDb::ExecSql}{wxdbexecsql}
897
107ffdc1 898\wxheading{Example}
d0c6b305 899
3ca6a5f0 900\begin{verbatim}
eea22fd5
GT
901 SDWORD cb;
902 ULONG reqQty;
903 wxString sqlStmt;
904 sqlStmt = "SELECT SUM(REQUIRED_QTY - PICKED_QTY) FROM ORDER_TABLE WHERE \
d0c6b305 905 PART_RECID = 1450 AND REQUIRED_QTY > PICKED_QTY";
3ca6a5f0 906
eea22fd5
GT
907 // Perform the query
908 if (!pDb->ExecSql(sqlStmt.c_str()))
909 {
910 // ERROR
911 return(0);
912 }
913
914 // Request the first row of the result set
915 if (!pDb->GetNext())
916 {
917 // ERROR
918 return(0);
919 }
920
107ffdc1 921 // Read column #1 of the row returned by the call to ::GetNext()
c67d6048 922 // and return the value in 'reqQty'
eea22fd5
GT
923 if (!pDb->GetData(1, SQL_C_ULONG, &reqQty, 0, &cb))
924 {
925 // ERROR
926 return(0);
927 }
928
929 // Check for a NULL result
930 if (cb == SQL_NULL_DATA)
931 return(0);
3ca6a5f0
BP
932\end{verbatim}
933
934\wxheading{Remarks}
935
936When requesting multiple columns to be returned from the result set (for example, the SQL query
eea22fd5 937requested 3 columns be returned), the calls to this function must request the columns in ordinal
107ffdc1 938sequence (1,2,3 or 1,3 or 2,3).
3ca6a5f0 939
3ca6a5f0
BP
940\membersection{wxDb::GetDatabaseName}\label{wxdbgetdatabasename}
941
9fe17bd3 942\func{const wxChar *}{GetDatabaseName}{\void}
3ca6a5f0
BP
943
944Returns the name of the database engine.
945
c67d6048 946\membersection{wxDb::GetDatasourceName}\label{wxdbgetdatasourcename}
3ca6a5f0 947
7af3ca16 948\func{const wxString \&}{GetDatasourceName}{\void}
3ca6a5f0
BP
949
950Returns the ODBC datasource name.
951
3ca6a5f0
BP
952\membersection{wxDb::GetHDBC}\label{wxdbgethdbc}
953
954\func{HDBC}{GetHDBC}{\void}
955
956Returns the ODBC handle to the database connection.
957
3ca6a5f0
BP
958\membersection{wxDb::GetHENV}\label{wxdbgethenv}
959
960\func{HENV}{GetHENV}{\void}
961
962Returns the ODBC environment handle.
963
3ca6a5f0
BP
964\membersection{wxDb::GetHSTMT}\label{wxdbgethstmt}
965
966\func{HSTMT}{GetHSTMT}{\void}
967
968Returns the ODBC statement handle associated with this database connection.
969
3ca6a5f0
BP
970\membersection{wxDb::GetKeyFields}\label{wxdbgetkeyfields}
971
998abc15 972\func{int }{GetKeyFields}{\param{const wxString \&}{tableName}, \param{wxDbColInf *}{colInf}, \param{UWORD }{numColumns}}
3ca6a5f0
BP
973
974Used 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.
975
d0c6b305 976This function is primarily for use by the \helpref{wxDb::GetColumns}{wxdbgetcolumns} function, but may be called if desired from the client application.
3ca6a5f0
BP
977
978\wxheading{Parameters}
979
980\docparam{tableName}{Name of the table for which the columns will be evaluated as to their inclusion in any indexes.}
d0c6b305 981\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.}
998abc15 982\docparam{numColumns}{Number of columns defined in the instance of colInf.}
3ca6a5f0
BP
983
984\wxheading{Return value}
985
cc81d32f 986Currently always returns true.
3ca6a5f0
BP
987
988\wxheading{See also}
989
990\helpref{wxDbColInf}{wxdbcolinf}, \helpref{wxDb::GetColumns}{wxdbgetcolumns}
991
3ca6a5f0
BP
992\membersection{wxDb::GetNext}\label{wxdbgetnext}
993
d0c6b305 994\func{bool}{GetNext}{\void}
3ca6a5f0 995
107ffdc1 996Called after executing a query, this function requests the next row
c67d6048 997in the result set after the current position of the cursor.
3ca6a5f0
BP
998
999\wxheading{See also}
1000
1001\helpref{wxDb::ExecSql}{wxdbexecsql}, \helpref{wxDb::GetData}{wxdbgetdata}
1002
3ca6a5f0
BP
1003\membersection{wxDb::GetNextError}\label{wxdbgetnexterror}
1004
107ffdc1 1005\func{bool}{GetNextError}{\param{HENV}{ aHenv},
e7240349 1006\param{HDBC}{ aHdbc = SQL\_NULL\_HDBC}, \param{HSTMT}{ aHstmt = SQL\_NULL\_HSTMT}}
3ca6a5f0
BP
1007
1008\wxheading{Parameters}
1009
1010\docparam{aHenv}{A handle to the ODBC environment.}
e626d7c7 1011\docparam{aHdbc}{{\it OPTIONAL.} A handle to the ODBC connection. Pass this
feaca34f 1012in if the ODBC function call that failed required a hdbc or hstmt argument.}
e626d7c7
RD
1013\docparam{AHstmt}{{\it OPTIONAL.}A handle to the ODBC statement being executed
1014against. Pass this in if the ODBC function call that failed requires a
9fe17bd3 1015hstmt argument.}
3ca6a5f0 1016
107ffdc1 1017\wxheading{Example}
d0c6b305 1018
3ca6a5f0
BP
1019\begin{verbatim}
1020 if (SQLExecDirect(hstmt, (UCHAR FAR *) pSqlStmt, SQL_NTS) != SQL_SUCCESS)
1021 {
feaca34f 1022 return(db.GetNextError(db.henv, db.hdbc, hstmt));
3ca6a5f0
BP
1023 }
1024\end{verbatim}
1025
9fe17bd3
GT
1026\wxheading{See also}
1027
107ffdc1 1028\helpref{wxDb::DispNextError}{wxdbdispnexterror},
9fe17bd3
GT
1029\helpref{wxDb::DispAllErrors}{wxdbdispallerrors}
1030
eea22fd5 1031
3ca6a5f0
BP
1032\membersection{wxDb::GetPassword}\label{wxdbgetpassword}
1033
7af3ca16 1034\func{const wxString \&}{GetPassword}{\void}
3ca6a5f0 1035
c67d6048
GT
1036Returns the password used to establish this connection to the datasource.
1037
3ca6a5f0 1038
3ca6a5f0
BP
1039\membersection{wxDb::GetTableCount}\label{wxdbgettablecount}
1040
c67d6048 1041\func{int }{GetTableCount}{\void}
3ca6a5f0 1042
107ffdc1 1043Returns the number of wxDbTable() instances currently using this datasource
9fe17bd3 1044connection.
3ca6a5f0 1045
eea22fd5 1046
3ca6a5f0
BP
1047\membersection{wxDb::GetUsername}\label{wxdbgetusername}
1048
7af3ca16 1049\func{const wxString \&}{GetUsername}{\void}
3ca6a5f0 1050
107ffdc1 1051Returns the user name (uid) used to establish this connection to the
9fe17bd3 1052datasource.
3ca6a5f0 1053
eea22fd5 1054
3ca6a5f0
BP
1055\membersection{wxDb::Grant}\label{wxdbgrant}
1056
107ffdc1 1057\func{bool}{Grant}{\param{int }{privileges}, \param{const wxString \&}{tableName},
7af3ca16 1058\param{const wxString \&}{userList = "PUBLIC"}}
3ca6a5f0 1059
107ffdc1 1060Use this member function to GRANT privileges to users for accessing tables in
9fe17bd3 1061the datasource.
3ca6a5f0
BP
1062
1063\wxheading{Parameters}
1064
107ffdc1
RD
1065\docparam{privileges}{Use this argument to select which privileges you want to
1066grant. Pass DB\_GRANT\_ALL to grant all privileges. To grant individual
9fe17bd3 1067privileges pass one or more of the following OR'd together:}
eea22fd5 1068
3ca6a5f0
BP
1069\begin{verbatim}
1070 DB_GRANT_SELECT = 1
1071 DB_GRANT_INSERT = 2
1072 DB_GRANT_UPDATE = 4
1073 DB_GRANT_DELETE = 8
1074 DB_GRANT_ALL = DB_GRANT_SELECT | DB_GRANT_INSERT |
1075 DB_GRANT_UPDATE | DB_GRANT_DELETE
1076\end{verbatim}
eea22fd5 1077
3ca6a5f0 1078\docparam{tableName}{The name of the table you wish to grant privileges on.}
c67d6048 1079\docparam{userList}{{\it OPTIONAL.} 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
1080
1081\wxheading{Remarks}
1082
1083Some 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.
1084
107ffdc1 1085The currently logged in user must have sufficient grantor privileges for this
c67d6048
GT
1086function to be able to successfully grant the indicated privileges.
1087
107ffdc1 1088\wxheading{Example}
d0c6b305 1089
3ca6a5f0
BP
1090\begin{verbatim}
1091 db.Grant(DB_GRANT_SELECT | DB_GRANT_INSERT, "PARTS", "mary, sue");
1092\end{verbatim}
1093
d0c6b305
GT
1094\membersection{wxDb::IsFwdOnlyCursors}\label{wxdbisfwdonlycursors}
1095
1096\func{bool}{IsFwdOnlyCursors}{\void}
1097
eea22fd5 1098This setting indicates whether this database connection was created
107ffdc1 1099as being capable of using only forward scrolling cursors.
c67d6048 1100
107ffdc1
RD
1101This function does NOT indicate if the ODBC driver or datasource supports
1102backward scrolling cursors. There is no standard way of detecting if the
c67d6048 1103driver or datasource can support backward scrolling cursors.
eea22fd5 1104
107ffdc1
RD
1105If a wxDb instance was created as being capable of only forward scrolling
1106cursors, then even if the datasource and ODBC driver support backward
1107scrolling cursors, tables using this database connection would only be able
c67d6048 1108to use forward scrolling cursors.
eea22fd5
GT
1109
1110The default setting of whether a wxDb connection to a database allows
107ffdc1 1111forward-only or also backward scrolling cursors is defined in setup.h by the
e7240349 1112value of wxODBC\_FWD\_ONLY\_CURSORS. This default setting can be overridden
107ffdc1 1113when the wxDb connection is initially created (see
b236c10f 1114\helpref{wxDb constructor}{wxdbctor} and \helpref{wxDbGetConnection}{wxdbfunctions}).
eea22fd5
GT
1115
1116\wxheading{Return value}
1117
cc81d32f
VS
1118Returns true if this datasource connection is defined as using only forward
1119scrolling cursors, or false if the connection is defined as being allowed to
c67d6048 1120use backward scrolling cursors and their associated functions (see note above).
d0c6b305
GT
1121
1122\wxheading{Remarks}
1123
fc2171bd
JS
1124Added as of wxWidgets v2.4 release, this function is a renamed version of
1125wxDb::FwdOnlyCursors() to match the normal wxWidgets naming conventions for
eea22fd5 1126class member functions.
d0c6b305 1127
107ffdc1 1128This function is not available in versions prior to v2.4. You should
fc2171bd 1129use \helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors} for wxWidgets
c67d6048 1130versions prior to 2.4.
d0c6b305
GT
1131
1132\wxheading{See also}
1133
b236c10f 1134\helpref{wxDb constructor}{wxdbctor}, \helpref{wxDbGetConnection}{wxdbfunctions}
eea22fd5 1135
3ca6a5f0
BP
1136\membersection{wxDb::IsOpen}\label{wxdbisopen}
1137
1138\func{bool}{IsOpen}{\void}
1139
107ffdc1 1140Indicates whether the database connection to the datasource is currently
eea22fd5
GT
1141opened.
1142
1143\wxheading{Remarks}
1144
107ffdc1
RD
1145This function may indicate that the database connection is open, even if
1146the call to \helpref{wxDb::Open}{wxdbopen} may have failed to fully
1147initialize the connection correctly. The connection to the database
1148{\it is} open and can be used via the direct SQL commands, if this
cc81d32f 1149function returns true. Other functions which depend on the
107ffdc1
RD
1150\helpref{wxDb::Open}{wxdbopen} to have completed correctly may not function
1151as expected. The return result from \helpref{wxDb::Open}{wxdbopen} is the
1152only way to know if complete initialization of this wxDb connection was
1153successful or not. See \helpref{wxDb::Open}{wxdbopen} for more details on
c67d6048 1154partial failures to open a connection instance.
eea22fd5 1155
eea22fd5
GT
1156\membersection{wxDb::LogError}\label{wxdblogerror}
1157
7af3ca16 1158\func{void}{LogError}{\param{const wxString \&}{errMsg} \param{const wxString \&}{SQLState=""}}
eea22fd5 1159
c67d6048
GT
1160\docparam{errMsg}{Free-form text to display describing the error/text to be logged.}
1161\docparam{SQLState}{{\it OPTIONAL.} Native SQL state error. Default is 0.}
eea22fd5
GT
1162
1163\wxheading{Remarks}
1164
1165Calling this function will enter a log message in the error list maintained
1166for the database connection. This log message is free form and can be
1167anything the programmer wants to enter in the error list.
1168
1169If SQL logging is turned on, the call to this function will also log the
1170text into the SQL log file.
1171
1172\wxheading{See also}
1173
1174\helpref{wxDb::WriteSqlLog}{wxdbwritesqllog}
1175
9fe17bd3
GT
1176\membersection{wxDb::ModifyColumn}\label{wxdbmodifycolumn}
1177
107ffdc1 1178\func{void}{ModifyColumn}{\param{const wxString \&}{tableName} \param{const wxString \&}{ColumnName}
7af3ca16 1179\param{int }{dataType} \param{ULONG }{columnLength=0} \param{const wxString \&}{optionalParam=""}}
9fe17bd3 1180
107ffdc1 1181Used to change certain properties of a column such as the length, or whether a column
9fe17bd3
GT
1182allows NULLs or not.
1183
1184\docparam{tableName}{Name of the table that the column to be modified is in.}
107ffdc1 1185\docparam{columnName}{Name of the column to be modified. NOTE: Name of column cannot
9fe17bd3 1186be changed with this function.}
107ffdc1 1187\docparam{dataType}{Any one of DB\_DATA\_TYPE\_VARCHAR, DB\_DATA\_TYPE\_INTEGER,
e7240349 1188DB\_DATA\_TYPE\_FLOAT, DB\_DATA\_TYPE\_DATE.}
107ffdc1 1189\docparam{columnLength}{New size of the column. Valid only for DB\_DATA\_TYPE\_VARCHAR
9fe17bd3
GT
1190dataType fields. Default is 0.}
1191\docparam{optionalParam}{Default is "".}
1192
1193\wxheading{Remarks}
1194
107ffdc1 1195Cannot be used to modify the precision of a numeric column, therefore 'columnLength'
e7240349 1196is ignored unless the dataType is DB\_DATA\_TYPE\_VARCHAR.
9fe17bd3 1197
107ffdc1
RD
1198Some datasources do not allow certain properties of a column to be changed if any rows
1199currently have data stored in that column. Those datasources that do allow columns
1200to be changed with data in the rows many handle truncation and/or expansion in
1201different ways. Please refer to the reference material for the datasource being
9fe17bd3
GT
1202used for behavioral descriptions.
1203
1204\wxheading{Example}
1205
1206\begin{verbatim}
1207 ok = pDb->ModifyColumn("CONTACTS", "ADDRESS2",
1208 DB_, colDefs[j].SzDataObj,
1209 wxT("NOT NULL"));
1210\end{verbatim}
1211
1212
3ca6a5f0
BP
1213\membersection{wxDb::Open}\label{wxdbopen}
1214
107ffdc1 1215\func{bool}{Open}{\param{const wxString \&}{Dsn}, \param{const wxString \&}{Uid},
f9af4e76
GT
1216\param{const wxString \&}{AuthStr}, \param{bool }{failOnDataTypeUnsupported}}
1217
1218\func{bool}{Open}{\param{const wxString \&}{inConnectStr},
1219\param{bool }{failOnDataTypeUnsupported}}
1220
1221\func{bool}{Open}{\param{wxDbConnectInf *}{dbConnectInf},
1222\param{bool }{failOnDataTypeUnsupported}}
c67d6048 1223
eea22fd5
GT
1224\func{bool}{Open}{\param{wxDb *}{copyDb}}
1225
107ffdc1
RD
1226Opens a connection to the datasource, sets certain behaviors of the datasource
1227to confirm to the accepted behaviors (e.g. cursor position maintained on
1228commits), and queries the datasource for its representations of the basic
1229datatypes to determine the form in which the data going to/from columns in
c67d6048 1230the data tables are to be handled.
eea22fd5 1231
107ffdc1
RD
1232The second form of this function, which accepts a "wxDb *" as a parameter,
1233can be used to avoid the overhead (execution time, database load, network
1234traffic) which are needed to determine the data types and representations
1235of data that are necessary for cross-datasource support by these classes.
1236
1237Normally the first form of the wxDb::Open() function will open the connection
1238and then send a series of queries to the datasource asking it for its
1239representation of data types, and all the features it supports. If one
1240connection to the datasource has already been made previously, the information
1241gathered when that connection was created can just be copied to any new
1242connections to the same datasource by passing a pointer to the first
1243connection in as a parameter to the wxDb::Open() function. Note that this
1244new connection created from the first connections information will use the
eea22fd5 1245same Dsn/Uid/AuthStr as the first connection used.
3ca6a5f0
BP
1246
1247\wxheading{Parameters}
1248
107ffdc1
RD
1249\docparam{Dsn}{datasource name. The name of the ODBC datasource as
1250assigned when the datasource is initially set up through the ODBC data
3ca6a5f0
BP
1251source manager.}
1252\docparam{Uid}{User ID. The name (ID) of the user you wish to connect as
c67d6048 1253to the datasource. The user name (ID) determines what objects you
3ca6a5f0
BP
1254have access to in the datasource and what datasource privileges you have.
1255Privileges include being able to create new objects, update objects, delete
1256objects and so on. Users and privileges are normally administered by the
1257database administrator.}
eea22fd5 1258\docparam{AuthStr}{The password associated with the Uid.}
f9af4e76
GT
1259\docparam{failOnDataTypeUnsupporte}{As part of connecting to a database, the
1260wxDb::Open() function will query the database to find out the native types
1261that it supports. With some databases, some data types may not be supported,
1262or not sufficiently supported, for use with the wxODBC classes. Normally
1263a program should fail in this case, so as not to try to use a data type
1264that is not supported. This parameter allows the programmer to override the
1265failure if they wish and continue on using the connection.}
1266\docparam{dbConnectInf}{Contains a DSN, Uid, Password, or a connection string
1267to be used in opening a new connection to the database. If a connection
1268string is present, then the connection string will be used. If there is no
1269connection string present, then the DSN, Uid, and Password are used.}
1270\docparam{inConnectStr}{A valid ODBC connection string used to connect to a
1271database}
1272\docparam{copyDb}{Already completely configured and opened datasource
1273connection from which all Dsn, Uid, AuthStr, connection string, and data
1274typing information is to be copied from for use by this datasource
1275connection. If 'copyDb' used a connection string to create its connection
1276originally, then the connection being made by this call to wxDb::Open() will
1277use that same connection string.}
eea22fd5
GT
1278
1279\wxheading{Remarks}
1280
107ffdc1
RD
1281After a wxDb instance is created, it must then be opened. When opening a
1282datasource, there must be three pieces of information passed. The data
1283source name, user name (ID) and the password for the user. No database
1284activity on the datasource can be performed until the connection is opened.
1285This is normally done at program startup and the datasource remains
1286open for the duration of the program/module run.
eea22fd5 1287
107ffdc1
RD
1288It is possible to have connections to multiple datasources open at the same
1289time to support distributed database connections by having separate instances
c67d6048 1290of wxDb objects that use either the same or different Dsn/Uid/AuthStr settings.
eea22fd5 1291
cc81d32f 1292If this function returns a value of false, it does not necessarily mean that
107ffdc1
RD
1293the connection to the datasource was not opened. It may mean that some
1294portion of the initialization of the connection failed (such as a datatype not
1295being able to be determined how the datasource represents it). To determine
1296if the connection to the database failed, use the \helpref{wxDb::IsOpen}{wxdbisopen}
cc81d32f
VS
1297function after receiving a false result back from this function to determine if
1298the connection was opened or not. If this function returns false, but \helpref{wxDb::IsOpen}{wxdbisopen}
1299returns true, then direct SQL commands may be passed to the database
107ffdc1
RD
1300connection and can be successfully executed, but use of the datatypes (such as
1301by a wxDbTable instance) that are normally determined during open will not be
c67d6048
GT
1302possible.
1303
107ffdc1
RD
1304\normalbox{The {\it Dsn}, {\it Uid}, and {\it AuthStr} string pointers that are passed in
1305are copied. NOT the strings themselves, only the pointers. The calling routine
c67d6048 1306must maintain the memory for these three strings for the life of the wxDb instance.}
3ca6a5f0
BP
1307
1308\wxheading{Example}
d0c6b305 1309
3ca6a5f0 1310\begin{verbatim}
9fe17bd3 1311 wxDb sampleDB(DbConnectInf.GetHenv());
3ca6a5f0
BP
1312 if (!sampleDB.Open("Oracle 7.1 HP/UX", "gtasker", "myPassword"))
1313 {
c67d6048
GT
1314 if (sampleDb.IsOpen())
1315 {
107ffdc1 1316 // Connection is open, but the initialization of
c67d6048
GT
1317 // datatypes and parameter settings failed
1318 }
1319 else
1320 {
1321 // Error opening datasource
1322 }
3ca6a5f0
BP
1323 }
1324\end{verbatim}
1325
3ca6a5f0
BP
1326\membersection{wxDb::RollbackTrans}\label{wxdbrollbacktrans}
1327
1328\func{bool}{RollbackTrans}{\void}
1329
c67d6048 1330Function to "undo" 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.
3ca6a5f0
BP
1331
1332\wxheading{Remarks}
1333
107ffdc1
RD
1334Transactions begin implicitly as soon as you make a change to the database. The
1335transaction continues until either a commit or rollback is executed. Calling
1336wxDb::RollbackTrans() will result in ALL changes done using this database
1337connection that have not already been committed to be "undone" back to the last
c67d6048 1338commit/rollback that was successfully executed.
3ca6a5f0 1339
107ffdc1
RD
1340\normalbox{Calling this member function rolls back ALL open (uncommitted)
1341transactions on this ODBC connection, including all wxDbTable instances that
c67d6048 1342use this connection.}
3ca6a5f0
BP
1343
1344\wxheading{See also}
1345
1346\helpref{wxDb::CommitTrans}{wxdbcommittrans} for a special note on cursors
1347
eea22fd5
GT
1348\membersection{wxDb::SetDebugErrorMessages}\label{wxdbsetdebugerrormessages}
1349
1350\func{void}{SetDebugErrorMessages}{\param{bool }{state}}
1351
cc81d32f 1352\docparam{state}{Either true (debug messages are logged) or false (debug
19320af4 1353messages are not logged).}
eea22fd5
GT
1354
1355\wxheading{Remarks}
1356
1357Turns on/off debug error messages from the ODBC class library. When
cc81d32f
VS
1358this function is passed true, errors are reported to the user/logged automatically
1359in a text or pop-up dialog when an ODBC error occurs. When passed false,
eea22fd5
GT
1360errors are silently handled.
1361
1362When compiled in release mode (FINAL=1), this setting has no affect.
1363
1364\wxheading{See also}
1365
b236c10f 1366\helpref{wxDb constructor}{wxdbctor}
eea22fd5 1367
3ca6a5f0
BP
1368\membersection{wxDb::SetSqlLogging}\label{wxdbsetsqllogging}
1369
cc81d32f 1370\func{bool}{SetSqlLogging}{\param{wxDbSqlLogState}{ state}, \param{const wxString \&}{filename = SQL\_LOG\_FILENAME}, \param{bool }{ append = false}}
3ca6a5f0
BP
1371
1372\wxheading{Parameters}
1373
c67d6048 1374\docparam{state}{Either sqlLogOFF or sqlLogON (see \helpref{enum wxDbSqlLogState}{wxdbcolfor}). Turns logging of SQL commands sent to the datasource OFF or ON.}
e7240349 1375\docparam{filename}{{\it OPTIONAL}. Name of the file to which the log text is to be written. Default is SQL\_LOG\_FILENAME.}
cc81d32f 1376\docparam{append}{{\it OPTIONAL}. Whether the file is appended to or overwritten. Default is false.}
3ca6a5f0
BP
1377
1378\wxheading{Remarks}
1379
19320af4 1380When called with {\it sqlLogON}, all commands sent to the datasource engine are logged to the file specified by {\it filename}. Logging is done by embedded \helpref{wxDb::WriteSqlLog}{wxdbwritesqllog} calls in the database member functions, or may be manually logged by adding calls to \helpref{wxDb::WriteSqlLog}{wxdbwritesqllog} in your own source code.
3ca6a5f0 1381
c67d6048 1382When called with {\it sqlLogOFF}, the logging file is closed, and any calls to \helpref{wxDb::WriteSqlLog}{wxdbwritesqllog} are ignored.
3ca6a5f0 1383
32d77178
GT
1384\membersection{wxDb::SQLColumnName}\label{wxdbsqlcolumnname}
1385
1386\func{const wxString}{SQLColumnName}{\param{const char *}{ colName}}
1387
107ffdc1 1388Returns the column name in a form ready for use in SQL statements.
32d77178 1389In most cases, the column name is returned verbatim. But some databases
107ffdc1 1390(e.g. MS Access, SQL Server, MSDE) allow for spaces in column names, which
32d77178 1391must be specially quoted. For example, if the datasource allows spaces
107ffdc1
RD
1392in the column name, the returned string will have the correct enclosing
1393marks around the name to allow it to be properly included in a SQL statement
32d77178
GT
1394for the DBMS that is currently connected to with this connection.
1395
1396\wxheading{Parameters}
1397
107ffdc1
RD
1398\docparam{colName}{Native name of the column in the table that is to be
1399evaluated to determine if any special quoting marks needed to be added to it
32d77178
GT
1400before including the column name in a SQL statement}
1401
1402\wxheading{See also}
1403
1404\helpref{wxDb::SQLTableName}{wxdbsqltablename}
1405
32d77178
GT
1406\membersection{wxDb::SQLTableName}\label{wxdbsqltablename}
1407
1408\func{const wxString}{SQLTableName}{\param{const char *}{ tableName}}
1409
107ffdc1 1410Returns the table name in a form ready for use in SQL statements.
32d77178 1411In most cases, the table name is returned verbatim. But some databases
107ffdc1 1412(e.g. MS Access, SQL Server, MSDE) allow for spaces in table names, which
32d77178 1413must be specially quoted. For example, if the datasource allows spaces
107ffdc1
RD
1414in the table name, the returned string will have the correct enclosing
1415marks around the name to allow it to be properly included in a SQL statement
32d77178
GT
1416for the data source that is currently connected to with this connection.
1417
1418\wxheading{Parameters}
1419
107ffdc1
RD
1420\docparam{tableName}{Native name of the table that is to be evaluated to
1421determine if any special quoting marks needed to be added to it
32d77178
GT
1422before including the table name in a SQL statement}
1423
1424\wxheading{See also}
1425
1426\helpref{wxDb::SQLColumnName}{wxdbsqlcolumnname}
1427
59990c22 1428\membersection{wxDb::TableExists}\label{wxdbtableexists}
3ca6a5f0 1429
7af3ca16 1430\func{bool}{TableExists}{\param{const wxString \&}{tableName}, \param{const wxChar *}{userID=NULL}, \param{const wxString \&}{path=""}}
3ca6a5f0 1431
107ffdc1
RD
1432Checks the ODBC datasource for the existence of a table. If a {\it userID}
1433is specified, then the table must be accessible by that user (user must have
eea22fd5 1434at least minimal privileges to the table).
3ca6a5f0
BP
1435
1436\wxheading{Parameters}
1437
c67d6048
GT
1438\docparam{tableName}{Name of the table to check for the existence of.}
1439\docparam{userID}{Owner of the table (also referred to as schema). Specify a userID when the datasource you are connected
3ca6a5f0
BP
1440to allows multiple unique tables with the same name to be owned by different users. {\it userID}
1441is evaluated as follows:}
1442
1443\begin{verbatim}
1444 userID == NULL ... UserID is ignored (DEFAULT)
1445 userID == "" ... UserID set equal to 'this->uid'
1446 userID != "" ... UserID set equal to 'userID'
1447\end{verbatim}
1448
1449\wxheading{Remarks}
1450
1451{\it tableName} may refer to a table, view, alias or synonym.
1452
c67d6048 1453This function does not indicate whether or not the user has privileges to query or perform other functions on the table. Use the \helpref{wxDb::TablePrivileges}{wxdbtableprivileges} to determine if the user has sufficient privileges or not.
3ca6a5f0 1454
eea22fd5
GT
1455\wxheading{See also}
1456
1457\helpref{wxDb::TablePrivileges}{wxdbtableprivileges}
1458
eea22fd5
GT
1459\membersection{wxDb::TablePrivileges}\label{wxdbtableprivileges}
1460
107ffdc1
RD
1461\func{bool}{TablePrivileges}{\param{const wxString \&}{tableName}, \param{const wxString \&}{priv},
1462\param{const wxChar *}{userID=NULL}, \param{const wxChar *}{schema=NULL},
7af3ca16 1463\param{const wxString \&}{path=""}}
eea22fd5 1464
107ffdc1
RD
1465Checks the ODBC datasource for the existence of a table. If a {\it userID}
1466is specified, then the table must be accessible by that user (user must have
eea22fd5
GT
1467at least minimal privileges to the table).
1468
1469\wxheading{Parameters}
1470
107ffdc1 1471\docparam{tableName}{Name of the table on which to check privileges.
eea22fd5 1472{\it tableName} may refer to a table, view, alias or synonym.}
107ffdc1 1473\docparam{priv}{The table privilege being evaluated. May be one of the
bf43ff9a 1474following (or a datasource specific privilege):}
05dedde7 1475
eea22fd5 1476\begin{verbatim}
107ffdc1 1477 SELECT : The connected user is permitted to retrieve data for
c67d6048 1478 one or more columns of the table.
eea22fd5 1479
107ffdc1
RD
1480 INSERT : The connected user is permitted to insert new rows
1481 containing data for one or more columns into the
c67d6048 1482 table.
eea22fd5 1483
107ffdc1 1484 UPDATE : The connected user is permitted to update the data in
c67d6048 1485 one or more columns of the table.
eea22fd5 1486
107ffdc1 1487 DELETE : The connected user is permitted to delete rows of
c67d6048 1488 data from the table.
eea22fd5 1489
107ffdc1
RD
1490 REFERENCES : Is the connected user permitted to refer to one or
1491 more columns of the table within a constraint (for
1492 example, a unique, referential, or table check
c67d6048 1493 constraint).
eea22fd5 1494\end{verbatim}
bf43ff9a 1495
107ffdc1
RD
1496\docparam{userID}{{\it OPTIONAL.} User for which to determine if the privilege
1497specified to be checked is granted or not. Default is "".
bf43ff9a 1498{\it userID} is evaluated as follows:}
05dedde7 1499
eea22fd5 1500\begin{verbatim}
c67d6048 1501 userID == NULL ... NOT ALLOWED!
eea22fd5
GT
1502 userID == "" ... UserID set equal to 'this->uid'
1503 userID != "" ... UserID set equal to 'userID'
1504\end{verbatim}
bf43ff9a 1505
107ffdc1
RD
1506\docparam{schema}{{\it OPTIONAL.} Owner of the table. Specify a userID when the datasource
1507you are connected to allows multiple unique tables with the same name to be
1508owned by different users. Specifying the table owner makes determination of the
bf43ff9a
VZ
1509users privileges MUCH faster. Default is NULL. {\it userID} is
1510evaluated as follows:}
05dedde7 1511
c67d6048
GT
1512\begin{verbatim}
1513 schema == NULL ... Any owner (DEFAULT)
1514 schema == "" ... Owned by 'this->uid'
1515 schema != "" ... Owned by userID specified in 'schema'
1516\end{verbatim}
bf43ff9a 1517
107ffdc1 1518\docparam{path}{{\it OPTIONAL.} Path to the table. Default is "".
eea22fd5
GT
1519Currently unused.}
1520
1521\wxheading{Remarks}
1522
107ffdc1
RD
1523The scope of privilege allowed to the connected user by a given table
1524privilege is datasource dependent.
eea22fd5 1525
107ffdc1
RD
1526For example, the privilege UPDATE might allow the connected user to update
1527all columns in a table on one datasource, but only those columns for
1528which the grantor (the user that granted the connected user) has the UPDATE
c67d6048 1529privilege on another datasource.
eea22fd5 1530
107ffdc1
RD
1531Looking up a user's privileges to a table can be time consuming depending on the
1532datasource and ODBC driver. This time can be minimized by passing a {\it schema}
1533as a parameter. With some datasources/drivers, the difference can be several
59990c22
GT
1534seconds of time difference.
1535
eea22fd5 1536
3ca6a5f0
BP
1537\membersection{wxDb::TranslateSqlState}\label{wxdbtranslatesqlstate}
1538
7af3ca16 1539\func{int }{TranslateSqlState}{\param{const wxString \&}{SQLState}}
c67d6048
GT
1540
1541Converts an ODBC sqlstate to an internal error code.
3ca6a5f0
BP
1542
1543\wxheading{Parameters}
1544
c67d6048 1545\docparam{SQLState}{State to be converted.}
3ca6a5f0
BP
1546
1547\wxheading{Return value}
1548
e7240349 1549Returns the internal class DB\_ERR code. See \helpref{wxDb::DB\_STATUS}{wxdb} definition.
3ca6a5f0
BP
1550
1551\membersection{wxDb::WriteSqlLog}\label{wxdbwritesqllog}
1552
7af3ca16 1553\func{bool}{WriteSqlLog}{\param{const wxString \&}{logMsg}}
3ca6a5f0
BP
1554
1555\wxheading{Parameters}
1556
1557\docparam{logMsg}{Free form string to be written to the log file.}
1558
1559\wxheading{Remarks}
1560
107ffdc1
RD
1561Very useful debugging tool that may be turned on/off during run time (see
1562(see \helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging} for details on
1563turning logging on/off). The passed in string {\it logMsg} will be written to
c67d6048 1564a log file if SQL logging is turned on.
3ca6a5f0
BP
1565
1566\wxheading{Return value}
1567
1568If SQL logging is off when a call to WriteSqlLog() is made, or there is a
1569failure to write the log message to the log file, the function returns
cc81d32f 1570false without performing the requested log, otherwise true is returned.
3ca6a5f0
BP
1571
1572\wxheading{See also}
1573
1574\helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging}
1575
eea22fd5 1576\section{\class{wxDbColDataPtr}}\label{wxdbcoldataptr}
3ca6a5f0 1577
107ffdc1 1578Pointer to dynamic column definitions for use with a wxDbTable instance.
eea22fd5 1579Currently there are no member functions for this class.
3ca6a5f0 1580
2564094b
JS
1581See the \helpref{database classes overview}{odbcoverview} for
1582an introduction to using the ODBC classes.
1583
3ca6a5f0 1584\begin{verbatim}
eea22fd5
GT
1585 void *PtrDataObj;
1586 int SzDataObj;
0715c838 1587 SWORD SqlCtype;
3ca6a5f0
BP
1588\end{verbatim}
1589
eea22fd5 1590\section{\class{wxDbColDef}}\label{wxdbcoldef}
3ca6a5f0 1591
107ffdc1
RD
1592This class is used to hold information about the columns bound to an
1593instance of a wxDbTable object.
1594
1595Each instance of this class describes one column in the wxDbTable
b236c10f 1596object. When calling the \helpref{wxDb constructor}{wxdbctor}, a
107ffdc1
RD
1597parameter passed in indicates the number of columns that will be defined for
1598the wxDbTable object. The constructor uses this information to allocate
1599adequate memory for all of the column descriptions in your wxDbTable object.
1600Private member wxDbTable::colDefs is a pointer to this chunk of memory
1601maintained by the wxDbTable class (and can be retrieved using the
1602\helpref{wxDbTable::GetColDefs}{wxdbtablegetcoldefs} function).
1603To access the nth column definition of your wxDbTable object, just reference
eea22fd5 1604wxDbColDefs element [n - 1].
3ca6a5f0 1605
107ffdc1 1606Typically, \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs} is used to
c67d6048 1607populate an array of these data structures for the wxDbTable instance.
3ca6a5f0 1608
107ffdc1 1609Currently there are no accessor functions for this class, so all members are
19320af4
GT
1610public.
1611
eea22fd5 1612\begin{verbatim}
9fe17bd3 1613 wxChar ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name
107ffdc1 1614 int DbDataType; - Logical Data Type;
c67d6048 1615 e.g. DB_DATA_TYPE_INTEGER
0715c838 1616 SWORD SqlCtype; - C data type; e.g. SQL_C_LONG
eea22fd5
GT
1617 void *PtrDataObj; - Address of the data object
1618 int SzDataObj; - Size, in bytes, of the data object
1619 bool KeyField; - Is column part of the PRIMARY KEY for the
107ffdc1 1620 table? -- Date fields should NOT be
c67d6048 1621 KeyFields
eea22fd5
GT
1622 bool Updateable; - Column is updateable?
1623 bool InsertAllowed; - Column included in INSERT statements?
1624 bool DerivedCol; - Column is a derived value?
1625 SDWORD CbValue; - !!!Internal use only!!!
1626 bool Null; - NOT FULLY IMPLEMENTED
1627 Allows NULL values in Inserts and Updates
1628\end{verbatim}
3ca6a5f0
BP
1629
1630\wxheading{See also}
1631
107ffdc1 1632\helpref{database classes overview}{odbcoverview},
b236c10f 1633\helpref{wxDbTable::GetColDefs}{wxdbtablegetcoldefs}, \helpref{wxDb constructor}{wxdbctor}
3ca6a5f0 1634
0e10e38d
VZ
1635\wxheading{Include files}
1636
1637<wx/db.h>
1638
1639\latexignore{\rtfignore{\wxheading{Members}}}
1640
19320af4
GT
1641\membersection{wxDbColDef::Initialize}\label{wxdbcoldefinitialize}
1642
107ffdc1 1643Simply initializes all member variables to a cleared state. Called by
19320af4
GT
1644the constructor automatically.
1645
f3845e88
VZ
1646\section{\class{wxDbColFor}}\label{wxdbcolfor}
1647
107ffdc1
RD
1648Beginning support for handling international formatting specifically on dates
1649and floats.
f3845e88
VZ
1650
1651\begin{verbatim}
90e572f1
MR
1652 wxString s_Field; // Formatted String for Output
1653 wxString s_Format[7]; // Formatted Objects - TIMESTAMP has
f3845e88 1654 the biggest (7)
90e572f1 1655 wxString s_Amount[7]; // Formatted Objects - amount of
f3845e88 1656 things that can be formatted
90e572f1 1657 int i_Amount[7]; // Formatted Objects -
f3845e88
VZ
1658 TT MM YYYY HH MM SS m
1659 int i_Nation; // 0 = timestamp
1660 1 = EU
1661 2 = UK
1662 3 = International
1663 4 = US
1664 int i_dbDataType; // conversion of the 'sqlDataType'
1665 to the generic data type used by
1666 these classes
1667 SWORD i_sqlDataType;
1668\end{verbatim}
1669
1670The constructor for this class initializes all the values to zero or NULL.
1671
1672The destructor does nothing at this time.
1673
2564094b 1674Only one function is provided with this class currently.
f3845e88 1675
2564094b
JS
1676See the \helpref{database classes overview}{odbcoverview} for
1677an introduction to using the ODBC classes.
f3845e88 1678
0e10e38d
VZ
1679\wxheading{Include files}
1680
1681<wx/db.h>
1682
1683\latexignore{\rtfignore{\wxheading{Members}}}
1684
f3845e88
VZ
1685\membersection{wxDbColFor::Format}\label{wxdbcolforformat}
1686
107ffdc1
RD
1687\func{int }{Format}{\param{int }{Nation}, \param{int }{dbDataType},
1688\param{SWORD }{sqlDataType}, \param{short }{columnSize},
f3845e88
VZ
1689\param{short }{decimalDigits}}\label{wxdbcolforformat}
1690
1691Work in progress, and should be inter-related with wxLocale eventually.
1692
f3845e88
VZ
1693\membersection{wxDbColFor::Initialize}\label{wxdbcolforinitialize}
1694
107ffdc1 1695Simply initializes all member variables to a cleared state. Called by
f3845e88
VZ
1696the constructor automatically.
1697
d0c6b305
GT
1698\section{\class{wxDbColInf}}\label{wxdbcolinf}
1699
c67d6048
GT
1700Used with the \helpref{wxDb::GetColumns}{wxdbgetcolumns} functions for obtaining all retrievable information about a column's definition.
1701
1702\begin{verbatim}
9fe17bd3
GT
1703 wxChar catalog[128+1];
1704 wxChar schema[128+1];
1705 wxChar tableName[DB_MAX_TABLE_NAME_LEN+1];
1706 wxChar colName[DB_MAX_COLUMN_NAME_LEN+1];
c67d6048 1707 SWORD sqlDataType;
9fe17bd3 1708 wxChar typeName[128+1];
c67d6048
GT
1709 SWORD columnSize;
1710 SWORD bufferLength;
1711 short decimalDigits;
1712 short numPrecRadix;
1713 short nullable;
9fe17bd3 1714 wxChar remarks[254+1];
107ffdc1
RD
1715 int dbDataType; // conversion of the 'sqlDataType'
1716 // to the generic data type used by
c67d6048
GT
1717 // these classes
1718 int PkCol; // Primary key column
1719 0 = No
1720 1 = First Key
1721 2 = Second Key, etc...
9fe17bd3 1722 wxChar PkTableName[DB_MAX_TABLE_NAME_LEN+1];
c67d6048
GT
1723 // Tables that use this PKey as a FKey
1724 int FkCol; // Foreign key column
1725 0 = No
1726 1 = First Key
1727 2 = Second Key, etc...
107ffdc1 1728 wxChar FkTableName[DB_MAX_TABLE_NAME_LEN+1];
c67d6048
GT
1729 // Foreign key table name
1730 wxDbColFor *pColFor; // How should this column be formatted
1731\end{verbatim}
1732
9fe17bd3 1733The constructor for this class initializes all the values to zero, "", or NULL.
c67d6048 1734
107ffdc1 1735The destructor for this class takes care of deleting the pColFor member if
c67d6048 1736it is non-NULL.
d0c6b305 1737
2564094b
JS
1738See the \helpref{database classes overview}{odbcoverview} for
1739an introduction to using the ODBC classes.
eea22fd5 1740
0e10e38d
VZ
1741\wxheading{Include files}
1742
1743<wx/db.h>
1744
1745\latexignore{\rtfignore{\wxheading{Members}}}
1746
19320af4
GT
1747\membersection{wxDbColInf::Initialize}\label{wxdbcolinfinitialize}
1748
107ffdc1 1749Simply initializes all member variables to a cleared state. Called by
19320af4
GT
1750the constructor automatically.
1751
9fe17bd3
GT
1752\section{\class{wxDbConnectInf}}\label{wxdbconnectinf}
1753
107ffdc1
RD
1754This class is used for holding the data necessary for connecting to the ODBC
1755datasource. That information includes: SQL environment handle, datasource
1756name, user ID, password and default directory path (used with dBase). Other
1757optional fields held in this class are and file type, both for future
9fe17bd3
GT
1758functions planned to be added for creating/manipulating datasource definitions.
1759
b236c10f 1760\membersection{wxDbConnectInf::wxDbConnectInf}\label{wxdbconnectinfctor}
2564094b 1761
9fe17bd3
GT
1762\func{}{wxDbConnectInf}{\void}
1763
1764Default constructor.
1765
e626d7c7
RD
1766\func{}{wxDbConnectInf}{\param{HENV }{henv}, \param{const wxString \&}{dsn},
1767\param{const wxString \&}{userID=""}, \param{const wxString \&}{password},
1768\param{const wxString \&}{defaultDir=""}, \param{const wxString \&}{description=""},
7af3ca16 1769\param{const wxString \&}{fileType=""}}
9fe17bd3
GT
1770
1771Constructor which allows initial settings of all the classes member variables.
1772
107ffdc1
RD
1773See the special note below on the henv parameter for forcing this constructor
1774to create a SQL environment handle automatically, rather than needing to pass
9fe17bd3
GT
1775one in to the function.
1776
1777\wxheading{Parameters}
1778
c140b7e7 1779\docparam{henv}{Environment handle used for this connection. See\rtfsp
107ffdc1
RD
1780\helpref{wxDConnectInf::AllocHenv}{wxdbconnectinfallochenv} for how to create
1781an SQL environment handle. NOTE: Passing in a NULL for this parameter will
1782inform the constructor that it should create its own SQL environment handle.
c140b7e7 1783If NULL is passed for this parameter, the constructor will call\rtfsp
107ffdc1
RD
1784\helpref{wxDConnectInf::AllocHenv}{wxdbconnectinfallochenv} internally. A
1785flag is set internally also to indicate that the HENV was created by the
1786constructor so that when the default class destructor is called, the
c140b7e7 1787destructor will call \helpref{wxDConnectInf::FreeHenv}{wxdbconnectinffreehenv}\rtfsp
9fe17bd3 1788to free the environment handle automatically.}
107ffdc1 1789\docparam{dsn}{Name of the datasource to be used in creating wxDb instances
9fe17bd3 1790for creating connection(s) to a datasource.}
107ffdc1
RD
1791\docparam{userID}{{\it OPTIONAL} Many datasources allow (or even require)
1792use of a username to determine privileges that connecting user is allowed
9fe17bd3 1793to have when accessing the datasource or the data tables. Default is "".}
107ffdc1 1794\docparam{password}{{\it OPTIONAL} Password to be associated with the user
9fe17bd3 1795ID specified in 'userID'. Default is "".}
107ffdc1
RD
1796\docparam{defaultDir}{{\it OPTIONAL} Used for datasources which require the
1797path to where the data file is stored to be specified. dBase is one example
9fe17bd3
GT
1798of the type of datasource which requires this information. Default is "".}
1799\docparam{description}{{\it OPTIONAL} {\bf FUTURE USE} Default is "".}
1800\docparam{fileType}{{\it OPTIONAL} {\bf FUTURE USE} Default is "".}
1801
1802\wxheading{Remarks}
1803
107ffdc1
RD
1804It is strongly recommended that programs use the longer form of the
1805constructor and allow the constructor to create the SQL environment handle
9fe17bd3
GT
1806automatically, and manage the destruction of the handle.
1807
1808\wxheading{Example}
1809
1810\begin{verbatim}
1811 wxDbConnectInf *DbConnectInf;
1812
1813 DbConnectInf = new wxDbConnectInf(0,"MY_DSN", "MY_USER", "MY_PASSWORD");
1814
1815 ....the rest of the program
1816
1817 delete DbConnectInf;
1818\end{verbatim}
1819
1820\wxheading{See also}
1821
107ffdc1 1822\helpref{wxDConnectInf::AllocHenv}{wxdbconnectinfallochenv},
9fe17bd3
GT
1823\helpref{wxDConnectInf::FreeHenv}{wxdbconnectinffreehenv}
1824
9fe17bd3
GT
1825\membersection{wxDbConnectInf::\destruct{wxDbConnectInf}}\label{wxdbconnectinfdestr}
1826
1827\func{}{\destruct{wxDbConnectInf}}{}
1828
107ffdc1
RD
1829Handles the default destruction of the instance of the class. If the long form
1830of the \helpref{wxDConnectInf}{wxdbconnectinf} was used, then this destructor
c140b7e7 1831also takes care of calling\rtfsp
107ffdc1 1832\helpref{wxDConnectInf::FreeHenv}{wxdbconnectinffreehenv} to free the
9fe17bd3
GT
1833SQL environment handle.
1834
9fe17bd3
GT
1835\membersection{wxDbConnectInf::AllocHenv}\label{wxdbconnectinfallochenv}
1836
1837\func{bool }{AllocHenv}{\void}
1838
107ffdc1 1839Allocates a SQL environment handle that will be used to interface with
9fe17bd3
GT
1840an ODBC datasource.
1841
1842\wxheading{Remarks}
1843
107ffdc1 1844This function can be automatically called by the long from of the
9fe17bd3
GT
1845\helpref{wxDbConnectInf}{wxdbconnectinf} constructor.
1846
9fe17bd3
GT
1847\membersection{wxDbConnectInf::FreeHenv}\label{wxdbconnectinffreehenv}
1848
1849\func{void}{FreeHenv}{\void}
1850
1851Frees the SQL environment handle being managed by the instance of this class.
1852
1853\wxheading{Remarks}
1854
c140b7e7 1855If the SQL environment handle was created using the long form of the\rtfsp
107ffdc1
RD
1856\helpref{wxDbConnectInf}{wxdbconnectinf} constructor, then the flag indicating
1857that the HENV should be destroyed when the classes destructor is called
c140b7e7 1858is reset to be false, so that any future handles created using the\rtfsp
107ffdc1 1859\helpref{wxDbConnectInf::AllocHenv}{wxdbconnectinfallochenv} function
9fe17bd3
GT
1860must be manually released with a call to this function.
1861
9fe17bd3
GT
1862\membersection{wxDbConnectInf::Initialize}\label{wxdbconnectinfinitialize}
1863
107ffdc1 1864Simply initializes all member variables to a cleared state. Called by
9fe17bd3
GT
1865the constructor automatically.
1866
9fe17bd3
GT
1867\membersection{wxDbConnectInf::GetAuthStr}\label{wxdbconnectinfgetauthstr}
1868
1869\func{const wxChar *}{GetAuthStr}{\void}
1870
107ffdc1 1871Accessor function to return the password assigned for this class
9fe17bd3
GT
1872instance that will be used with the user ID.
1873
1874Synonymous with \helpref{wxDbConnectInf::GetPassword}{wxdbconnectinfgetpassword}
1875
9fe17bd3
GT
1876\membersection{wxDbConnectInf::GetDefaultDir}\label{wxdbconnectinfgetdefaultdir}
1877
1878\func{const wxChar *}{GetDefaultDir}{\void}
1879
107ffdc1
RD
1880Accessor function to return the default directory in which the datasource's data
1881table is stored. This directory is only used for file based datasources like
1882dBase. MS-Access does not require this to be set, as the path is set in the
9fe17bd3
GT
1883ODBC Administrator for MS-Access.
1884
9fe17bd3
GT
1885\membersection{wxDbConnectInf::GetDescription}\label{wxdbconnectinfgetdescription}
1886
1887\func{const wxChar *}{GetDescription}{\void}
1888
107ffdc1 1889Accessor function to return the description assigned for this class
9fe17bd3
GT
1890instance.
1891
1892NOTE: Description is a FUTURE USE item and is unused currently.
1893
9fe17bd3
GT
1894\membersection{wxDbConnectInf::GetDsn}\label{wxdbconnectinfgetdsn}
1895
1896\func{const wxChar *}{GetDsn}{\void}
1897
107ffdc1 1898Accessor function to return the datasource name assigned for this class
9fe17bd3
GT
1899instance.
1900
9fe17bd3
GT
1901\membersection{wxDbConnectInf::GetFileType}\label{wxdbconnectinfgetfiletype}
1902
1903\func{const wxChar *}{GetFileType}{\void}
1904
107ffdc1 1905Accessor function to return the filetype of the ODBC datasource assigned for
9fe17bd3
GT
1906this class instance.
1907
1908NOTE: FileType is a FUTURE USE item and is unused currently.
1909
9fe17bd3
GT
1910\membersection{wxDbConnectInf::GetHenv}\label{wxdbconnectinfgethenv}
1911
1912\func{const HENV}{GetHenv}{\void}
1913
107ffdc1 1914Accessor function to return the SQL environment handle being managed
9fe17bd3
GT
1915by this class instance.
1916
9fe17bd3
GT
1917\membersection{wxDbConnectInf::GetPassword}\label{wxdbconnectinfgetpassword}
1918
1919\func{const wxChar *}{GetPassword}{\void}
1920
107ffdc1 1921Accessor function to return the password assigned for this class
9fe17bd3
GT
1922instance that will be used with the user ID.
1923
1924Synonymous with \helpref{wxDbConnectInf::GetAuthStr}{wxdbconnectinfgetauthstr}
1925
9fe17bd3
GT
1926\membersection{wxDbConnectInf::GetUid}\label{wxdbconnectinfgetuid}
1927
1928\func{const wxChar *}{GetUid}{\void}
1929
107ffdc1 1930Accessor function to return the user ID assigned for this class
9fe17bd3
GT
1931instance.
1932
9fe17bd3
GT
1933\membersection{wxDbConnectInf::GetUserID}\label{wxdbconnectinfgetuserid}
1934
1935\func{const wxChar *}{GetUserID}{\void}
1936
107ffdc1 1937Accessor function to return the user ID assigned for this class
9fe17bd3
GT
1938instance.
1939
9fe17bd3
GT
1940\membersection{wxDbConnectInf::SetAuthStr}\label{wxdbconnectinfsetauthstr}
1941
7af3ca16 1942\func{\void}{SetAuthStr}{const wxString \&authstr}
9fe17bd3 1943
107ffdc1 1944Accessor function to assign the password for this class
9fe17bd3
GT
1945instance that will be used with the user ID.
1946
1947Synonymous with \helpref{wxDbConnectInf::SetPassword}{wxdbconnectinfsetpassword}
1948
9fe17bd3
GT
1949\membersection{wxDbConnectInf::SetDefaultDir}\label{wxdbconnectinfsetdefaultdir}
1950
7af3ca16 1951\func{\void}{SetDefaultDir}{const wxString \&defDir}
9fe17bd3 1952
107ffdc1
RD
1953Accessor function to assign the default directory in which the datasource's data
1954table is stored. This directory is only used for file based datasources like
1955dBase. MS-Access does not require this to be set, as the path is set in the
9fe17bd3
GT
1956ODBC Administrator for MS-Access.
1957
9fe17bd3
GT
1958\membersection{wxDbConnectInf::SetDescription}\label{wxdbconnectinfsetdescription}
1959
7af3ca16 1960\func{\void}{SetDescription}{const wxString \&desc}
9fe17bd3 1961
107ffdc1 1962Accessor function to assign the description assigned for this class
9fe17bd3
GT
1963instance.
1964
1965NOTE: Description is a FUTURE USE item and is unused currently.
1966
9fe17bd3
GT
1967\membersection{wxDbConnectInf::SetDsn}\label{wxdbconnectinfsetdsn}
1968
7af3ca16 1969\func{\void}{SetDsn}{const wxString \&dsn}
9fe17bd3
GT
1970
1971Accessor function to assign the datasource name for this class instance.
1972
9fe17bd3
GT
1973\membersection{wxDbConnectInf::SetFileType}\label{wxdbconnectinfsetfiletype}
1974
7af3ca16 1975\func{\void}{SetFileType}{const wxString \&}
9fe17bd3 1976
107ffdc1 1977Accessor function to return the filetype of the ODBC datasource assigned for
9fe17bd3
GT
1978this class instance.
1979
1980NOTE: FileType is a FUTURE USE item and is unused currently.
1981
9fe17bd3
GT
1982\membersection{wxDbConnectInf::SetHenv}\label{wxdbconnectinfsethenv}
1983
1984\func{void}{SetHenv}{\param{const HENV }{henv}}
1985
1986Accessor function to set the SQL environment handle for this class instance.
1987
9fe17bd3
GT
1988\membersection{wxDbConnectInf::SetPassword}\label{wxdbconnectinfsetpassword}
1989
7af3ca16 1990\func{\void}{SetPassword}{const wxString \&password}
9fe17bd3 1991
107ffdc1 1992Accessor function to assign the password for this class
9fe17bd3
GT
1993instance that will be used with the user ID.
1994
1995Synonymous with \helpref{wxDbConnectInf::SetAuthStr}{wxdbconnectinfsetauthstr}
1996
9fe17bd3
GT
1997\membersection{wxDbConnectInf::SetUid}\label{wxdbconnectinfsetuid}
1998
7af3ca16 1999\func{\void}{SetUid}{const wxString \&uid}
9fe17bd3
GT
2000
2001Accessor function to set the user ID for this class instance.
2002
9fe17bd3
GT
2003\membersection{wxDbConnectInf::SetUserID}\label{wxdbconnectinfsetuserid}
2004
7af3ca16 2005\func{\void}{SetUserID}{const wxString \&userID}
9fe17bd3
GT
2006
2007Accessor function to assign the user ID for this class instance.
2008
0f353563 2009\section{\class{wxDbIdxDef}}\label{wxdbidxdef}
19320af4 2010
107ffdc1 2011Used in creation of non-primary indexes. Currently there are no member
19320af4
GT
2012functions for this class.
2013
2014\begin{verbatim}
107ffdc1 2015 wxChar ColName[DB_MAX_COLUMN_NAME_LEN+1]
19320af4 2016 // Name of column
107ffdc1 2017 bool Ascending // Is index maintained in
19320af4
GT
2018 ASCENDING sequence?
2019\end{verbatim}
2020
2021There are no constructors/destructors as of this time, and no member functions.
2022
2564094b
JS
2023See the \helpref{database classes overview}{odbcoverview} for
2024an introduction to using the ODBC classes.
19320af4 2025
0f353563
VZ
2026
2027\wxheading{Include files}
2028
2029<wx/db.h>
2030
d0c6b305
GT
2031\section{\class{wxDbInf}}\label{wxdbinf}
2032
107ffdc1
RD
2033Contains information regarding the database connection (datasource name,
2034number of tables, etc). A pointer to a wxDbTableInf is included in this
d0c6b305
GT
2035class so a program can create a wxDbTableInf array instance to maintain all
2036information about all tables in the datasource to have all the datasource's
2037information in one memory structure.
2038
fc2171bd 2039Primarily, this class is used internally by the wxWidgets ODBC classes.
c67d6048
GT
2040
2041\begin{verbatim}
9fe17bd3
GT
2042 wxChar catalog[128+1];
2043 wxChar schema[128+1]; // typically means owner of table(s)
107ffdc1 2044 int numTables; // How many tables does this
c67d6048 2045 datasource have
107ffdc1 2046 wxDbTableInf *pTableInf; // Equals a new
c67d6048
GT
2047 wxDbTableInf[numTables];
2048\end{verbatim}
2049
9fe17bd3 2050The constructor for this class initializes all the values to zero, "", or NULL.
c67d6048 2051
107ffdc1 2052The destructor for this class takes care of deleting the pTableInf member if
c67d6048
GT
2053it is non-NULL.
2054
2564094b
JS
2055See the \helpref{database classes overview}{odbcoverview} for
2056an introduction to using the ODBC classes.
2057
0e10e38d
VZ
2058\wxheading{Include files}
2059
2060<wx/db.h>
2061
2062\latexignore{\rtfignore{\wxheading{Members}}}
2063
9fe17bd3
GT
2064\membersection{wxDbInf::Initialize}\label{wxdbinfinitialize}
2065
107ffdc1 2066Simply initializes all member variables to a cleared state. Called by
9fe17bd3
GT
2067the constructor automatically.
2068
d0c6b305
GT
2069\section{\class{wxDbTable}}\label{wxdbtable}
2070
2071A wxDbTable instance provides re-usable access to rows of data in
c67d6048 2072a table contained within the associated ODBC datasource
d0c6b305 2073
2564094b
JS
2074See the \helpref{database classes overview}{odbcoverview} for
2075an introduction to using the ODBC classes.
2076
d0c6b305
GT
2077\wxheading{Include files}
2078
2079<wx/dbtable.h>\\
2080<wx/db.h>
2081
2082\latexignore{\rtfignore{\wxheading{Members}}}
2083\wxheading{Helper classes and data structures}
2084
107ffdc1 2085The following classes and structs are defined in dbtable.cpp/.h for use
9fe17bd3 2086with the wxDbTable class.
c67d6048 2087
eea22fd5
GT
2088\begin{itemize}\itemsep=0pt
2089\item \helpref{wxDbColDef}{wxdbcoldef}
2090\item \helpref{wxDbColDataPtr}{wxdbcoldataptr}
0f353563 2091\item \helpref{wxDbIdxDef}{wxdbidxdef}
eea22fd5 2092\end{itemize}
d0c6b305
GT
2093
2094\wxheading{Constants}
eea22fd5 2095
d0c6b305 2096\begin{verbatim}
c67d6048
GT
2097 wxDB_DEFAULT_CURSOR Primary cursor normally used for cursor based
2098 operations.
3ca6a5f0 2099
c67d6048
GT
2100 wxDB_QUERY_ONLY Used to indicate whether a table that is opened
2101 is for query only, or if insert/update/deletes
2102 will be performed on the table. Less overhead
107ffdc1 2103 (cursors and memory) are allocated for query
c67d6048
GT
2104 only tables, plus read access times are faster
2105 with some datasources.
3ca6a5f0 2106
c67d6048
GT
2107 wxDB_ROWID_LEN [Oracle only] - Used when CanUpdateByRowID()
2108 is true. Optimizes updates so they are faster
2109 by updating on the Oracle-specific ROWID column
2110 rather than some other index.
3ca6a5f0 2111
3ca6a5f0 2112
c67d6048 2113 wxDB_DISABLE_VIEW Use to indicate when a database view should not
107ffdc1 2114 be if a table is normally set up to use a view.
c67d6048 2115 [Currently unsupported.]
d0c6b305
GT
2116
2117\end{verbatim}
3ca6a5f0 2118
d0c6b305
GT
2119
2120\latexignore{\rtfignore{\wxheading{Members}}}
2121
2122\membersection{wxDbTable::wxDbTable}\label{wxdbtableconstr}
2123
107ffdc1
RD
2124\func{}{wxDbTable}{\param{wxDb *}{pwxDb}, \param{const wxString \&}{tblName},
2125 \param{const UWORD }{numColumns}, \param{const wxString \&}{qryTblName = ""},
7af3ca16 2126 \param{bool }{qryOnly = !wxDB\_QUERY\_ONLY}, \param{const wxString \&}{tblPath = ""}}
d0c6b305
GT
2127
2128Default constructor.
2129
2130\wxheading{Parameters}
2131
107ffdc1 2132\docparam{pwxDb}{Pointer to the wxDb instance to be used by this wxDbTable
eea22fd5
GT
2133instance.}
2134\docparam{tblName}{The name of the table in the RDBMS.}
0715c838 2135\docparam{numColumns}{The number of columns in the table. (Do NOT include the ROWID
eea22fd5 2136column in the count if using Oracle).}
107ffdc1 2137\docparam{qryTblName}{{\it OPTIONAL}. The name of the table or view to base
eea22fd5 2138your queries on. This argument allows you to specify a table/view other than
107ffdc1
RD
2139the base table for this object to base your queries on. This allows you to
2140query on a view for example, but all of the INSERT, UPDATE and DELETES will
2141still be performed on the base table for this wxDbTable object. Basing your
eea22fd5 2142queries on a view can provide a substantial performance increase in cases where
9fe17bd3 2143your queries involve many tables with multiple joins. Default is "".}
107ffdc1 2144\docparam{qryOnly}{{\it OPTIONAL}. Indicates whether the table will be
eea22fd5 2145accessible for query purposes only, or should the table create the necessary
107ffdc1 2146cursors to be able to insert, update, and delete data from the table.
e7240349 2147Default is !wxDB\_QUERY\_ONLY.}
107ffdc1 2148\docparam{tblPath}{{\it OPTIONAL}. Some datasources (such as dBase)
9fe17bd3 2149require a path to where the table is stored on the system. Default is "".}
d0c6b305
GT
2150
2151\membersection{wxDbTable::wxDbTable}\label{wxdbtabledestr}
2152
2153\func{virtual}{\destruct{wxDbTable}}{}
2154
2155Virtual default destructor.
2156
d0c6b305
GT
2157\membersection{wxDbTable::BuildDeleteStmt}\label{wxdbtablebuilddeletestmt}
2158
107ffdc1 2159\func{void}{BuildDeleteStmt}{\param{wxString \&}{pSqlStmt},
7af3ca16 2160\param{int }{typeOfDel}, \param{const wxString \&}{pWhereClause=""}}
eea22fd5
GT
2161
2162Constructs the full SQL statement that can be used to delete all rows matching
2163the criteria in the pWhereClause.
d0c6b305
GT
2164
2165\wxheading{Parameters}
2166
c67d6048 2167\docparam{pSqlStmt}{Pointer to buffer for the SQL statement retrieved. To be
eea22fd5 2168sure you have adequate space allocated for the SQL statement, allocate
e7240349 2169DB\_MAX\_STATEMENT\_LEN bytes.}
eea22fd5 2170\docparam{typeOfDel}{The type of delete statement being performed. Can be one
e7240349 2171of three values: DB\_DEL\_KEYFIELDS, DB\_DEL\_WHERE or DB\_DEL\_MATCHING}
107ffdc1
RD
2172\docparam{pWhereClause}{{\it OPTIONAL}. If the typeOfDel is DB\_DEL\_WHERE,
2173then you must also pass in a SQL WHERE clause in this argument. Default
9fe17bd3 2174is "".}
eea22fd5
GT
2175
2176\wxheading{Remarks}
2177
107ffdc1 2178This member function constructs a SQL DELETE statement. This can be used for
c67d6048 2179debugging purposes if you are having problems executing your SQL statement.
eea22fd5 2180
107ffdc1
RD
2181WHERE and FROM clauses specified using \helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
2182and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by
eea22fd5 2183this function.
d0c6b305 2184
d0c6b305
GT
2185\membersection{wxDbTable::BuildSelectStmt}\label{wxdbtablebuildselectstmt}
2186
107ffdc1 2187\func{void}{BuildSelectStmt}{\param{wxString \&}{pSqlStmt},
9fe17bd3 2188\param{int }{typeOfSelect}, \param{bool }{distinct}}
d0c6b305 2189
eea22fd5 2190Constructs the full SQL statement that can be used to select all rows matching
107ffdc1
RD
2191the criteria in the pWhereClause. This function is called internally in the
2192wxDbTable class whenever the function \helpref{wxDbTable::Query}{wxdbtablequery}
eea22fd5
GT
2193is called.
2194
107ffdc1
RD
2195NOTE: Only the columns specified in \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}
2196statements are included in the list of columns returned by the SQL statement
eea22fd5
GT
2197created by a call to this function.
2198
d0c6b305
GT
2199\wxheading{Parameters}
2200
eea22fd5
GT
2201\docparam{pSqlStmt}{Pointer to storage for the SQL statement retrieved. To be
2202sure you have adequate space allocated for the SQL statement, allocate
e7240349 2203DB\_MAX\_STATEMENT\_LEN bytes.}
eea22fd5 2204\docparam{typeOfSelect}{The type of select statement being performed. Can be
e7240349
GT
2205one of four values: DB\_SELECT\_KEYFIELDS, DB\_SELECT\_WHERE, DB\_SELECT\_MATCHING
2206or DB\_SELECT\_STATEMENT.}
eea22fd5
GT
2207\docparam{distinct}{Whether to select distinct records only.}
2208
2209\wxheading{Remarks}
2210
107ffdc1 2211This member function constructs a SQL SELECT statement. This can be used for
c67d6048 2212debugging purposes if you are having problems executing your SQL statement.
eea22fd5 2213
107ffdc1
RD
2214WHERE and FROM clauses specified using
2215\helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
2216and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by
eea22fd5 2217this function.
d0c6b305 2218
d0c6b305
GT
2219\membersection{wxDbTable::BuildUpdateStmt}\label{wxdbtablebuildupdatestmt}
2220
107ffdc1 2221\func{void}{BuildUpdateStmt}{\param{wxString \&}{pSqlStmt}, \param{int }{typeOfUpd},
7af3ca16 2222\param{const wxString \&}{pWhereClause=""}}
d0c6b305 2223
eea22fd5
GT
2224Constructs the full SQL statement that can be used to update all rows matching
2225the criteria in the pWhereClause.
2226
549c8cc2 2227If typeOfUpdate is DB\_UPD\_KEYFIELDS, then the current values in the bound columns
107ffdc1 2228are used to determine which row(s) in the table are to be updated. The
c67d6048 2229exception to this is when a datasource supports ROW IDs (Oracle). The ROW ID
eea22fd5
GT
2230column is used for efficiency purposes when available.
2231
107ffdc1
RD
2232NOTE: Only the columns specified in \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}
2233statements are included in the list of columns updated by the SQL statement
eea22fd5
GT
2234created by a call to this function. Any column definitions that were defined
2235as being non-updateable will be excluded from the SQL UPDATE statement created
2236by this function.
2237
d0c6b305
GT
2238\wxheading{Parameters}
2239
eea22fd5
GT
2240\docparam{pSqlStmt}{Pointer to storage for the SQL statement retrieved. To be
2241sure you have adequate space allocated for the SQL statement, allocate
e7240349 2242DB\_MAX\_STATEMENT\_LEN bytes.}
549c8cc2 2243\docparam{typeOfUpdate}{The type of update statement being performed. Can be one
e7240349 2244of two values: DB\_UPD\_KEYFIELDS or DB\_UPD\_WHERE.}
549c8cc2 2245\docparam{pWhereClause}{{\it OPTIONAL}. If the typeOfUpdate is DB\_UPD\_WHERE,
9fe17bd3 2246then you must also pass in a SQL WHERE clause in this argument. Default is "".}
eea22fd5
GT
2247
2248\wxheading{Remarks}
2249
2250This member function allows you to see what the SQL UPDATE statement looks like
2251that the ODBC class library builds. This can be used for debugging purposes if
2252you are having problems executing your SQL statement.
2253
107ffdc1
RD
2254WHERE and FROM clauses specified using \helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
2255and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by
eea22fd5 2256this function.
d0c6b305 2257
d0c6b305 2258
9919dac1
RN
2259\membersection{wxDbTable::BuildWhereClause}\label{wxdbtablebuildwhereclause}
2260
2261\func{void}{BuildWhereClause}{\param{wxString \&}{pWhereClause},
2262\param{int }{typeOfWhere}, \param{const wxString \&}{qualTableName=""},
2263\param{bool }{useLikeComparison=false}}
2264
2265Constructs the portion of a SQL statement which would follow the word 'WHERE'
2266in a SQL statement to be passed to the datasource. The returned string
2267does NOT include the word 'WHERE'.
2268
2269\wxheading{Parameters}
2270
2271\docparam{pWhereClause}{Pointer to storage for the SQL statement retrieved.
2272To be sure you have adequate space allocated for the SQL statement, allocate
2273DB\_MAX\_STATEMENT\_LEN bytes.}
2274\docparam{typeOfWhere}{The type of where clause to generate. Can be one of
2275two values: DB\_WHERE\_KEYFIELDS or DB\_WHERE\_MATCHING.}
2276\docparam{qualTableName}{{\it OPTIONAL}. Prepended to all base table
2277column names. For use when a FROM clause has been specified with the
2278\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause},
2279to clarify which table a column name reference belongs to. Default is "".}
2280\docparam{useLikeComparison}{{\it OPTIONAL}. Should the constructed WHERE
2281clause utilize the LIKE comparison operator. If false, then the '='
2282operator is used. Default is false.}
2283
2284\wxheading{Remarks}
2285
2286This member function allows you to see what the SQL WHERE clause looks like
2287that the ODBC class library builds. This can be used for debugging purposes
2288if you are having problems executing your own SQL statements.
2289
2290If using 'typeOfWhere' set to DB\_WHERE\_MATCHING, any bound columns currently
2291containing a NULL value are not included in the WHERE clause's list of
2292columns to use in the comparison.
2293
2294
d0c6b305
GT
2295\membersection{wxDbTable::CanSelectForUpdate}\label{wxdbtablecanselectforupdate}
2296
2297\func{bool}{CanSelectForUpdate}{\void}
2298
c67d6048 2299Use this function to determine if the datasource supports SELECT ... FOR UPDATE.
eea22fd5 2300When the keywords "FOR UPDATE" are included as part of your SQL SELECT statement,
107ffdc1
RD
2301all records {\it retrieved} (not just queried, but actually retrieved using
2302\helpref{wxDbTable::GetNext}{wxdbtablegetnext}, etc) from the result set are
2303locked.
eea22fd5 2304
d0c6b305
GT
2305\wxheading{Remarks}
2306
c67d6048
GT
2307Not all datasources support the "FOR UPDATE" clause, so you must use this
2308member function to determine if the datasource currently connected to supports
eea22fd5
GT
2309this behavior or not before trying to select using "FOR UPDATE".
2310
107ffdc1 2311If the wxDbTable instance was created with the parameter wxDB\_QUERY\_ONLY, then
cc81d32f
VS
2312this function will return false. For all known databases which do not support
2313the FOR UPDATE clause, this function will return false also.
59990c22 2314
d0c6b305
GT
2315\membersection{wxDbTable::CanUpdateByROWID}\label{wxdbtablecanupdatebyrowid}
2316
2317\func{bool}{CanUpdateByROWID}{\void}
2318
107ffdc1 2319CURRENTLY ONLY POSSIBLE IF USING ORACLE.
eea22fd5
GT
2320
2321--- CURRENTLY DISABLED FOR *ALL* DATASOURCES --- NOV 1 2000 - gt
2322
2323Every Oracle table has a hidden column named ROWID. This is a pointer to the
107ffdc1 2324physical location of the record in the datasource and allows for very fast
eea22fd5 2325updates and deletes. The key is to retrieve this ROWID during your query so
107ffdc1
RD
2326it is available during an update or delete operation.
2327
2328Use of the ROWID feature is always handled by the class library except in the
2329case of \helpref{wxDbTable::QueryBySqlStmt}{wxdbtablequerybysqlstmt}. Since
2330you are passing in the SQL SELECT statement,
2331it is up to you to include the ROWID column in your query. If you do not,
2332the application will still work, but may not be as optimized. The ROWID is
2333always the last column in the column list in your SQL SELECT statement.
2334The ROWID is not a column in the normal sense and should not be considered
eea22fd5
GT
2335part of the column definitions for the wxDbTable object.
2336
d0c6b305
GT
2337\wxheading{Remarks}
2338
107ffdc1
RD
2339The decision to include the ROWID in your SQL SELECT statement must be
2340deferred until runtime since it depends on whether you are connected
c67d6048 2341to an Oracle datasource or not.
eea22fd5
GT
2342
2343\wxheading{Example}
2344
2345\begin{verbatim}
2346 // Incomplete code sample
2347 wxDbTable parts;
2348 .....
998abc15 2349 if (parts.CanUpdateByROWID())
c67d6048 2350 {
eea22fd5 2351 // Note that the ROWID column must always be the last column selected
998abc15 2352 sqlStmt = "SELECT PART_NUM, PART_DESC, ROWID" FROM PARTS";
c67d6048 2353 }
eea22fd5 2354 else
998abc15 2355 sqlStmt = "SELECT PART_NUM, PART_DESC FROM PARTS";
eea22fd5
GT
2356\end{verbatim}
2357
d0c6b305 2358
c67d6048
GT
2359\membersection{wxDbTable::ClearMemberVar}\label{wxdbtableclearmembervar}
2360
998abc15 2361\func{void}{ClearMemberVar}{\param{UWORD }{colNumber}, \param{bool }{setToNull=false}}
c67d6048
GT
2362
2363Same as \helpref{wxDbTable::ClearMemberVars}{wxdbtableclearmembervars} except
107ffdc1 2364that this function clears only the specified column of its values, and
59990c22 2365optionally sets the column to be a NULL column.
c67d6048 2366
998abc15
GT
2367\docparam{colNumber}{Column number that is to be cleared. This number (between 0
2368and (numColumns-1)) is the index of the column definition created using the
9fe17bd3 2369\helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs} function.}
107ffdc1 2370\docparam{setToNull}{{\it OPTIONAL}. Indicates whether the column should be
cc81d32f 2371flagged as being a NULL value stored in the bound memory variable. If true,
107ffdc1 2372then any value stored in the bound member variable is cleared. Default is
cc81d32f 2373false.}
c67d6048 2374
d0c6b305
GT
2375\membersection{wxDbTable::ClearMemberVars}\label{wxdbtableclearmembervars}
2376
cc81d32f 2377\func{void}{ClearMemberVars}{\param{bool }{setToNull=false}}
c67d6048 2378
107ffdc1
RD
2379Initializes all bound columns of the wxDbTable instance to zero. In the case
2380of a string, zero is copied to the first byte of the string.
d0c6b305 2381
107ffdc1 2382\docparam{setToNull}{{\it OPTIONAL}. Indicates whether all columns should be
cc81d32f 2383flagged as having a NULL value stored in the bound memory variable. If true,
107ffdc1 2384then any value stored in the bound member variable is cleared. Default is
cc81d32f 2385false.}
eea22fd5 2386
d0c6b305
GT
2387\wxheading{Remarks}
2388
107ffdc1
RD
2389This is useful before calling functions such as
2390\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
2391\helpref{wxDbTable::DeleteMatching}{wxdbtabledeletematching} since these
2392functions build their WHERE clauses from non-zero columns. To call either
2393\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
eea22fd5
GT
2394\helpref{wxDbTable::DeleteMatching}{wxdbtabledeletematching} use this sequence:
2395
2396\begin{verbatim}
23971) ClearMemberVars()
23982) Assign columns values you wish to match on
23993) Call wxDbTable::QueryMatching() or wxDbTable::DeleteMatching()
2400\end{verbatim}
d0c6b305
GT
2401
2402\membersection{wxDbTable::CloseCursor}\label{wxdbtableclosecursor}
2403
2404\func{bool}{CloseCursor}{\param{HSTMT}{cursor}}
2405
eea22fd5
GT
2406Closes the specified cursor associated with the wxDbTable object.
2407
d0c6b305
GT
2408\wxheading{Parameters}
2409
eea22fd5 2410\docparam{cursor}{The cursor to be closed.}
d0c6b305
GT
2411
2412\wxheading{Remarks}
2413
107ffdc1 2414Typically handled internally by the ODBC class library, but may be used by the
eea22fd5
GT
2415programmer if desired.
2416
e7240349 2417\normalbox{DO NOT CLOSE THE wxDB\_DEFAULT\_CURSOR!}
c67d6048 2418
d0c6b305
GT
2419\membersection{wxDbTable::Count}\label{wxdbtablecount}
2420
7af3ca16 2421\func{ULONG }{Count}{\param{const wxString \&}{args="*"}}
d0c6b305 2422
eea22fd5
GT
2423Returns the number of records which would be in the result set using the
2424current query parameters specified in the WHERE and FROM clauses.
2425
d0c6b305
GT
2426\wxheading{Parameters}
2427
107ffdc1
RD
2428\docparam{args}{{\it OPTIONAL}. This argument allows the use of the
2429DISTINCT keyword against a column name to cause the returned count to
2430only indicate the number of rows in the result set that have a unique
2431value in the specified column. An example is shown below. Default is "*",
2432meaning a count of the total number of rows matching is returned, regardless
9fe17bd3 2433of uniqueness.}
d0c6b305
GT
2434
2435\wxheading{Remarks}
2436
107ffdc1 2437This function can be called before or after an actual query to obtain the
eea22fd5
GT
2438count of records in the result set. Count() uses its own cursor, so result
2439set cursor positioning is not affected by calls to Count().
2440
107ffdc1
RD
2441WHERE and FROM clauses specified using
2442\helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
2443and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} ARE used by
c67d6048
GT
2444this function.
2445
eea22fd5
GT
2446\wxheading{Example}
2447
2448\begin{verbatim}
2449
2450 USERS TABLE
2451
2452 FIRST_NAME LAST_NAME
2453 ----------- ----------
107ffdc1 2454 John Doe
eea22fd5
GT
2455 Richard Smith
2456 Michael Jones
2457 John Carpenter
2458
2459 // Incomplete code sample
2460 wxDbTable users;
2461 .....
2462 users.SetWhereClause("");
2463
2464 // This Count() will return 4, as there are four users listed above
2465 // that match the query parameters
2466 totalNumberOfUsers = users.Count();
2467
2468 // This Count() will return 3, as there are only 3 unique first names
2469 // in the table above - John, Richard, Michael.
2470 totalNumberOfUniqueFirstNames = users.Count("DISTINCT FIRST_NAME");
2471\end{verbatim}
2472
d0c6b305
GT
2473\membersection{wxDbTable::CreateIndex}\label{wxdbtablecreateindex}
2474
549c8cc2 2475\func{bool}{CreateIndex}{\param{const wxString \&}{IndexName}, \param{bool }{unique},
0f353563 2476\param{UWORD }{numIndexColumns}, \param{wxDbIdxDef *}{pIndexDefs},
cc81d32f 2477\param{bool }{attemptDrop=true}}
eea22fd5 2478
154b6b0f 2479This member function allows you to create secondary (non-primary) indexes on
107ffdc1
RD
2480your tables. You first create your table, normally specifying a primary
2481index, and then create any secondary indexes on the table. Indexes in
2482relational model are not required. You do not need indexes to look up records
2483in a table or to join two tables together. In the relational model, indexes,
2484if available, provide a quicker means to look up data in a table. To enjoy
2485the performance benefits of indexes, the indexes must be defined on the
2486appropriate columns and your SQL code must be written in such a way as to
eea22fd5 2487take advantage of those indexes.
d0c6b305
GT
2488
2489\wxheading{Parameters}
2490
549c8cc2 2491\docparam{IndexName}{Name of the Index. Name must be unique within the table
9fe17bd3 2492space of the datasource.}
eea22fd5 2493\docparam{unique}{Indicates if this index is unique.}
549c8cc2 2494\docparam{numIndexColumns}{Number of columns in the index.}
0f353563 2495\docparam{pIndexDefs}{A pointer to an array \helpref{wxDbIdxDef}{wxdbidxdef} structures. }
107ffdc1
RD
2496\docparam{attemptDrop}{{\it OPTIONAL}. Indicates if the function should try
2497to execute a \helpref{wxDbTable::DropIndex}{wxdbtabledropindex} on the index
cc81d32f 2498name provided before trying to create the index name. Default is true.}
d0c6b305
GT
2499
2500\wxheading{Remarks}
2501
107ffdc1
RD
2502The first parameter, index name, must be unique and should be given a
2503meaningful name. Common practice is to include the table name as a prefix
2504in the index name (e.g. For table PARTS, you might want to call your index
549c8cc2 2505PARTS\_Index1). This will allow you to easily view all
eea22fd5
GT
2506of the indexes defined for a given table grouped together alphabetically.
2507
107ffdc1 2508The second parameter indicates if the index is unique or not. Uniqueness
c67d6048 2509is enforced at the RDBMS level preventing rows which would have duplicate
107ffdc1 2510indexes from being inserted into the table when violating a unique index's
c67d6048 2511uniqueness.
eea22fd5 2512
107ffdc1 2513In the third parameter, specify how many columns are in your index. This
549c8cc2 2514number must match the number of columns defined in the 'pIndexDefs' parameter.
eea22fd5 2515
107ffdc1 2516The fourth parameter specifies which columns make up the index using the
0f353563 2517\helpref{wxDbIdxDef}{wxdbidxdef} structure. For each column in the index, you must specify two
107ffdc1 2518things, the column name and the sort order (ascending / descending). See
0f353563 2519the example below to see how to build and pass in the \helpref{wxDbIdxDef}{wxdbidxdef} structure.
eea22fd5 2520
107ffdc1
RD
2521The fifth parameter is provided to handle the differences in datasources as
2522to whether they will automatically overwrite existing indexes with the same
2523name or not. Some datasources require that the existing index must be dropped
c67d6048 2524first, so this is the default behavior.
eea22fd5 2525
107ffdc1
RD
2526Some datasources (MySQL, and possibly others) require columns which are to be
2527part of an index to be defined as NOT NULL. When this function is called, if
2528a column is not defined to be NOT NULL, a call to this function will modify
2529the column definition to change any columns included in the index to be
2530NOT NULL. In this situation, if a NULL value already exists in one of the
c67d6048 2531columns that is being modified, creation of the index will fail.
eea22fd5 2532
107ffdc1
RD
2533PostGres is unable to handle index definitions which specify whether the index
2534is ascending or descending, and defaults to the system default when the index
eea22fd5
GT
2535is created.
2536
107ffdc1 2537It is not necessary to call \helpref{wxDb::CommitTrans}{wxdbcommittrans}
eea22fd5
GT
2538after executing this function.
2539
2540\wxheading{Example}
2541
2542\begin{verbatim}
2543 // Create a secondary index on the PARTS table
0f353563 2544 wxDbIdxDef IndexDef[2]; // 2 columns make up the index
eea22fd5 2545
549c8cc2
GT
2546 wxStrcpy(IndexDef[0].ColName, "PART_DESC"); // Column 1
2547 IndexDef[0].Ascending = true;
eea22fd5 2548
549c8cc2
GT
2549 wxStrcpy(IndexDef[1].ColName, "SERIAL_NO"); // Column 2
2550 IndexDef[1].Ascending = false;
eea22fd5
GT
2551
2552 // Create a name for the index based on the table's name
2553 wxString indexName;
549c8cc2
GT
2554 indexName.Printf("%s_Index1",parts->GetTableName());
2555 parts->CreateIndex(indexName, true, 2, IndexDef);
eea22fd5
GT
2556\end{verbatim}
2557
d0c6b305
GT
2558\membersection{wxDbTable::CreateTable}\label{wxdbtablecreatetable}
2559
cc81d32f 2560\func{bool}{CreateTable}{\param{bool }{attemptDrop=true}}
d0c6b305 2561
eea22fd5
GT
2562Creates a table based on the definitions previously defined for this
2563wxDbTable instance.
2564
d0c6b305
GT
2565\wxheading{Parameters}
2566
107ffdc1
RD
2567\docparam{attemptDrop}{{\it OPTIONAL}. Indicates whether the driver should
2568attempt to drop the table before trying to create it. Some datasources will
2569not allow creation of a table if the table already exists in the table space
cc81d32f 2570being used. Default is true.}
d0c6b305
GT
2571
2572\wxheading{Remarks}
2573
107ffdc1
RD
2574This function creates the table and primary index (if any) in the table space
2575associated with the connected datasource. The owner of these objects will
2576be the user id that was given when \helpref{wxDb::Open}{wxdbopen} was called.
9fe17bd3 2577The objects will be created in the default schema/table space for that user.
d0c6b305 2578
107ffdc1
RD
2579In your derived wxDbTable object constructor, the columns and primary index
2580of the table are described through the \helpref{wxDbColDef}{wxdbcoldef} structure.
2581\helpref{wxDbTable::CreateTable}{wxdbtablecreatetable} uses this information
2582to create the table and to add the primary index. See
2583\helpref{wxDbTable}{wxdbtable} ctor and wxDbColDef description for additional
9fe17bd3 2584information on describing the columns of the table.
d0c6b305 2585
107ffdc1 2586It is not necessary to call \helpref{wxDb::CommitTrans}{wxdbcommittrans}
eea22fd5 2587after executing this function.
d0c6b305 2588
e7240349 2589\membersection{wxDbTable::DB\_STATUS}\label{wxdbtabledbstatus}
d0c6b305 2590
e7240349 2591\func{bool}{DB\_STATUS}{\void}
d0c6b305 2592
107ffdc1 2593Accessor function that returns the wxDb private member variable DB\_STATUS for
eea22fd5 2594the database connection used by this instance of wxDbTable.
d0c6b305 2595
d0c6b305
GT
2596\membersection{wxDbTable::Delete}\label{wxdbtabledelete}
2597
2598\func{bool}{Delete}{\void}
2599
c67d6048 2600Deletes the row from the table indicated by the current cursor.
eea22fd5 2601
d0c6b305
GT
2602\wxheading{Remarks}
2603
107ffdc1
RD
2604Use \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst},
2605\helpref{wxDbTable::GetLast}{wxdbtablegetlast},
eea22fd5 2606\helpref{wxDbTable::GetNext}{wxdbtablegetnext} or
107ffdc1
RD
2607\helpref{wxDbTable::GetPrev}{wxdbtablegetprev} to position the cursor to
2608a valid record. Once positioned on a record, call this function to delete
eea22fd5
GT
2609the row from the table.
2610
107ffdc1
RD
2611A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
2612\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
eea22fd5
GT
2613this function to commit or rollback the deletion.
2614
107ffdc1
RD
2615NOTE: Most datasources have a limited size "rollback" segment. This means
2616that it is only possible to insert/update/delete a finite number of rows
2617without performing a \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
2618\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans}. Size of the rollback
2619segment varies from database to database, and is user configurable in
2620most databases. Therefore it is usually best to try to perform a commit
2621or rollback at relatively small intervals when processing a larger number
eea22fd5
GT
2622of actions that insert/update/delete rows in a table.
2623
d0c6b305
GT
2624\membersection{wxDbTable::DeleteCursor}\label{wxdbtabledeletecursor}
2625
eea22fd5
GT
2626\func{bool}{DeleteCursor}{\param{HSTMT *}{hstmtDel}}
2627
2628Allows a program to delete a cursor.
d0c6b305
GT
2629
2630\wxheading{Parameters}
2631
eea22fd5
GT
2632\docparam{hstmtDel}{Handle of the cursor to delete.}
2633
2634\wxheading{Remarks}
2635
107ffdc1
RD
2636For default cursors associated with the instance of wxDbTable, it is not
2637necessary to specifically delete the cursors. This is automatically done
eea22fd5
GT
2638in the wxDbTable destructor.
2639
107ffdc1
RD
2640NOTE: If the cursor could not be deleted for some reason, an error is logged
2641indicating the reason. Even if the cursor could not be deleted, the HSTMT
eea22fd5
GT
2642that is passed in is deleted, and the pointer is set to NULL.
2643
e7240349 2644\normalbox{DO NOT DELETE THE wxDB\_DEFAULT\_CURSOR!}
c67d6048 2645
eea22fd5
GT
2646\membersection{wxDbTable::DeleteMatching}\label{wxdbtabledeletematching}
2647
2648\func{bool}{DeleteMatching}{\void}
2649
107ffdc1
RD
2650This member function allows you to delete records from your wxDbTable object
2651by specifying the data in the columns to match on.
d0c6b305
GT
2652
2653\wxheading{Remarks}
2654
eea22fd5
GT
2655To delete all users with a first name of "JOHN", do the following:
2656
05dedde7
JS
2657\begin{enumerate}\itemsep=0pt
2658\item Clear all "columns" using wxDbTable::ClearMemberVars().
e626d7c7 2659\item Set the FIRST\_NAME column equal to "JOHN".
05dedde7
JS
2660\item Call wxDbTable::DeleteMatching().
2661\end{enumerate}
eea22fd5 2662
107ffdc1
RD
2663The WHERE clause is built by the ODBC class library based on all non-NULL
2664columns. This allows deletion of records by matching on any column(s) in
9fe17bd3 2665your wxDbTable instance, without having to write the SQL WHERE clause.
eea22fd5 2666
107ffdc1
RD
2667A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
2668\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
eea22fd5
GT
2669this function to commit or rollback the deletion.
2670
107ffdc1
RD
2671NOTE: Row(s) should be locked before deleting them to make sure they are
2672not already in use. This can be achieved by calling
2673\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching},
2674and then retrieving the records, locking each as you go (assuming FOR UPDATE
2675is allowed on the datasource). After the row(s) have been successfully locked,
c67d6048 2676call this function.
eea22fd5 2677
107ffdc1
RD
2678NOTE: Most datasources have a limited "rollback" segment. This means
2679that it is only possible to insert/update/delete a finite number of rows
2680without performing a \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
2681\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans}. Size of the rollback
2682segment varies from database to database, and is user configurable in
2683most databases. Therefore it is usually best to try to perform a commit
2684or rollback at relatively small intervals when processing a larger number
eea22fd5
GT
2685of actions that insert/update/delete rows in a table.
2686
eea22fd5
GT
2687\wxheading{Example}
2688
2689\begin{verbatim}
2690 // Incomplete code sample to delete all users with a first name
2691 // of "JOHN"
2692 users.ClearMemberVars();
9fe17bd3 2693 wxStrcpy(users.FirstName,"JOHN");
eea22fd5
GT
2694 users.DeleteMatching();
2695\end{verbatim}
2696
2697
d0c6b305
GT
2698\membersection{wxDbTable::DeleteWhere}\label{wxdbtabledeletewhere}
2699
7af3ca16 2700\func{bool}{DeleteWhere}{\param{const wxString \&}{pWhereClause}}
d0c6b305 2701
107ffdc1 2702Deletes all rows from the table which match the criteria specified in the
59990c22 2703WHERE clause that is passed in.
eea22fd5 2704
d0c6b305
GT
2705\wxheading{Parameters}
2706
107ffdc1
RD
2707\docparam{pWhereClause}{SQL WHERE clause. This WHERE clause determines which
2708records will be deleted from the table interfaced through the wxDbTable
2709instance. The WHERE clause passed in must be compliant with the SQL 92
eea22fd5
GT
2710grammar. Do not include the keyword 'WHERE'
2711}
d0c6b305
GT
2712
2713\wxheading{Remarks}
2714
107ffdc1
RD
2715This is the most powerful form of the wxDbTable delete functions. This
2716function gives access to the full power of SQL. This function can be used
2717to delete records by passing a valid SQL WHERE clause. Sophisticated
2718deletions can be performed based on multiple criteria using the full
2719functionality of the SQL language.
d0c6b305 2720
107ffdc1 2721A \helpref{wxDb::CommitTrans}{wxdbcommittrans} must be called after use of
eea22fd5
GT
2722this function to commit the deletions.
2723
107ffdc1 2724Note: This function is limited to deleting records from the table associated
eea22fd5
GT
2725with this wxDbTable object only. Deletions on joined tables is not possible.
2726
107ffdc1
RD
2727NOTE: Most datasources have a limited size "rollback" segment. This means
2728that it is only possible to insert/update/delete a finite number of rows
2729without performing a \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
2730\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans}. Size of the rollback
2731segment varies from database to database, and is user configurable in
2732most databases. Therefore it is usually best to try to perform a commit
2733or rollback at relatively small intervals when processing a larger number
eea22fd5
GT
2734of actions that insert/update/delete rows in a table.
2735
107ffdc1
RD
2736WHERE and FROM clauses specified using \helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
2737and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by
59990c22
GT
2738this function.
2739
eea22fd5
GT
2740\wxheading{Example}
2741
2742\begin{verbatim}
107ffdc1 2743 // Delete parts 1 thru 10 from containers 'X', 'Y' and 'Z' that
eea22fd5
GT
2744 // are magenta in color
2745 parts.DeleteWhere("(PART_NUMBER BETWEEN 1 AND 10) AND \
2746 CONTAINER IN ('X', 'Y', 'Z') AND \
2747 UPPER(COLOR) = 'MAGENTA'");
2748\end{verbatim}
d0c6b305 2749
d0c6b305
GT
2750
2751\membersection{wxDbTable::DropIndex}\label{wxdbtabledropindex}
2752
549c8cc2 2753\func{bool}{DropIndex}{\param{const wxString \&}{IndexName}}
d0c6b305 2754
107ffdc1 2755Allows an index on the associated table to be dropped (deleted) if the user
eea22fd5
GT
2756login has sufficient privileges to do so.
2757
d0c6b305
GT
2758\wxheading{Parameters}
2759
549c8cc2 2760\docparam{IndexName}{Name of the index to be dropped.}
d0c6b305
GT
2761
2762\wxheading{Remarks}
2763
549c8cc2 2764If the index specified in the 'IndexName' parameter does not exist, an error
cc81d32f 2765will be logged, and the function will return a result of false.
eea22fd5 2766
107ffdc1 2767It is not necessary to call \helpref{wxDb::CommitTrans}{wxdbcommittrans}
eea22fd5
GT
2768after executing this function.
2769
d0c6b305
GT
2770\membersection{wxDbTable::DropTable}\label{wxdbtabledroptable}
2771
2772\func{bool}{DropTable}{\void}
2773
eea22fd5
GT
2774Deletes the associated table if the user has sufficient privileges to do so.
2775
d0c6b305
GT
2776\wxheading{Remarks}
2777
cc81d32f 2778This function returns true if the table does not exist, but only for
107ffdc1
RD
2779supported databases (see \helpref{wxDb::Dbms}{wxdbdbms}). If a datasource
2780is not specifically supported, and this function is called, the function
cc81d32f 2781will return false.
eea22fd5 2782
107ffdc1
RD
2783Most datasources/ODBC drivers will delete any indexes associated with the
2784table automatically, and others may not. Check the documentation for your
eea22fd5
GT
2785database to determine the behavior.
2786
107ffdc1 2787It is not necessary to call \helpref{wxDb::CommitTrans}{wxdbcommittrans}
eea22fd5
GT
2788after executing this function.
2789
eea22fd5
GT
2790\membersection{wxDbTable::From}\label{wxdbtablefrom}
2791
7af3ca16 2792\func{const wxString \&}{From}{}
59990c22 2793
7af3ca16 2794\func{void}{From}{\param{const wxString \&}{From}}
eea22fd5 2795
107ffdc1
RD
2796Accessor function for the private class member wxDbTable::from. Can be used
2797as a synonym for \helpref{wxDbTable::GetFromClause}{wxdbtablegetfromclause}
2798(the first form of this function) or
2799\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} (the second form
eea22fd5
GT
2800of this function).
2801
2802\wxheading{Parameters}
2803
90e7e277 2804\docparam{From}{A comma separated list of table names that are to be inner
107ffdc1
RD
2805joined with the base table's columns so that the joined table's columns
2806may be returned in the result set or used as a portion of a comparison with
2807the base table's columns. NOTE that the base tables name must NOT be included
2808in the FROM clause, as it is automatically included by the wxDbTable class
eea22fd5
GT
2809in constructing query statements.}
2810
2811\wxheading{Return value}
2812
107ffdc1
RD
2813The first form of this function returns the current value of the wxDbTable
2814member variable ::from.
eea22fd5 2815
107ffdc1
RD
2816The second form of the function has no return value, as it will always set
2817the from clause successfully.
eea22fd5
GT
2818
2819\wxheading{See also}
2820
107ffdc1 2821\helpref{wxDbTable::GetFromClause}{wxdbtablegetfromclause},
eea22fd5
GT
2822\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}
2823
2824
d0c6b305
GT
2825\membersection{wxDbTable::GetColDefs}\label{wxdbtablegetcoldefs}
2826
2827\func{wxDbColDef *}{GetColDefs}{}
2828
107ffdc1
RD
2829Accessor function that returns a pointer to the array of column definitions
2830that are bound to the columns that this wxDbTable instance is associated
eea22fd5
GT
2831with.
2832
107ffdc1
RD
2833To determine the number of elements pointed to by the returned
2834\helpref{wxDbColDef}{wxdbcoldef} pointer, use the
eea22fd5
GT
2835\helpref{wxDbTable::GetNumberOfColumns}{wxdbtablegetnumberofcolumns} function.
2836
d0c6b305
GT
2837\wxheading{Remarks}
2838
107ffdc1 2839These column definitions must not be manually redefined after they have been
eea22fd5
GT
2840set.
2841
d0c6b305
GT
2842\membersection{wxDbTable::GetCursor}\label{wxdbtablegetcursor}
2843
2844\func{HSTMT}{GetCursor}{\void}
2845
107ffdc1 2846Returns the HSTMT value of the current cursor for this wxDbTable object.
eea22fd5 2847
d0c6b305
GT
2848\wxheading{Remarks}
2849
107ffdc1
RD
2850This function is typically used just before changing to use a different cursor
2851so that after the program is finished using the other cursor, the current
eea22fd5
GT
2852cursor can be set back to being the cursor in use.
2853
2854\wxheading{See also}
2855
2856\helpref{wxDbTable::SetCursor}{wxdbtablesetcursor}, \helpref{wxDbTable::GetNewCursor}{wxdbtablegetnewcursor}
2857
d0c6b305
GT
2858\membersection{wxDbTable::GetDb}\label{wxdbtablegetdb}
2859
2860\func{wxDb *}{GetDb}{}
2861
107ffdc1 2862Accessor function for the private member variable pDb which is a pointer to
eea22fd5 2863the datasource connection that this wxDbTable instance uses.
d0c6b305 2864
d0c6b305
GT
2865\membersection{wxDbTable::GetFirst}\label{wxdbtablegetfirst}
2866
2867\func{bool}{GetFirst}{\void}
2868
107ffdc1
RD
2869Retrieves the FIRST row in the record set as defined by the current query.
2870Before retrieving records, a query must be performed using
2871\helpref{wxDbTable::Query}{wxdbtablequery},
2872\helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields},
2873\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
eea22fd5
GT
2874\helpref{wxDbTable::QueryBySqlStmt}{wxdbtablequerybysqlstmt}.
2875
d0c6b305
GT
2876\wxheading{Remarks}
2877
107ffdc1 2878This function can only be used if the datasource connection used by the
cc81d32f 2879wxDbTable instance was created with FwdOnlyCursors set to false. If the
107ffdc1 2880connection does not allow backward scrolling cursors, this function will
cc81d32f 2881return false, and the data contained in the bound columns will be undefined.
d0c6b305
GT
2882
2883\wxheading{See also}
2884
19320af4 2885\helpref{wxDb::IsFwdOnlyCursors}{wxdbisfwdonlycursors}
d0c6b305
GT
2886
2887\membersection{wxDbTable::GetFromClause}\label{wxdbtablegetfromclause}
2888
7af3ca16 2889\func{const wxString \&}{GetFromClause}{}
d0c6b305 2890
107ffdc1 2891Accessor function that returns the current FROM setting assigned with the
eea22fd5
GT
2892\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}.
2893
2894\wxheading{See also}
2895
2896\helpref{wxDbTable::From}{wxdbtablefrom}
2897
d0c6b305
GT
2898\membersection{wxDbTable::GetLast}\label{wxdbtablegetlast}
2899
2900\func{bool}{GetLast}{\void}
2901
107ffdc1
RD
2902Retrieves the LAST row in the record set as defined by the current query.
2903Before retrieving records, a query must be performed using
2904\helpref{wxDbTable::Query}{wxdbtablequery},
2905\helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields},
2906\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
eea22fd5
GT
2907\helpref{wxDbTable::QueryBySqlStmt}{wxdbtablequerybysqlstmt}.
2908
d0c6b305
GT
2909\wxheading{Remarks}
2910
107ffdc1 2911This function can only be used if the datasource connection used by the
cc81d32f 2912wxDbTable instance was created with FwdOnlyCursors set to false. If the
107ffdc1 2913connection does not allow backward scrolling cursors, this function will
cc81d32f 2914return false, and the data contained in the bound columns will be undefined.
d0c6b305
GT
2915
2916\wxheading{See also}
2917
19320af4 2918\helpref{wxDb::IsFwdOnlyCursors}{wxdbisfwdonlycursors}
d0c6b305
GT
2919
2920\membersection{wxDbTable::GetNewCursor}\label{wxdbtablegetnewcursor}
2921
cc81d32f
VS
2922\func{HSTMT *}{GetNewCursor}{\param{bool }{setCursor=false},
2923\param{bool }{bindColumns=true}}
d0c6b305 2924
107ffdc1
RD
2925This function will create a new cursor that can be used to access the table
2926being referenced by this wxDbTable instance, or to execute direct SQL commands
2927on without affecting the cursors that are already defined and possibly
9fe17bd3 2928positioned.
eea22fd5 2929
d0c6b305
GT
2930\wxheading{Parameters}
2931
107ffdc1 2932\docparam{setCursor}{{\it OPTIONAL}. Should this new cursor be set to be the
cc81d32f 2933current cursor after successfully creating the new cursor. Default is false.}
107ffdc1 2934\docparam{bindColumns}{{\it OPTIONAL}. Should this new cursor be bound to all
cc81d32f 2935the memory variables that the default cursor is bound to. Default is true.}
d0c6b305
GT
2936
2937\wxheading{Remarks}
2938
107ffdc1
RD
2939This new cursor must be closed using
2940\helpref{wxDbTable::DeleteCursor}{wxdbtabledeletecursor}
2941by the calling program before the wxDbTable instance is deleted, or both
9fe17bd3 2942memory and resource leaks will occur.
59990c22 2943
d0c6b305
GT
2944\membersection{wxDbTable::GetNext}\label{wxdbtablegetnext}
2945
2946\func{bool}{GetNext}{\void}
2947
107ffdc1
RD
2948Retrieves the NEXT row in the record set after the current cursor position
2949as defined by the current query. Before retrieving records, a query must be
2950performed using \helpref{wxDbTable::Query}{wxdbtablequery},
2951\helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields},
2952\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
eea22fd5
GT
2953\helpref{wxDbTable::QueryBySqlStmt}{wxdbtablequerybysqlstmt}.
2954
2955\wxheading{Return value}
2956
cc81d32f
VS
2957This function returns false when the current cursor has reached the end of
2958the result set. When false is returned, data in the bound columns is
eea22fd5
GT
2959undefined.
2960
59990c22
GT
2961\wxheading{Remarks}
2962
2963This function works with both forward and backward scrolling cursors.
2964
eea22fd5
GT
2965\wxheading{See also}
2966\helpref{wxDbTable::++}{wxdbtableplusplus}
d0c6b305 2967
d0c6b305
GT
2968\membersection{wxDbTable::GetNumberOfColumns}\label{wxdbtablegetnumberofcolumns}
2969
0715c838 2970\func{UWORD }{GetNumberOfColumns}{}
d0c6b305 2971
107ffdc1 2972Accessor function that returns the number of columns that are statically
eea22fd5
GT
2973bound for access by the wxDbTable instance.
2974
d0c6b305
GT
2975\membersection{wxDbTable::GetOrderByClause}\label{wxdbtablegetorderbyclause}
2976
7af3ca16 2977\func{const wxString \&}{GetOrderByClause}{}
d0c6b305 2978
107ffdc1 2979Accessor function that returns the current ORDER BY setting assigned with
eea22fd5
GT
2980the \helpref{wxDbTable::SetOrderByClause}{wxdbtablesetorderbyclause}.
2981
2982\wxheading{See also}
2983
2984\helpref{wxDbTable::OrderBy}{wxdbtableorderby}
2985
d0c6b305
GT
2986\membersection{wxDbTable::GetPrev}\label{wxdbtablegetprev}
2987
2988\func{bool}{GetPrev}{\void}
2989
107ffdc1
RD
2990Retrieves the PREVIOUS row in the record set before the current cursor
2991position as defined by the current query. Before retrieving records, a
2992query must be performed using \helpref{wxDbTable::Query}{wxdbtablequery},
2993\helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields},
2994\helpref{wxDbTable::QueryMatching}{wxdbtablequerymatching} or
eea22fd5
GT
2995\helpref{wxDbTable::QueryBySqlStmt}{wxdbtablequerybysqlstmt}.
2996
2997\wxheading{Return value}
2998
cc81d32f 2999This function returns false when the current cursor has reached the beginning
107ffdc1 3000of the result set and there are now other rows prior to the cursors current
cc81d32f 3001position. When false is returned, data in the bound columns is undefined.
eea22fd5 3002
d0c6b305
GT
3003\wxheading{Remarks}
3004
107ffdc1 3005This function can only be used if the datasource connection used by the
cc81d32f 3006wxDbTable instance was created with FwdOnlyCursors set to false. If the
107ffdc1 3007connection does not allow backward scrolling cursors, this function will
cc81d32f 3008return false, and the data contained in the bound columns will be undefined.
d0c6b305
GT
3009
3010\wxheading{See also}
3011
107ffdc1 3012\helpref{wxDb::IsFwdOnlyCursors}{wxdbisfwdonlycursors},
eea22fd5 3013\helpref{wxDbTable::--}{wxdbtableminusminus}
d0c6b305 3014
d0c6b305
GT
3015\membersection{wxDbTable::GetQueryTableName}\label{wxdbtablegetquerytablename}
3016
7af3ca16 3017\func{const wxString \&}{GetQueryTableName}{}
d0c6b305 3018
107ffdc1
RD
3019Accessor function that returns the name of the table/view that was indicated
3020as being the table/view to query against when this wxDbTable instance was
eea22fd5
GT
3021created.
3022
3023\wxheading{See also}
3024
3025\helpref{wxDbTable constructor}{wxdbtableconstr}
3026
d0c6b305
GT
3027\membersection{wxDbTable::GetRowNum}\label{wxdbtablegetrownum}
3028
3029\func{UWORD}{GetRowNum}{\void}
3030
107ffdc1 3031Returns the ODBC row number for performing positioned updates and deletes.
eea22fd5 3032
d0c6b305
GT
3033\wxheading{Remarks}
3034
107ffdc1 3035This function is not being used within the ODBC class library and may be a
eea22fd5
GT
3036candidate for removal if no use is found for it.
3037
107ffdc1
RD
3038Row number with some datasources/ODBC drivers is the position in the result set,
3039while in others it may be a physical position in the database. Check your
59990c22
GT
3040database documentation to find out which behavior is supported.
3041
d0c6b305
GT
3042\membersection{wxDbTable::GetTableName}\label{wxdbtablegettablename}
3043
7af3ca16 3044\func{const wxString \&}{GetTableName}{}
d0c6b305 3045
107ffdc1 3046Accessor function that returns the name of the table that was indicated
eea22fd5
GT
3047as being the table that this wxDbTable instance was associated with.
3048
d0c6b305
GT
3049\membersection{wxDbTable::GetTablePath}\label{wxdbtablegettablepath}
3050
7af3ca16 3051\func{const wxString \&}{GetTablePath}{}
d0c6b305 3052
107ffdc1 3053Accessor function that returns the path to the data table that was indicated
eea22fd5
GT
3054during creation of this wxDbTable instance.
3055
d0c6b305
GT
3056\wxheading{Remarks}
3057
eea22fd5
GT
3058Currently only applicable to dBase and MS-Access datasources.
3059
d0c6b305
GT
3060\membersection{wxDbTable::GetWhereClause}\label{wxdbtablegetwhereclause}
3061
7af3ca16 3062\func{const wxString \&}{GetWhereClause}{}
d0c6b305 3063
107ffdc1 3064Accessor function that returns the current WHERE setting assigned with the
eea22fd5
GT
3065\helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
3066
3067\wxheading{See also}
3068
3069\helpref{wxDbTable::Where}{wxdbtablewhere}
3070
d0c6b305
GT
3071\membersection{wxDbTable::Insert}\label{wxdbtableinsert}
3072
c67d6048 3073\func{int }{Insert}{\void}
d0c6b305 3074
107ffdc1
RD
3075Inserts a new record into the table being referenced by this wxDbTable
3076instance. The values in the member variables of the wxDbTable instance are
59990c22 3077inserted into the columns of the new row in the database.
107ffdc1 3078
eea22fd5
GT
3079\wxheading{Return value}
3080
3081\begin{verbatim}
3082 DB_SUCCESS Record inserted successfully (value = 1)
3083
3084 DB_FAILURE Insert failed (value = 0)
3085
107ffdc1 3086 DB_ERR_INTEGRITY_CONSTRAINT_VIOL
eea22fd5
GT
3087 The insert failed due to an integrity
3088 constraint violation (duplicate non-unique
3089 index entry) is attempted.
3090\end{verbatim}
3091
3092\wxheading{Remarks}
3093
107ffdc1
RD
3094A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
3095\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
eea22fd5
GT
3096this function to commit or rollback the insertion.
3097
3098\wxheading{Example}
3099
3100\begin{verbatim}
3101 // Incomplete code snippet
9fe17bd3
GT
3102 wxStrcpy(parts->PartName, "10");
3103 wxStrcpy(parts->PartDesc, "Part #10");
eea22fd5 3104 parts->Qty = 1000;
6ff1cefa 3105 RETCODE retcode = parts->Insert();
eea22fd5
GT
3106 switch(retcode)
3107 {
3108 case DB_SUCCESS:
3109 parts->GetDb()->CommitTrans();
cc81d32f 3110 return(true);
eea22fd5
GT
3111 case DB_ERR_INTEGRITY_CONSTRAINT_VIOL:
3112 // Current data would result in a duplicate key
3113 // on one or more indexes that do not allow duplicates
3114 parts->GetDb()->RollbackTrans();
cc81d32f 3115 return(false);
eea22fd5
GT
3116 default:
3117 // Insert failed for some unexpected reason
3118 parts->GetDb()->RollbackTrans();
cc81d32f 3119 return(false);
eea22fd5
GT
3120 }
3121\end{verbatim}
3122
eea22fd5
GT
3123\membersection{wxDbTable::IsColNull}\label{wxdbtableiscolnull}
3124
998abc15 3125\func{bool }{IsColNull}{\param{UWORD }{colNumber}} const
eea22fd5 3126
107ffdc1 3127Used primarily in the ODBC class library to determine if a column value is
9fe17bd3 3128set to "NULL". Works for all data types supported by the ODBC class library.
eea22fd5
GT
3129
3130\wxheading{Parameters}
3131
998abc15 3132\docparam{colNumber}{The column number of the bound column as defined by the
107ffdc1 3133\helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}
19320af4 3134calls which defined the columns accessible to this wxDbTable instance.}
eea22fd5 3135
d0c6b305
GT
3136\wxheading{Remarks}
3137
fc2171bd 3138NULL column support is currently not fully implemented as of wxWidgets 2.4.
eea22fd5 3139
d0c6b305
GT
3140\membersection{wxDbTable::IsCursorClosedOnCommit}\label{wxdbtableiscursorclosedoncommit}
3141
9fe17bd3 3142\func{bool }{IsCursorClosedOnCommit}{\void}
d0c6b305 3143
107ffdc1
RD
3144Accessor function to return information collected during the opening of the
3145datasource connection that is used by this wxDbTable instance. The result
3146returned by this function indicates whether an implicit closing of the cursor is
59990c22 3147done after a commit on the database connection.
eea22fd5
GT
3148
3149\wxheading{Return value}
3150
cc81d32f
VS
3151Returns true if the cursor associated with this wxDbTable object is closed
3152after a commit or rollback operation. Returns false otherwise.
eea22fd5 3153
59990c22
GT
3154\wxheading{Remarks}
3155
107ffdc1
RD
3156If more than one wxDbTable instance used the same database connection, all cursors
3157which use the database connection are closed on the commit if this function
cc81d32f 3158indicates true.
59990c22 3159
d0c6b305
GT
3160\membersection{wxDbTable::IsQueryOnly}\label{wxdbtableisqueryonly}
3161
9fe17bd3 3162\func{bool }{IsQueryOnly}{}
d0c6b305 3163
107ffdc1
RD
3164Accessor function that returns a value indicating if this wxDbTable instance
3165was created to allow only queries to be performed on the bound columns. If
cc81d32f 3166this function returns true, then no actions may be performed using this
eea22fd5
GT
3167wxDbTable instance that would modify (insert/delete/update) the table's data.
3168
d0c6b305
GT
3169\membersection{wxDbTable::Open}\label{wxdbtableopen}
3170
cc81d32f 3171\func{bool }{Open}{\param{bool }{checkPrivileges=false}, \param{bool }{checkTableExists=true}}
d0c6b305 3172
107ffdc1
RD
3173Every wxDbTable instance must be opened before it can be used. This function
3174checks for the existence of the requested table, binds columns, creates required
3175cursors, (insert/select and update if connection is not wxDB\_QUERY\_ONLY) and
3176constructs the insert statement that is to be used for inserting data as a new
59990c22
GT
3177row in the datasource.
3178
e32d2b57
GT
3179NOTE: To retrieve data into an opened table, the of the table must be bound
3180to the variables in the program via call(s) to
3181\helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs} before calling Open().
3182
3183See the \helpref{database classes overview}{odbcoverview} for
3184an introduction to using the ODBC classes.
3185
59990c22
GT
3186\wxheading{Parameters}
3187
107ffdc1
RD
3188\docparam{checkPrivileges}{Indicates whether the Open() function should check
3189whether the current connected user has at least SELECT privileges to access the
cc81d32f 3190table to which they are trying to open. Default is false.}
eea22fd5 3191
107ffdc1 3192\docparam{checkTableExists}{Indicates whether the Open() function should check
cc81d32f 3193whether the table exists in the database or not before opening it. Default is true.}
1454d4e6 3194
d0c6b305
GT
3195\wxheading{Remarks}
3196
cc81d32f 3197If the function returns a false value due to the table not existing, a log
107ffdc1
RD
3198entry is recorded for the datasource connection indicating the problem
3199that was detected when checking for table existence. Note that it is usually
3200best for the calling routine to check for the existence of the table and for
2edb0bde 3201sufficient user privileges to access the table in the mode (wxDB\_QUERY\_ONLY or
107ffdc1 3202!wxDB\_QUERY\_ONLY) before trying to open the table for the best possible
59990c22
GT
3203explanation as to why a table cannot be opened.
3204
107ffdc1
RD
3205Checking the user's privileges on a table can be quite time consuming during
3206the open phase. With most applications, the programmer already knows that the
3207user has sufficient privileges to access the table, so this check is normally
59990c22
GT
3208not required.
3209
107ffdc1
RD
3210For best performance, open the table, and then use the
3211\helpref{wxDb::TablePrivileges}{wxdbtableprivileges} function
3212to check the users privileges. Passing a schema to the TablePrivileges()
59990c22 3213function can significantly speed up the privileges checks.
eea22fd5
GT
3214
3215\wxheading{See also}
3216
107ffdc1 3217\helpref{wxDb::TableExists}{wxdbtableexists},
59990c22 3218\helpref{wxDb::TablePrivileges}{wxdbtableprivileges}
e32d2b57 3219\helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}
eea22fd5 3220
eea22fd5
GT
3221\membersection{wxDbTable::OrderBy}\label{wxdbtableorderby}
3222
7af3ca16 3223\func{const wxString \&}{OrderBy}{}
59990c22 3224
7af3ca16 3225\func{void}{OrderBy}{\param{const wxString \&}{OrderBy}}
eea22fd5 3226
107ffdc1
RD
3227Accessor function for the private class member wxDbTable::orderBy. Can be
3228used as a synonym for
3229\helpref{wxDbTable::GetOrderByClause}{wxdbtablegetorderbyclause}
3230(the first form of this function) or
3231\helpref{wxDbTable::SetOrderByClause}{wxdbtablesetorderbyclause}
eea22fd5
GT
3232(the second form of this function).
3233
3234\wxheading{Parameters}
3235
107ffdc1
RD
3236\docparam{OrderBy}{A comma separated list of column names that indicate the
3237alphabetized/numeric sorting sequence that the result set is to be returned
3238in. If a FROM clause has also been specified, each column name specified in
3239the ORDER BY clause should be prefaced with the table name to which the column
e7240349 3240belongs using DOT notation (TABLE\_NAME.COLUMN\_NAME).}
eea22fd5
GT
3241
3242\wxheading{Return value}
3243
107ffdc1
RD
3244The first form of this function returns the current value of the wxDbTable
3245member variable ::orderBy.
eea22fd5
GT
3246
3247The second form of the function has no return value.
3248
3249\wxheading{See also}
3250
107ffdc1 3251\helpref{wxDbTable::GetOrderByClause}{wxdbtablegetorderbyclause},
eea22fd5
GT
3252\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}
3253
d0c6b305
GT
3254\membersection{wxDbTable::Query}\label{wxdbtablequery}
3255
cc81d32f 3256\func{virtual bool }{Query}{\param{bool }{forUpdate=false}, \param{bool }{distinct=false}}
d0c6b305
GT
3257
3258\wxheading{Parameters}
3259
107ffdc1
RD
3260\docparam{forUpdate}{{\it OPTIONAL}. Gives you the option of locking records
3261as they are retrieved. If the RDBMS is not capable of the FOR UPDATE clause,
3262this argument is ignored. See
3263\helpref{wxDbTable::CanSelectForUpdate}{wxdbtablecanselectforupdate} for
cc81d32f 3264additional information regarding this argument. Default is false.}
107ffdc1
RD
3265\docparam{distinct}{{\it OPTIONAL}. Allows selection of only distinct values
3266from the query (SELECT DISTINCT ... FROM ...). The notion of DISTINCT
3267applies to all columns returned in the result set, not individual columns.
cc81d32f 3268Default is false.}
eea22fd5
GT
3269
3270\wxheading{Remarks}
3271
107ffdc1
RD
3272This function queries records from the datasource based on the three
3273wxDbTable members: "where", "orderBy", and "from". Use
3274\helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause} to filter on
3275records to be retrieved (e.g. All users with a first name of "JOHN").
3276Use \helpref{wxDbTable::SetOrderByClause}{wxdbtablesetorderbyclause} to
3277change the sequence in which records are returned in the result set from
3278the datasource (e.g. Ordered by LAST\_NAME). Use
90e7e277 3279\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} to allow inner
107ffdc1
RD
3280joining of the base table (the one being associated with this instance of
3281wxDbTable) with other tables which share a related field.
eea22fd5 3282
107ffdc1
RD
3283After each of these clauses are set/cleared, call wxDbTable::Query() to
3284fetch the result set from the datasource.
eea22fd5 3285
107ffdc1
RD
3286This scheme has an advantage if you have to requery your record set
3287frequently in that you only have to set your WHERE, ORDER BY, and FROM
3288clauses once. Then to refresh the record set, simply call wxDbTable::Query()
3289as frequently as needed.
eea22fd5 3290
107ffdc1
RD
3291Note that repeated calls to wxDbTable::Query() may tax the database
3292server and make your application sluggish if done too frequently or
3293unnecessarily.
eea22fd5 3294
107ffdc1
RD
3295The base table name is automatically prepended to the base column names in
3296the event that the FROM clause has been set (is non-null) using
eea22fd5
GT
3297\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}.
3298
107ffdc1
RD
3299The cursor for the result set is positioned {\it before} the first record in
3300the result set after the query. To retrieve the first record, call either
3301\helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} (only if backward scrolling
3302cursors are available) or
3303\helpref{wxDbTable::GetNext}{wxdbtablegetnext}. Typically, no data from the
3304result set is returned to the client driver until a request such as
3305\helpref{wxDbTable::GetNext}{wxdbtablegetnext} is performed, so network
3306traffic and database load are not overwhelmed transmitting data until the
3307data is actually requested by the client. This behavior is solely dependent
3308on the ODBC driver though, so refer to the ODBC driver's reference material
eea22fd5
GT
3309for information on its behaviors.
3310
107ffdc1
RD
3311Values in the bound columns' memory variables are undefined after executing a
3312call to this function and remain that way until a row in the result set is
59990c22
GT
3313requested to be returned.
3314
107ffdc1 3315The wxDbTable::Query() function is defined as "virtual" so that it may be
eea22fd5
GT
3316overridden for application specific purposes.
3317
107ffdc1
RD
3318\normalbox{Be sure to set the wxDbTable's "where", "orderBy", and "from"
3319member variables to "" if they are not to be used in the query. Otherwise,
3320the results returned may have unexpected results (or no results) due to
3321improper or incorrect query parameters constructed from the uninitialized
eea22fd5
GT
3322clauses.}
3323
3324\wxheading{Example}
3325
3326\begin{verbatim}
3327 // Incomplete code sample
3328 parts->SetWhereClause("DESCRIPTION = 'FOOD'");
3329 parts->SetOrderByClause("EXPIRATION_DATE");
3330 parts->SetFromClause("");
107ffdc1 3331 // Query the records based on the where, orderBy and from clauses
eea22fd5
GT
3332 // specified above
3333 parts->Query();
3334 // Display all records queried
3335 while(parts->GetNext())
3336 dispPart(parts); // user defined function
3337\end{verbatim}
d0c6b305 3338
d0c6b305
GT
3339\membersection{wxDbTable::QueryBySqlStmt}\label{wxdbtablequerybysqlstmt}
3340
7af3ca16 3341\func{bool}{QueryBySqlStmt}{\param{const wxString \&}{pSqlStmt}}
d0c6b305 3342
107ffdc1 3343Performs a query against the datasource by accepting and passing verbatim the
eea22fd5
GT
3344SQL SELECT statement passed to the function.
3345
d0c6b305
GT
3346\wxheading{Parameters}
3347
59990c22 3348\docparam{pSqlStmt}{Pointer to the SQL SELECT statement to be executed.}
d0c6b305
GT
3349
3350\wxheading{Remarks}
3351
107ffdc1
RD
3352This is the most powerful form of the query functions available. This member
3353function allows a programmer to write their own custom SQL SELECT statement
3354for requesting data from the datasource. This gives the programmer access
3355to the full power of SQL for performing operations such as scalar functions,
3356aggregate functions, table joins, and sub-queries, as well as datasource
3357specific function calls.
eea22fd5
GT
3358
3359The requirements of the SELECT statement are the following:
3360
05dedde7
JS
3361\begin{enumerate}
3362\item Must return the correct number of columns. In the derived
3363wxDbTable constructor, it is specified how many columns are in
3364the wxDbTable object. The SELECT statement must return exactly
3365that many columns.
3366\item The columns must be returned in the same sequence as specified
e32d2b57 3367when defining the bounds columns \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs},
05dedde7
JS
3368and the columns returned must be of the proper data type. For
3369example, if column 3 is defined in the wxDbTable bound column
3370definitions to be a float, the SELECT statement must return a
3371float for column 3 (e.g. PRICE * 1.10 to increase the price by
337210%).
e626d7c7 3373\item The ROWID can be included in your SELECT statement as the {\bf last}
05dedde7 3374column selected, if the datasource supports it. Use
998abc15 3375wxDbTable::CanUpdateByROWID() to determine if the ROWID can be
05dedde7
JS
3376selected from the datasource. If it can, much better
3377performance can be achieved on updates and deletes by including
3378the ROWID in the SELECT statement.
3379\end{enumerate}
eea22fd5 3380
107ffdc1 3381Even though data can be selected from multiple tables (joins) in your select
59990c22 3382statement, only the base table associated with this wxDbTable object
107ffdc1
RD
3383is automatically updated through the ODBC class library. Data from multiple
3384tables can be selected for display purposes however. Include columns in
3385the wxDbTable object and mark them as non-updateable (See
3386\helpref{wxDbColDef}{wxdbcoldef} for details). This way columns can be
3387selected and displayed from other tables, but only the base table will be
3388updated automatically when performed through the
3389\helpref{wxDbTable::Update}{wxdbtableupdate} function after using this type of
3390query. To update tables other than the base table, use the
eea22fd5
GT
3391\helpref{wxDbTable::Update}{wxdbtableupdate} function passing a SQL statement.
3392
107ffdc1
RD
3393After this function has been called, the cursor is positioned before the
3394first record in the record set. To retrieve the first record, call
3395either \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} or
eea22fd5
GT
3396\helpref{wxDbTable::GetNext}{wxdbtablegetnext}.
3397
3398\wxheading{Example}
3399
3400\begin{verbatim}
3401 // Incomplete code samples
9fe17bd3
GT
3402 wxString sqlStmt;
3403 sqlStmt = "SELECT * FROM PARTS WHERE STORAGE_DEVICE = 'SD98' \
3404 AND CONTAINER = 12";
eea22fd5
GT
3405 // Query the records using the SQL SELECT statement above
3406 parts->QueryBySqlStmt(sqlStmt);
3407 // Display all records queried
3408 while(parts->GetNext())
3409 dispPart(&parts);
3410
3411 Example SQL statements
3412 ----------------------
3413
3414 // Table Join returning 3 columns
998abc15 3415 SELECT PART_NUM, part_desc, sd_name
eea22fd5 3416 from parts, storage_devices
107ffdc1 3417 where parts.storage_device_id =
59990c22 3418 storage_devices.storage_device_id
eea22fd5 3419
107ffdc1 3420 // Aggregate function returning total number of
59990c22 3421 // parts in container 99
eea22fd5
GT
3422 SELECT count(*) from PARTS where container = 99
3423
3424 // Order by clause; ROWID, scalar function
998abc15 3425 SELECT PART_NUM, substring(part_desc, 1, 10), qty_on_hand + 1, ROWID
eea22fd5
GT
3426 from parts
3427 where warehouse = 10
998abc15 3428 order by PART_NUM desc // descending order
eea22fd5
GT
3429
3430 // Subquery
3431 SELECT * from parts
3432 where container in (select container
3433 from storage_devices
3434 where device_id = 12)
3435\end{verbatim}
3436
d0c6b305
GT
3437\membersection{wxDbTable::QueryMatching}\label{wxdbtablequerymatching}
3438
cc81d32f
VS
3439\func{virtual bool }{QueryMatching}{\param{bool }{forUpdate=false},
3440\param{bool }{distinct=false}}
eea22fd5 3441
107ffdc1
RD
3442QueryMatching allows querying of records from the table associated with
3443the wxDbTable object by matching "columns" to values.
eea22fd5 3444
107ffdc1
RD
3445For example: To query the datasource for the row with a PART\_NUMBER column
3446value of "32", clear all column variables of the wxDbTable object, set the
3447PartNumber variable that is bound to the PART\_NUMBER column in the wxDbTable
eea22fd5 3448object to "32", and then call wxDbTable::QueryMatching().
d0c6b305
GT
3449
3450\wxheading{Parameters}
3451
107ffdc1
RD
3452\docparam{forUpdate}{{\it OPTIONAL}. Gives you the option of locking records
3453as they are queried (SELECT ... FOR UPDATE). If the RDBMS is not capable of
3454the FOR UPDATE clause, this argument is ignored. See
3455\helpref{wxDbTable::CanSelectForUpdate}{wxdbtablecanselectforupdate} for
cc81d32f 3456additional information regarding this argument. Default is false.}
107ffdc1
RD
3457\docparam{distinct}{{\it OPTIONAL}. Allows selection of only distinct values
3458from the query (SELECT DISTINCT ... FROM ...). The notion of DISTINCT
3459applies to all columns returned in the result set, not individual columns.
cc81d32f 3460Default is false.}
d0c6b305
GT
3461
3462\wxheading{Remarks}
3463
107ffdc1
RD
3464The SQL WHERE clause is built by the ODBC class library based on all
3465non-zero/non-NULL columns in your wxDbTable object. Matches can be on one,
3466many or all of the wxDbTable's columns. The base table name is prepended
eea22fd5
GT
3467to the column names in the event that the wxDbTable's FROM clause is non-null.
3468
107ffdc1
RD
3469This function cannot be used to perform queries which will check for
3470columns that are 0 or NULL, as the automatically constructed WHERE clause
3471only will contain comparisons on column member variables that are
eea22fd5
GT
3472non-zero/non-NULL.
3473
107ffdc1
RD
3474The primary difference between this function and \helpref{wxDbTable::QueryOnKeyFields}{wxdbtablequeryonkeyfields}
3475is that this function can query on any column(s) in the wxDbTable object.
3476Note however that this may not always be very efficient. Searching on
eea22fd5
GT
3477non-indexed columns will always require a full table scan.
3478
107ffdc1
RD
3479The cursor is positioned before the first record in the record set after
3480the query is performed. To retrieve the first record, the program must call
3481either \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} or
eea22fd5
GT
3482\helpref{wxDbTable::GetNext}{wxdbtablegetnext}.
3483
107ffdc1
RD
3484WHERE and FROM clauses specified using \helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
3485and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by
59990c22
GT
3486this function.
3487
eea22fd5
GT
3488\wxheading{Example}
3489
3490\begin{verbatim}
3491 // Incomplete code sample
3492 parts->ClearMemberVars(); // Set all columns to zero
9fe17bd3 3493 wxStrcpy(parts->PartNumber,"32"); // Set columns to query on
cc81d32f 3494 parts->OnHold = true;
eea22fd5
GT
3495 parts->QueryMatching(); // Query
3496 // Display all records queried
3497 while(parts->GetNext())
3498 dispPart(parts); // Some application defined function
3499\end{verbatim}
3500
d0c6b305
GT
3501\membersection{wxDbTable::QueryOnKeyFields}\label{wxdbtablequeryonkeyfields}
3502
cc81d32f
VS
3503\func{bool }{QueryOnKeyFields}{\param{bool }{forUpdate=false},
3504\param{bool }{distinct=false}}
eea22fd5 3505
107ffdc1
RD
3506QueryOnKeyFields provides an easy mechanism to query records in the table
3507associated with the wxDbTable object by the primary index column(s). Simply
3508assign the primary index column(s) values and then call this member function
3509to retrieve the record.
eea22fd5 3510
107ffdc1
RD
3511Note that since primary indexes are always unique, this function implicitly
3512always returns a single record from the database. The base table name is
3513prepended to the column names in the event that the wxDbTable's FROM clause
eea22fd5 3514is non-null.
d0c6b305
GT
3515
3516\wxheading{Parameters}
3517
107ffdc1
RD
3518\docparam{forUpdate}{{\it OPTIONAL}. Gives you the option of locking records
3519as they are queried (SELECT ... FOR UPDATE). If the RDBMS is not capable of
3520the FOR UPDATE clause, this argument is ignored. See
3521\helpref{wxDbTable::CanSelectForUpdate}{wxdbtablecanselectforupdate} for
cc81d32f 3522additional information regarding this argument. Default is false.}
107ffdc1
RD
3523\docparam{distinct}{{\it OPTIONAL}. Allows selection of only distinct values
3524from the query (SELECT DISTINCT ... FROM ...). The notion of DISTINCT
3525applies to all columns returned in the result set, not individual columns.
cc81d32f 3526Default is false.}
d0c6b305
GT
3527
3528\wxheading{Remarks}
3529
107ffdc1
RD
3530The cursor is positioned before the first record in the record set after
3531the query is performed. To retrieve the first record, the program must call
3532either \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} or
eea22fd5
GT
3533\helpref{wxDbTable::GetNext}{wxdbtablegetnext}.
3534
107ffdc1
RD
3535WHERE and FROM clauses specified using \helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
3536and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by
59990c22
GT
3537this function.
3538
eea22fd5
GT
3539\wxheading{Example}
3540
3541\begin{verbatim}
3542 // Incomplete code sample
9fe17bd3 3543 wxStrcpy(parts->PartNumber, "32");
eea22fd5
GT
3544 parts->QueryOnKeyFields();
3545 // Display all records queried
3546 while(parts->GetNext())
3547 dispPart(parts); // Some application defined function
3548\end{verbatim}
3549
d0c6b305
GT
3550\membersection{wxDbTable::Refresh}\label{wxdbtablerefresh}
3551
3552\func{bool}{Refresh}{\void}
3553
107ffdc1 3554This function re-reads the bound columns into the memory variables, setting
59990c22 3555them to the current values stored on the disk.
eea22fd5
GT
3556
3557The cursor position and result set are unaffected by calls to this function.
107ffdc1
RD
3558(The one exception is in the case where the record to be refreshed has been
3559deleted by some other user or transaction since it was originally retrieved
3560as part of the result set. For most datasources, the default behavior in
3561this situation is to return the value that was originally queried for the
3562result set, even though it has been deleted from the database. But this is
eea22fd5
GT
3563datasource dependent, and should be tested before relying on this behavior.)
3564
d0c6b305
GT
3565\wxheading{Remarks}
3566
107ffdc1
RD
3567This routine is only guaranteed to work if the table has a unique primary
3568index defined for it. Otherwise, more than one record may be fetched and
3569there is no guarantee that the correct record will be refreshed. The
eea22fd5
GT
3570table's columns are refreshed to reflect the current data in the database.
3571
d0c6b305
GT
3572\membersection{wxDbTable::SetColDefs}\label{wxdbtablesetcoldefs}
3573
549c8cc2 3574\func{bool}{SetColDefs}{\param{UWORD }{index}, \param{const wxString \&}{fieldName},
107ffdc1 3575\param{int }{dataType}, \param{void *}{pData}, \param{SWORD }{cType},
549c8cc2
GT
3576\param{int }{size}, \param{bool }{keyField = false}, \param{bool }{updateable = true},
3577\param{bool }{insertAllowed = true}, \param{bool }{derivedColumn = false}}
d0c6b305 3578
0715c838 3579\func{wxDbColDataPtr *}{SetColDefs}{\param{wxDbColInf *}{colInfs}, \param{UWORD }{numCols}}
d0c6b305
GT
3580
3581\wxheading{Parameters}
3582
107ffdc1
RD
3583\docparam{index}{Column number (0 to n-1, where n is the number of columns
3584specified as being defined for this wxDbTable instance when the
eea22fd5
GT
3585wxDbTable constructor was called.}
3586\docparam{fieldName}{Column name from the associated data table.}
3587\docparam{dataType}{Logical data type. Valid logical types include:}
d0c6b305 3588
eea22fd5
GT
3589\begin{verbatim}
3590 DB_DATA_TYPE_VARCHAR : strings
3591 DB_DATA_TYPE_INTEGER : non-floating point numbers
3592 DB_DATA_TYPE_FLOAT : floating point numbers
3593 DB_DATA_TYPE_DATE : dates
7eeba511
JS
3594 DB_DATA_TYPE_BLOB : binary large objects
3595 DB_DATA_TYPE_MEMO : large strings
eea22fd5
GT
3596\end{verbatim}
3597
107ffdc1 3598\docparam{pData}{Pointer to the data object that will hold the column's
eea22fd5 3599value when a row of data is returned from the datasource.}
107ffdc1 3600\docparam{cType}{SQL C Type. This defines the data type that the SQL
eea22fd5
GT
3601representation of the data is converted to to be stored in {\it pData}.
3602Other valid types are available also, but these are the most common ones:}
3603
3604\begin{verbatim}
998abc15
GT
3605 SQL_C_CHAR // string - deprecated: use SQL_C_WXCHAR
3606 SQL_C_WXCHAR // string - Used transparently in unicode or non-unicode builds
eea22fd5
GT
3607 SQL_C_LONG
3608 SQL_C_ULONG
3609 SQL_C_SHORT
3610 SQL_C_USHORT
3611 SQL_C_FLOAT
3612 SQL_C_DOUBLE
107ffdc1 3613 SQL_C_NUMERIC
eea22fd5
GT
3614 SQL_C_TIMESTAMP
3615
3616 SQL_C_BOOLEAN // defined in db.h
3617 SQL_C_ENUM // defined in db.h
3618\end{verbatim}
3619
3620\docparam{size}{Maximum size in bytes of the {\it pData} object.}
107ffdc1 3621\docparam{keyField}{{\it OPTIONAL}. Indicates if this column is part of the
cc81d32f 3622primary index. Default is false.}
549c8cc2 3623\docparam{updateable}{{\it OPTIONAL}. Are updates allowed on this column?
cc81d32f 3624Default is true.}
549c8cc2 3625\docparam{insertAllowed}{{\it OPTIONAL}. Inserts allowed on this column?
cc81d32f 3626Default is true.}
549c8cc2 3627\docparam{derivedColumn}{{\it OPTIONAL}. Is this a derived column (non-base
cc81d32f 3628table column for query only)? Default is false.}
eea22fd5 3629
107ffdc1 3630\docparam{colInfs}{Pointer to an array of wxDbColInf instances which contains
eea22fd5 3631all the information necessary to create {\it numCols} column definitions.}
107ffdc1 3632\docparam{numCols}{Number of elements of wxDbColInf type that are pointed
eea22fd5 3633to by {\it colInfs}, which are to have column definitions created from them.}
d0c6b305
GT
3634
3635\wxheading{Remarks}
3636
107ffdc1 3637If {\it pData} is to hold a string of characters, be sure to include enough
eea22fd5
GT
3638space for the NULL terminator in pData and in the byte count of {\it size}.
3639
549c8cc2
GT
3640Using the first form of this function, if the column definition is not able
3641to be created, a value of false is returned. If the specified index of the
3642column exceeds the number of columns defined in the wxDbTable instance, an
3643assert is thrown and logged (in debug builds) and a false is returned.
3644
3645A failure to create the column definition in the second form results in a
3646value of NULL being returned.
3647
107ffdc1
RD
3648Both forms of this function provide a shortcut for defining the columns in
3649your wxDbTable object. Use this function in any derived wxDbTable
eea22fd5
GT
3650constructor when describing the column/columns in the wxDbTable object.
3651
107ffdc1
RD
3652The second form of this function is primarily used when the
3653\helpref{wxDb::GetColumns}{wxdbgetcolumns} function was used to query the
3654datasource for the column definitions, so that the column definitions are
3655already stored in wxDbColInf form. One example use of using
3656\helpref{wxDb::GetColumns}{wxdbgetcolumns} then using this function is if
3657a data table existed in one datasource, and the table's column definitions
eea22fd5
GT
3658were to be copied over to another datasource or table.
3659
3660\wxheading{Example}
3661
3662\begin{verbatim}
3663 // Long way not using this function
998abc15 3664 wxStrcpy(colDefs[0].ColName, "PART_NUM");
eea22fd5
GT
3665 colDefs[0].DbDataType = DB_DATA_TYPE_VARCHAR;
3666 colDefs[0].PtrDataObj = PartNumber;
998abc15 3667 colDefs[0].SqlCtype = SQL_C_WXCHAR;
eea22fd5 3668 colDefs[0].SzDataObj = PART_NUMBER_LEN;
cc81d32f
VS
3669 colDefs[0].KeyField = true;
3670 colDefs[0].Updateable = false;
3671 colDefs[0].InsertAllowed= true;
3672 colDefs[0].DerivedCol = false;
eea22fd5
GT
3673
3674 // Shortcut using this function
998abc15
GT
3675 SetColDefs(0, "PART_NUM", DB_DATA_TYPE_VARCHAR, PartNumber,
3676 SQL_C_WXCHAR, PART_NUMBER_LEN, true, false, true, false);
eea22fd5
GT
3677\end{verbatim}
3678
d0c6b305
GT
3679\membersection{wxDbTable::SetCursor}\label{wxdbtablesetcursor}
3680
f6e9a818 3681\func{void}{SetCursor}{\param{HSTMT *}{hstmtActivate = (void **) wxDB\_DEFAULT\_CURSOR}}
d0c6b305
GT
3682
3683\wxheading{Parameters}
3684
107ffdc1
RD
3685\docparam{hstmtActivate}{{\it OPTIONAL}. Pointer to the cursor that is to
3686become the current cursor. Passing no cursor handle will reset the cursor
3687back to the wxDbTable's default (original) cursor that was created when the
e7240349 3688wxDbTable instance was first created. Default is wxDB\_DEFAULT\_CURSOR.}
d0c6b305
GT
3689
3690\wxheading{Remarks}
3691
107ffdc1
RD
3692When swapping between cursors, the member variables of the wxDbTable object
3693are automatically refreshed with the column values of the row that the
3694current cursor is positioned at (if any). If the cursor is not positioned,
eea22fd5
GT
3695then the data in member variables is undefined.
3696
107ffdc1
RD
3697The only way to return back to the cursor that was in use before this
3698function was called is to programmatically determine the current cursor's HSTMT
3699{\bf BEFORE} calling this function using \helpref{wxDbTable::GetCursor}{wxdbtablegetcursor}
eea22fd5
GT
3700and saving a pointer to that cursor.
3701
3702\wxheading{See also}
3703
107ffdc1
RD
3704\helpref{wxDbTable::GetNewCursor}{wxdbtablegetnewcursor},
3705\helpref{wxDbTable::GetCursor}{wxdbtablegetcursor},
eea22fd5
GT
3706\helpref{wxDbTable::SetCursor}{wxdbtablesetcursor}
3707
d0c6b305
GT
3708\membersection{wxDbTable::SetFromClause}\label{wxdbtablesetfromclause}
3709
7af3ca16 3710\func{void}{SetFromClause}{\param{const wxString \&}{From}}
eea22fd5 3711
107ffdc1 3712Accessor function for setting the private class member wxDbTable::from
90e7e277 3713that indicates what other tables should be inner joined with the wxDbTable's
107ffdc1 3714base table for access to the columns in those other tables.
eea22fd5
GT
3715
3716Synonym to this function is one form of \helpref{wxDbTable::From}{wxdbtablefrom}
d0c6b305
GT
3717
3718\wxheading{Parameters}
3719
90e7e277 3720\docparam{From}{A comma separated list of table names that are to be inner
107ffdc1
RD
3721joined with the base table's columns so that the joined table's columns
3722may be returned in the result set or used as a portion of a comparison with
3723the base table's columns. NOTE that the base tables name must NOT be included
3724in the FROM clause, as it is automatically included by the wxDbTable class
eea22fd5
GT
3725in constructing query statements.}
3726
3727\wxheading{Remarks}
3728
107ffdc1 3729Used by the \helpref{wxDbTable::Query}{wxdbtablequery} and
90e7e277 3730\helpref{wxDbTable::Count}{wxdbtablecount} member functions to allow inner
107ffdc1 3731joining of records from multiple tables.
eea22fd5
GT
3732
3733Do {\bf not} include the keyword "FROM" when setting the FROM clause.
3734
107ffdc1
RD
3735If using the FROM clause when performing a query, be certain to include in
3736the corresponding WHERE clause a comparison of a column from either the base
3737table or one of the other joined tables to each other joined table to ensure
eea22fd5
GT
3738the datasource knows on which column values the tables should be joined on.
3739
3740\wxheading{Example}
3741
3742\begin{verbatim}
3743 ...
3744 // Base table is the "LOCATION" table, and it is being
90e7e277 3745 // inner joined to the "PART" table via the field "PART_NUMBER"
eea22fd5
GT
3746 // that can be related between the two tables.
3747 location->SetWhereClause("LOCATION.PART_NUMBER = PART.PART_NUMBER")
3748 location->SetFromClause("PART");
3749 ...
3750\end{verbatim}
3751
3752\wxheading{See also}
3753
107ffdc1 3754\helpref{wxDbTable::From}{wxdbtablefrom},
59990c22 3755\helpref{wxDbTable::GetFromClause}{wxdbtablegetfromclause}
eea22fd5 3756
59990c22 3757\membersection{wxDbTable::SetColNull}\label{wxdbtablesetcolnull}
d0c6b305 3758
998abc15 3759\func{bool}{SetColNull}{\param{UWORD }{colNumber}, \param{bool }{set=true}}
d0c6b305 3760
107ffdc1 3761\func{bool}{SetColNull}{\param{const wxString \&}{colName},
cc81d32f 3762\param{bool }{set=true}}
d0c6b305 3763
107ffdc1 3764Both forms of this function allow a member variable representing a column
eea22fd5
GT
3765in the table associated with this wxDbTable object to be set to NULL.
3766
107ffdc1
RD
3767The first form allows the column to be set by the index into the column
3768definitions used to create the wxDbTable instance, while the second allows
eea22fd5
GT
3769the actual column name to be specified.
3770
d0c6b305
GT
3771\wxheading{Parameters}
3772
998abc15 3773\docparam{colNumber}{Index into the column definitions used when first defining
eea22fd5
GT
3774this wxDbTable object.}
3775\docparam{colName}{Actual data table column name that is to be set to NULL.}
cc81d32f
VS
3776\docparam{set}{Whether the column is set to NULL or not. Passing true sets
3777the column to NULL, passing false sets the column to be non-NULL. Default is
3778true.}
59990c22 3779
d0c6b305
GT
3780\wxheading{Remarks}
3781
107ffdc1
RD
3782No database updates are done by this function. It only operates on the
3783member variables in memory. Use and insert or update function to store this
eea22fd5
GT
3784value to disk.
3785
d0c6b305
GT
3786\membersection{wxDbTable::SetOrderByClause}\label{wxdbtablesetorderbyclause}
3787
7af3ca16 3788\func{void}{SetOrderByClause}{\param{const wxString \&}{OrderBy}}
eea22fd5 3789
107ffdc1
RD
3790Accessor function for setting the private class member wxDbTable::orderBy
3791which determines sequence/ordering of the rows returned in the result set
eea22fd5
GT
3792of a query.
3793
59990c22 3794A synonym to this function is one form of the function \helpref{wxDbTable::OrderBy}{wxdbtableorderby}
d0c6b305
GT
3795
3796\wxheading{Parameters}
3797
107ffdc1
RD
3798\docparam{OrderBy}{A comma separated list of column names that indicate the
3799alphabetized sorting sequence that the result set is to be returned in. If
3800a FROM clause has also been specified, each column name specified in the
3801ORDER BY clause should be prefaced with the table name to which the column
e7240349 3802belongs using DOT notation (TABLE\_NAME.COLUMN\_NAME).}
eea22fd5
GT
3803
3804\wxheading{Remarks}
3805
3806Do {\bf not} include the keywords "ORDER BY" when setting the ORDER BY clause.
3807
3808\wxheading{Example}
3809
3810\begin{verbatim}
3811 ...
3812 parts->SetOrderByClause("PART_DESCRIP, QUANTITY");
3813 ...
3814
3815 ...
3816 location->SetOrderByClause("LOCATION.POSITION, PART.PART_NUMBER);
3817 ...
3818\end{verbatim}
3819
3820\wxheading{See also}
3821
107ffdc1 3822\helpref{wxDbTable::OrderBy}{wxdbtableorderby},
59990c22 3823\helpref{wxDbTable::GetOrderByClause}{wxdbtablegetorderbyclause}
eea22fd5 3824
d0c6b305
GT
3825\membersection{wxDbTable::SetQueryTimeout}\label{wxdbtablesetquerytimeout}
3826
3827\func{bool}{SetQueryTimeout}{\param{UDWORD }{nSeconds}}
3828
eea22fd5
GT
3829Allows a time period to be set as the timeout period for queries.
3830
d0c6b305
GT
3831\wxheading{Parameters}
3832
107ffdc1 3833\docparam{nSeconds}{The number of seconds to wait for the query to complete
eea22fd5 3834before timing out.}
d0c6b305
GT
3835
3836\wxheading{Remarks}
3837
107ffdc1
RD
3838Neither Oracle or Access support this function as of yet. Other databases
3839should be evaluated for support before depending on this function working
eea22fd5
GT
3840correctly.
3841
d0c6b305
GT
3842\membersection{wxDbTable::SetWhereClause}\label{wxdbtablesetwhereclause}
3843
7af3ca16 3844\func{void}{SetWhereClause}{\param{const wxString \&}{Where}}
eea22fd5 3845
107ffdc1 3846Accessor function for setting the private class member wxDbTable::where
eea22fd5
GT
3847that determines which rows are returned in the result set by the datasource.
3848
59990c22 3849A synonym to this function is one form of the function \helpref{wxDbTable::Where}{wxdbtablewhere}
d0c6b305
GT
3850
3851\wxheading{Parameters}
3852
107ffdc1
RD
3853\docparam{Where}{SQL "where" clause. This clause can contain any SQL language
3854that is legal in standard where clauses. If a FROM clause has also been
3855specified, each column name specified in the ORDER BY clause should be
3856prefaced with the table name to which the column belongs using DOT notation
e7240349 3857(TABLE\_NAME.COLUMN\_NAME).}
eea22fd5
GT
3858
3859\wxheading{Remarks}
3860
3861Do {\bf not} include the keywords "WHERE" when setting the WHERE clause.
3862
3863\wxheading{Example}
3864
3865\begin{verbatim}
3866 ...
3867 // Simple where clause
3868 parts->SetWhereClause("PART_NUMBER = '32'");
3869 ...
3870 // Any comparison operators
3871 parts->SetWhereClause("PART_DESCRIP LIKE 'HAMMER%'");
3872 ...
3873 // Multiple comparisons, including a function call
3874 parts->Where("QTY > 0 AND {fn UCASE(PART_DESCRIP)} LIKE '%DRILL%'");
3875 ...
3876 // Using parameters and multiple logical combinations
3877 parts->Where("((QTY > 10) OR (ON_ORDER > 0)) AND ON_HOLD = 0");
3878 ...
90e7e277 3879 // This query uses an inner join (requiring a FROM clause also)
eea22fd5
GT
3880 // that joins the PART and LOCATION table on he common field
3881 // PART_NUMBER.
3882 parts->Where("PART.ON_HOLD = 0 AND \
3883 PART.PART_NUMBER = LOCATION.PART_NUMBER AND \
3884 LOCATION.PART_NUMBER > 0");
3885\end{verbatim}
3886
59990c22
GT
3887\wxheading{See also}
3888
107ffdc1 3889\helpref{wxDbTable::Where}{wxdbtablewhere},
59990c22
GT
3890\helpref{wxDbTable::GetWhereClause}{wxdbtablegetwhereclause}
3891
d0c6b305
GT
3892\membersection{wxDbTable::Update}\label{wxdbtableupdate}
3893
9fe17bd3 3894\func{bool }{Update}{\void}
d0c6b305 3895
7af3ca16 3896\func{bool }{Update}{\param{const wxString \&}{pSqlStmt}}
d0c6b305 3897
107ffdc1
RD
3898The first form of this function will update the row that the current cursor
3899is currently positioned at with the values in the memory variables that
3900are bound to the columns. The actual SQL statement to perform the update
eea22fd5
GT
3901is automatically created by the ODBC class, and then executed.
3902
107ffdc1
RD
3903The second form of the function allows full access through SQL statements for
3904updating records in the database. Write any valid SQL UPDATE statement and
3905submit it to this function for execution. Sophisticated updates can be
3906performed using the full power of the SQL dialect. The full SQL statement
3907must have the exact syntax required by the driver/datasource for performing
eea22fd5
GT
3908the update. This usually is in the form of:
3909
3910\begin{verbatim}
3911 UPDATE tablename SET col1=X, col2=Y, ... where ...
3912\end{verbatim}
3913
d0c6b305
GT
3914\wxheading{Parameters}
3915
eea22fd5 3916\docparam{pSqlStmt}{Pointer to SQL UPDATE statement to be executed.}
d0c6b305
GT
3917
3918\wxheading{Remarks}
3919
107ffdc1
RD
3920A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
3921\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
eea22fd5
GT
3922this function to commit or rollback the update.
3923
3924\wxheading{Example}
3925
3926\begin{verbatim}
9fe17bd3
GT
3927 wxString sqlStmt;
3928 sqlStmt = "update PART set QTY = 0 where PART_NUMBER = '32'";
eea22fd5
GT
3929\end{verbatim}
3930
d0c6b305
GT
3931\membersection{wxDbTable::UpdateWhere}\label{wxdbtableupdatewhere}
3932
7af3ca16 3933\func{bool}{UpdateWhere}{\param{const wxString \&}{pWhereClause}}
d0c6b305 3934
107ffdc1 3935Performs updates to the base table of the wxDbTable object, updating only the
eea22fd5
GT
3936rows which match the criteria specified in the {\it pWhereClause}.
3937
107ffdc1 3938All columns that are bound to member variables for this wxDbTable instance
cc81d32f 3939that were defined with the "updateable" parameter set to true will be updated
107ffdc1 3940with the information currently held in the memory variable.
eea22fd5 3941
d0c6b305
GT
3942\wxheading{Parameters}
3943
107ffdc1 3944\docparam{pWhereClause}{Pointer to a valid SQL WHERE clause. Do not
eea22fd5 3945include the keyword 'WHERE'.}
d0c6b305
GT
3946
3947\wxheading{Remarks}
3948
107ffdc1 3949Care should be used when updating columns that are part of indexes with
eea22fd5
GT
3950this function so as not to violate an unique key constraints.
3951
107ffdc1
RD
3952A \helpref{wxDb::CommitTrans}{wxdbcommittrans} or
3953\helpref{wxDb::RollbackTrans}{wxdbrollbacktrans} must be called after use of
eea22fd5
GT
3954this function to commit or rollback the update(s).
3955
59990c22
GT
3956\membersection{wxDbTable::Where}\label{wxdbtablewhere}
3957
7af3ca16 3958\func{const wxString \&}{Where}{}
59990c22 3959
7af3ca16 3960\func{void}{Where}{\param{const wxString\& }{Where}}
59990c22 3961
107ffdc1
RD
3962Accessor function for the private class member wxDbTable::where. Can be used
3963as a synonym for \helpref{wxDbTable::GetWhereClause}{wxdbtablegetwhereclause}
3964(the first form of this function) to return the current where clause or
3965\helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause} (the second form
59990c22
GT
3966of this function) to set the where clause for this table instance.
3967
3968\wxheading{Parameters}
3969
3970\docparam{Where}{A valid SQL WHERE clause. Do not include the keyword 'WHERE'.}
3971
3972\wxheading{Return value}
3973
107ffdc1
RD
3974The first form of this function returns the current value of the wxDbTable
3975member variable ::where.
59990c22 3976
107ffdc1
RD
3977The second form of the function has no return value, as it will always set
3978the where clause successfully.
59990c22
GT
3979
3980\wxheading{See also}
3981
107ffdc1 3982\helpref{wxDbTable::GetWhereClause}{wxdbtablegetwhereclause},
59990c22
GT
3983\helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
3984
d0c6b305
GT
3985\membersection{wxDbTable::operator $++$}\label{wxdbtableplusplus}
3986
3987\func{bool}{operator $++$}{\void}
3988
eea22fd5 3989Synonym for \helpref{wxDbTable::GetNext}{wxdbtablegetnext}
d0c6b305
GT
3990
3991\wxheading{See also}
3992
3993\helpref{wxDbTable::GetNext}{wxdbtablegetnext}
3994
3995\membersection{wxDbTable::operator $--$}\label{wxdbtableminusminus}
3996
3997\func{bool}{operator $--$}{\void}
3998
eea22fd5 3999Synonym for \helpref{wxDbTable::GetPrev}{wxdbtablegetprev}
d0c6b305
GT
4000
4001\wxheading{See also}
4002
4003\helpref{wxDbTable::GetPrev}{wxdbtablegetprev}
4004
4005\section{\class{wxDbTableInf}}\label{wxdbtableinf}
4006
59990c22
GT
4007\begin{verbatim}
4008 tableName[0] = 0;
4009 tableType[0] = 0;
4010 tableRemarks[0] = 0;
4011 numCols = 0;
4012 pColInf = NULL;
4013\end{verbatim}
4014
107ffdc1
RD
4015Currently only used by \helpref{wxDb::GetCatalog}{wxdbgetcatalog} internally
4016and \helpref{wxDbInf}{wxdbinf} class, but may be used in future releases for
4017user functions. Contains information describing the table (Name, type, etc).
4018A pointer to a wxDbColInf array instance is included so a program can create a
4019\helpref{wxDbColInf}{wxdbcolinf} array instance (using
4020\helpref{wxDb::GetColumns}{wxdbgetcolumns})
4021to maintain all information about the columns of a table in one memory
59990c22 4022structure.
3ca6a5f0 4023
19320af4
GT
4024Eventually, accessor functions will be added for this class
4025
2564094b
JS
4026See the \helpref{database classes overview}{odbcoverview} for
4027an introduction to using the ODBC classes.
4028
0e10e38d
VZ
4029\wxheading{Include files}
4030
4031<wx/db.h>
4032
4033\latexignore{\rtfignore{\wxheading{Members}}}
4034
19320af4
GT
4035\membersection{wxDbTableInf::Initialize}\label{wxdbtableinfinitialize}
4036
107ffdc1 4037Simply initializes all member variables to a cleared state. Called by
19320af4 4038the constructor automatically.
a98f98ac 4039
cdbecb39
RG
4040\section{\class{wxDbGridColInfo}}\label{wxdbgridcolinfo}
4041
4042This class is used to define columns to be shown, names of the columns,
4043order and type of data, when using \helpref{wxdbGridTableBase}{wxdbgridtablebase} to display
4044a Table or query in a \helpref{wxGrid}{wxgrid}
4045
4046See the database grid example in \helpref{wxDbGridTableBase}{wxdbgridtablebase} for
4047an introduction to using the wxDbGrid classes.
4048
4049\wxheading{Include files}
4050
4051<wx/dbgrid.h>
4052
4053\latexignore{\rtfignore{\wxheading{Members}}}
4054
684761db 4055\membersection{wxDbGridColInfo::wxDbGridColInfo}\label{wxdbgridcolinfoctor}
cdbecb39 4056
998abc15 4057\func{}{wxDbGridColInfo}{\param{int }{colNumber}, \param{wxString }{type},
cdbecb39
RG
4058 \param{wxString }{title}, \param{wxDbGridColInfo *}{next}}
4059
4060Default constructor. See the database grid example in \helpref{wxDbGridTableBase}{wxdbgridtablebase} to
4061see two different ways for adding columns.
4062
4063
4064\wxheading{Parameters}
4065
998abc15 4066\docparam{colNumber}{Column number in the \helpref{wxDbTable}{wxdbtable} instance to be used (first column is 0).}
cdbecb39 4067\docparam{type}{Column type ,wxString specifying the grid name for the datatype in this column, or
1d390a62 4068 use wxGRID\_VALUE\_DBAUTO to determine the type automatically from the \helpref{wxDbColDef}{wxdbcoldef} definition}
cdbecb39
RG
4069\docparam{title}{The column label to be used in the grid display}
4070\docparam{next}{A pointer to the next wxDbGridColInfo structure if using one-step
4071construction, NULL terminates the list. Use Null also if using two step construction.}
4072See the database grid example in \helpref{wxDbGridTableBase}{wxdbgridtablebase} to
4073see two different ways for adding columns.
4074
b236c10f 4075\membersection{wxDbGridColInfo::\destruct{wxDbGridColInfo}}\label{wxdbgridcolinfodtor}
cdbecb39
RG
4076
4077\func{}{\destruct{wxDbGridColInfo}}{}
4078
4079Destructor.
4080
4081\membersection{wxDbGridColInfo::AddColInfo}\label{wxdbgridcolinfoaddcolinfo}
4082
998abc15 4083\func{void}{AddColInfo}{\param{int }{colNumber},
cdbecb39
RG
4084\param{wxString }{type}, \param{wxString }{title}}
4085
4086Use this member function for adding columns. See the database
4087grid example in \helpref{wxDbGridTableBase}{wxdbgridtablebase} to
4088see two different ways for adding columns.
4089
4090It is important to note that this class is merely a specifier to the \helpref{wxDbGridTableBase}{wxdbgridtablebase}
4091constructor. Changes made to this datatype after the \helpref{wxDbGridTableBase}{wxdbgridtablebase} is called will
4092not have any effect.
4093
4094\wxheading{Parameters}
998abc15 4095\docparam{colNumber}{Column number in the \helpref{wxDbTable}{wxdbtable} instance to be used (first column is 0).}
cdbecb39 4096\docparam{type}{Column type ,wxString specifying the grid name for the datatype in this column, or
1d390a62 4097 use wxGRID\_VALUE\_DBAUTO to determine the type automatically from the \helpref{wxDbColDef}{wxdbcoldef} definition}
cdbecb39
RG
4098\docparam{title}{The column label to be used in the grid display}
4099
4100\wxheading{Remarks}
4101
4102As wxDbTable must be defined with to have columns which match those to by a wxDbGridColInfo
4103info structure as this is the structure which informs the grid of how you want to display your
4104\helpref{wxDbTable}{wxdbtable}. If no datatype conversion or the referenced column number does not exist the
4105the behavior is undefined.
4106
684761db 4107See the example at \helpref{wxDbGridColInfo::wxDbGridColInfo}{wxdbgridcolinfoctor}.
cdbecb39
RG
4108
4109\section{\class{wxDbGridTableBase}}\label{wxdbgridtablebase}
4110
4111You can view a database table in a grid using this class.
4112
4113If you are deriving your own wxDbTable subclass for your table , then you may consider
4114overriding GetCol() and SetCol() to provide calculated fields. This does work but care should
4115be taken when using wxDbGridTableBase in this way.
4116
4117The constructor and AssignDbTable() call allows you to specify the ownership if the wxDbTable
4118object pointer. If you tell wxGridTableBase to take ownership , it will delete the passed wxDbTable
4119when an new on is assigned or wxGridTableBase's destructor is called.
4120However no checks for aliasing are done so Assign(table,..,true); Assign(table,..,true);
4121is an error. If you need to requery an table object the preferred way is
4122that the client keeps ownership.
4123
4124\wxheading{Derived From}
4125
4126\helpref{wxGridTableBase}{wxgridtablebase}
4127
4128\wxheading{Include files}
4129
4130<wx/dbgrid.h>
4131
4132
4133\wxheading{Example}
4134
4135\begin{verbatim}
4136 // First step, let's define wxDbTable
4137 int numColumns = 2;
4138 wxDbTable *table = new wxDbTable (db, tblName, numColumns);
4139 int int_var;
4140 wxChar string_name[255];
4141 table->SetColDef (0, "column 0", DB_DATA_TYPE_INTEGER, &int_var,
cc81d32f 4142 SQL_C_LONG, sizeof(int_var), true);
cdbecb39 4143 table->SetColDef (1, "column 1", DB_DATA_TYPE_VARCHAR, &string_name,
cc81d32f 4144 SQL_C_LONG, sizeof(string_name), false);
cdbecb39
RG
4145
4146 // now let's define columns in the grid
4147
4148 // first way to do it
4149 wxDbGridColInfo *columns;
4150 columns = new wxDbGridColInfo(0, wxGRID_VALUE_LONG, "first column",
4151 new wxDbGridColInfo(1, wxGRID_VALUE_STRING, "second column",
4152 NULL);
4153
4154 // second way to do it
4155 wxDbGridColInfo *columns;
4156 // first column is special
4157 columns = new wxDbGridColInfo(0, wxGRID_VALUE_LONG, "first column", NULL);
4158 // all the rest
4159 columns->AddColInfo (1, wxGRID_VALUE_STRING, "second column");
4160
4161 // second way may be better when columns are not known at compile time
4162
4163 // now, let's open the table and make a Query()
4164 table->Open();
4165 // this step is very important
4166 table->SetRowMode (wxDbTable::WX_ROW_MODE_QUERY);
4167 // in the grid we will see only the rows of the result query
4168 m_dbTable->Query();
4169
cc81d32f 4170 wxDbGridTableBase *dbgrid = new wxDbGridTableBase(table, columns, wxUSE_QUERY, true);
cdbecb39
RG
4171 delete columns; // not needed anymore
4172 wxGrid *grid = new wxGrid ( ... );
cc81d32f 4173 grid->SetTable(dbgrid, true);
cdbecb39
RG
4174 grid->Fit();
4175\end{verbatim}
4176
4177
4178\wxheading{Include files}
4179
4180<wx/dbgrid.h>
4181
4182\wxheading{Helper classes and data structures}
4183
4184\membersection{wxDbGridTableBase::wxDbGridTableBase}\label{wxdbgridtablebaseconstr}
4185
4186\func{}{wxDbGridTableBase}{\param{wxDbTable *}{tab}, \param{wxDbGridColInfo *}{ColInfo},
cc81d32f 4187 \param{int }{count = wxUSE\_QUERY}, \param{bool }{takeOwnership = true}}
cdbecb39
RG
4188
4189Constructor.
4190
4191\wxheading{Parameters}
4192
4193\docparam{tab}{ The database table you want to display. Must be opened and queried before display the grid.
4194See the example \helpref{above}{wxdbgridtablebase}.}
4195\docparam{ColInfo}{ Columns titles, and other values. See \helpref{wxDbGridColInfo}{wxdbgridcolinfo}.}
1d390a62 4196\docparam{count}{You can use a query result set (wxUSE\_QUERY, to use wxDbTable::Count(wxDbTable::Count()
cdbecb39
RG
4197 or you can fix the total number of rows (count >= 0) to display, or specify it if you already know the size in avoid calling }
4198
cc81d32f
VS
4199\docparam{takeOwnership}{ If true, this class deletes wxDbTable when it stops
4200referring to it, if false application must
cdbecb39
RG
4201take care of deleting it. }
4202
4203\membersection{wxDbGridTableBase::ValidateRow}\label{wxdbgridtablebasevalidate}
4204
4205\func{void}{ValidateRow}{\param{int }{row}}
4206
4207It ensures that the row data is fetched from the database, and it the wxDbTable local buffer,
4208the row number passed should be the grid row.
4209
4210\wxheading{Parameters}
4211
4212\docparam{row}{ Row where validation must be done. }
4213
4214\membersection{wxDbGridTableBase::UpdateRow}\label{wxdbgridtablebaseupdaterow}
4215
4216\func{bool}{UpdateRow}{\param{int }{row}}
4217
4218If row has changed it forces that row to be written back to the database, however support
4219for detecting whether insert/update is required is currently not in wxDbTable, so this
4220function is currently unsupported.
4221
4222\wxheading{Parameters}
4223
4224\docparam{row}{ Row you want to update. }
4225
4226\membersection{wxDbGridTableBase::AssignDbTable}\label{wxdbgridtablebaseassigndbtable}
4227
1d390a62 4228\func{bool}{AssignDbTable}{\param{wxDbTable *}{tab},\param{int }{count = wxUSE\_QUERY},
cc81d32f 4229\param{bool }{takeOwnership = true}}
cdbecb39
RG
4230
4231Resets the grid for using with a new database table, but using the same columns definition.
4232This can be useful when re-querying the database and want to see the changes.
4233
4234\wxheading{Parameters}
4235
4236\docparam{tab}{ Database table you want to assign to the grid. }
1d390a62 4237\docparam{count}{ Number of rows you want to show or wxUSE\_QUERY for using a query. }
cc81d32f
VS
4238\docparam{takeOwnership}{ If false, user must take care of deleting tab after deleting
4239the wxDbGridTableBase. If true, deletion is made by destructor class. }
cdbecb39 4240