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