wxWidgets/docs/latex/wx/db.tex
2000-08-14 11:44:26 +00:00

1678 lines
61 KiB
TeX

\section{\class{wxDb}}\label{wxdb}
A wxDb instance is a connection to an ODBC data source which may
be opened, closed, and re-opened an unlimited number of times. A
database connection allows function to be performed directly on the
data source, as well as allowing access to any tables/views defined in
the data source to which the user has sufficient privileges.
\wxheading{Include files}
<wx/db.h>
\wxheading{Helper classes and data structures}
The following classes and structs are defined in db.cpp/.h for use with the wxDb class.
\begin{itemize}\itemsep=0pt
\item \helpref{wxDbColFor}{wxdbcolfor}
\item \helpref{wxDbColInf}{wxdbcolinf}
\item \helpref{wxDbTableInf}{wxdbtableinf}
\item \helpref{wxDbInf}{wxdbinf}
\end{itemize}
\wxheading{Constants}
NOTE: In a future release, all ODBC class constants will be prefaced with 'wx'
\begin{verbatim}
wxDB_PATH_MAX Maximum path length allowed to be passed to the ODBC
driver to indicate where the data file is located.
DB_MAX_COLUMN_NAME_LEN Maximum supported length for the name of a column
DB_MAX_ERROR_HISTORY Maximum number of error messages retained in the
queue before being overwritten by new errors.
DB_MAX_ERROR_MSG_LEN Maximum supported length of an error message returned
by the ODBC classes
DB_MAX_STATEMENT_LEN Maximum supported length for a complete SQL statement
to be passed to the ODBC driver
DB_MAX_TABLE_NAME_LEN Maximum supported length for the name of a table
DB_MAX_WHERE_CLAUSE_LEN Maximum supported WHERE clause length that can be
passed to the ODBC driver
DB_TYPE_NAME_LEN Maximum length of the name of a column's data type
\end{verbatim}
\wxheading{Enumerated types}
\docparam{enum {\bf wxDbSqlLogState}}{sqlLogOFF, sqlLogON}
{\it enum {\bf wxDBMS}}
These are the databases currently tested and working with the ODBC classes. A call to \helpref{wxDb::Dbms}{wxdbdbms} will return one of these enumerated values listed below.
\begin{verbatim}
dbmsUNIDENTIFIED,
dbmsORACLE,
dbmsSYBASE_ASA, // Adaptive Server Anywhere
dbmsSYBASE_ASE, // Adaptive Server Enterprise
dbmsMS_SQL_SERVER,
dbmsMY_SQL,
dbmsPOSTGRES,
dbmsACCESS,
dbmsDBASE,
dbmsINFORMIX
\end{verbatim}
See the remarks in \helpref{wxDb::Dbms}{wxdbdbms} for exceptions/issues with each of these database engines.
\wxheading{Public member variables}
\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.}
\docparam{int {\bf wxDb::DB\_STATUS}}{The last ODBC error that occurred on this data connection. Possible codes are:}
\begin{verbatim}
DB_ERR_GENERAL_WARNING // SqlState = '01000'
DB_ERR_DISCONNECT_ERROR // SqlState = '01002'
DB_ERR_DATA_TRUNCATED // SqlState = '01004'
DB_ERR_PRIV_NOT_REVOKED // SqlState = '01006'
DB_ERR_INVALID_CONN_STR_ATTR // SqlState = '01S00'
DB_ERR_ERROR_IN_ROW // SqlState = '01S01'
DB_ERR_OPTION_VALUE_CHANGED // SqlState = '01S02'
DB_ERR_NO_ROWS_UPD_OR_DEL // SqlState = '01S03'
DB_ERR_MULTI_ROWS_UPD_OR_DEL // SqlState = '01S04'
DB_ERR_WRONG_NO_OF_PARAMS // SqlState = '07001'
DB_ERR_DATA_TYPE_ATTR_VIOL // SqlState = '07006'
DB_ERR_UNABLE_TO_CONNECT // SqlState = '08001'
DB_ERR_CONNECTION_IN_USE // SqlState = '08002'
DB_ERR_CONNECTION_NOT_OPEN // SqlState = '08003'
DB_ERR_REJECTED_CONNECTION // SqlState = '08004'
DB_ERR_CONN_FAIL_IN_TRANS // SqlState = '08007'
DB_ERR_COMM_LINK_FAILURE // SqlState = '08S01'
DB_ERR_INSERT_VALUE_LIST_MISMATCH // SqlState = '21S01'
DB_ERR_DERIVED_TABLE_MISMATCH // SqlState = '21S02'
DB_ERR_STRING_RIGHT_TRUNC // SqlState = '22001'
DB_ERR_NUMERIC_VALUE_OUT_OF_RNG // SqlState = '22003'
DB_ERR_ERROR_IN_ASSIGNMENT // SqlState = '22005'
DB_ERR_DATETIME_FLD_OVERFLOW // SqlState = '22008'
DB_ERR_DIVIDE_BY_ZERO // SqlState = '22012'
DB_ERR_STR_DATA_LENGTH_MISMATCH // SqlState = '22026'
DB_ERR_INTEGRITY_CONSTRAINT_VIOL // SqlState = '23000'
DB_ERR_INVALID_CURSOR_STATE // SqlState = '24000'
DB_ERR_INVALID_TRANS_STATE // SqlState = '25000'
DB_ERR_INVALID_AUTH_SPEC // SqlState = '28000'
DB_ERR_INVALID_CURSOR_NAME // SqlState = '34000'
DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL // SqlState = '37000'
DB_ERR_DUPLICATE_CURSOR_NAME // SqlState = '3C000'
DB_ERR_SERIALIZATION_FAILURE // SqlState = '40001'
DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL2 // SqlState = '42000'
DB_ERR_OPERATION_ABORTED // SqlState = '70100'
DB_ERR_UNSUPPORTED_FUNCTION // SqlState = 'IM001'
DB_ERR_NO_DATA_SOURCE // SqlState = 'IM002'
DB_ERR_DRIVER_LOAD_ERROR // SqlState = 'IM003'
DB_ERR_SQLALLOCENV_FAILED // SqlState = 'IM004'
DB_ERR_SQLALLOCCONNECT_FAILED // SqlState = 'IM005'
DB_ERR_SQLSETCONNECTOPTION_FAILED // SqlState = 'IM006'
DB_ERR_NO_DATA_SOURCE_DLG_PROHIB // SqlState = 'IM007'
DB_ERR_DIALOG_FAILED // SqlState = 'IM008'
DB_ERR_UNABLE_TO_LOAD_TRANSLATION_DLL // SqlState = 'IM009'
DB_ERR_DATA_SOURCE_NAME_TOO_LONG // SqlState = 'IM010'
DB_ERR_DRIVER_NAME_TOO_LONG // SqlState = 'IM011'
DB_ERR_DRIVER_KEYWORD_SYNTAX_ERROR // SqlState = 'IM012'
DB_ERR_TRACE_FILE_ERROR // SqlState = 'IM013'
DB_ERR_TABLE_OR_VIEW_ALREADY_EXISTS // SqlState = 'S0001'
DB_ERR_TABLE_NOT_FOUND // SqlState = 'S0002'
DB_ERR_INDEX_ALREADY_EXISTS // SqlState = 'S0011'
DB_ERR_INDEX_NOT_FOUND // SqlState = 'S0012'
DB_ERR_COLUMN_ALREADY_EXISTS // SqlState = 'S0021'
DB_ERR_COLUMN_NOT_FOUND // SqlState = 'S0022'
DB_ERR_NO_DEFAULT_FOR_COLUMN // SqlState = 'S0023'
DB_ERR_GENERAL_ERROR // SqlState = 'S1000'
DB_ERR_MEMORY_ALLOCATION_FAILURE // SqlState = 'S1001'
DB_ERR_INVALID_COLUMN_NUMBER // SqlState = 'S1002'
DB_ERR_PROGRAM_TYPE_OUT_OF_RANGE // SqlState = 'S1003'
DB_ERR_SQL_DATA_TYPE_OUT_OF_RANGE // SqlState = 'S1004'
DB_ERR_OPERATION_CANCELLED // SqlState = 'S1008'
DB_ERR_INVALID_ARGUMENT_VALUE // SqlState = 'S1009'
DB_ERR_FUNCTION_SEQUENCE_ERROR // SqlState = 'S1010'
DB_ERR_OPERATION_INVALID_AT_THIS_TIME // SqlState = 'S1011'
DB_ERR_INVALID_TRANS_OPERATION_CODE // SqlState = 'S1012'
DB_ERR_NO_CURSOR_NAME_AVAIL // SqlState = 'S1015'
DB_ERR_INVALID_STR_OR_BUF_LEN // SqlState = 'S1090'
DB_ERR_DESCRIPTOR_TYPE_OUT_OF_RANGE // SqlState = 'S1091'
DB_ERR_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1092'
DB_ERR_INVALID_PARAM_NO // SqlState = 'S1093'
DB_ERR_INVALID_SCALE_VALUE // SqlState = 'S1094'
DB_ERR_FUNCTION_TYPE_OUT_OF_RANGE // SqlState = 'S1095'
DB_ERR_INF_TYPE_OUT_OF_RANGE // SqlState = 'S1096'
DB_ERR_COLUMN_TYPE_OUT_OF_RANGE // SqlState = 'S1097'
DB_ERR_SCOPE_TYPE_OUT_OF_RANGE // SqlState = 'S1098'
DB_ERR_NULLABLE_TYPE_OUT_OF_RANGE // SqlState = 'S1099'
DB_ERR_UNIQUENESS_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1100'
DB_ERR_ACCURACY_OPTION_TYPE_OUT_OF_RANGE // SqlState = 'S1101'
DB_ERR_DIRECTION_OPTION_OUT_OF_RANGE // SqlState = 'S1103'
DB_ERR_INVALID_PRECISION_VALUE // SqlState = 'S1104'
DB_ERR_INVALID_PARAM_TYPE // SqlState = 'S1105'
DB_ERR_FETCH_TYPE_OUT_OF_RANGE // SqlState = 'S1106'
DB_ERR_ROW_VALUE_OUT_OF_RANGE // SqlState = 'S1107'
DB_ERR_CONCURRENCY_OPTION_OUT_OF_RANGE // SqlState = 'S1108'
DB_ERR_INVALID_CURSOR_POSITION // SqlState = 'S1109'
DB_ERR_INVALID_DRIVER_COMPLETION // SqlState = 'S1110'
DB_ERR_INVALID_BOOKMARK_VALUE // SqlState = 'S1111'
DB_ERR_DRIVER_NOT_CAPABLE // SqlState = 'S1C00'
DB_ERR_TIMEOUT_EXPIRED // SqlState = 'S1T00'
\end{verbatim}
\docparam{struct {\bf wxDb::dbInf}}{This structure is internal to the wxDb class and contains details of the ODBC datasource that the current instance of the wxDb is connected to in its members. When the data source is opened, all of the information contained in the dbInf structure is queried from the data source. This information is used almost exclusively within the ODBC class library. Where there is a need for this information outside of the class library a member function such as wxDbTable::IsCursorClosedOnCommit() has been added for ease of use.}
\begin{verbatim}
char dbmsName[40] - Name of the dbms product
char dbmsVer[64] - Version # of the dbms product
char driverName[40] - Driver name
char odbcVer[60] - ODBC version of the driver
char drvMgrOdbcVer[60] - ODBC version of the driver manager
char driverVer[60] - Driver version
char serverName[80] - Server Name, typically a connect string
char databaseName[128] - Database filename
char outerJoins[2] - Does datasource support outer joins
char procedureSupport[2] - Does datasource support stored procedures
UWORD maxConnections - Maximum # of connections datasource supports
UWORD maxStmts - Maximum # of HSTMTs per HDBC
UWORD apiConfLvl - ODBC API conformance level
UWORD cliConfLvl - Is datasource SAG compliant
UWORD sqlConfLvl - SQL conformance level
UWORD cursorCommitBehavior - How cursors are affected on db commit
UWORD cursorRollbackBehavior - How cursors are affected on db rollback
UWORD supportNotNullClause - Does datasource support NOT NULL clause
char supportIEF[2] - Integrity Enhancement Facility (Ref. Integrity)
UDWORD txnIsolation - Transaction isolation level supported by driver
UDWORD txnIsolationOptions - Transaction isolation level options available
UDWORD fetchDirections - Fetch directions supported
UDWORD lockTypes - Lock types supported in SQLSetPos
UDWORD posOperations - Position operations supported in SQLSetPos
UDWORD posStmts - Position statements supported
UDWORD scrollConcurrency - Scrollable cursor concurrency options supported
UDWORD scrollOptions - Scrollable cursor options supported
UDWORD staticSensitivity - Can additions/deletions/updates be detected
UWORD txnCapable - Indicates if datasource supports transactions
UDWORD loginTimeout - Number seconds to wait for a login request
\end{verbatim}
\docparam{char {\bf wxDb::errorList}[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN]}{The last n ODBC errors that have occurred on this database connection.}
\docparam{char {\bf wxDb::errorMsg}[SQL_MAX_MESSAGE_LENGTH]}{This member variable is populated as a result of calling \helpref{wxDb::GetNextError}{wxdbgetnexterror}. It contains the ODBC error message text.}
\docparam{SDWORD {\bf wxDb::nativeError}}{Set by wxDb::DispAllErrors, wxDb::GetNextError, and wxDb::DispNextError. It contains the datasource-specific error code returned by the datasource to the ODBC driver. Used for reporting ODBC errors.}
\docparam{wxChar {\bf wxDb::sqlState}[20]}{Set by wxDb::TranslateSqlState(). Indicates the error state after a failed ODBC operation. Used for reporting ODBC errors.}
\wxheading{Remarks}
Default cursor scrolling is defined by wxODBC_FWD_ONLY_CURSORS in setup.h
when the wxWindows library is built. This behavior can be overridden when
an instance of a wxDb is created (see \helpref{wxDb constructor}{wxdbconstr}).
\wxheading{See also}
\helpref{wxDbColFor}{wxdbcolfor}, \helpref{wxDbColInf}{wxdbcolinf}, \helpref{wxDbTable}{wxdbtable}, \helpref{wxDbTableInf}{wxdbtableinf}, \helpref{wxDbInf}{wxdbinf}
\subsection{Associated non-class functions}\label{wxdbfunctions}
The following functions are used in conjunction with the wxDb class.
\func{wxDb *}{wxDbGetConnection}{\param{wxDbConnectInf *}{pDbConfig}, \param{bool }{FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS}}
\func{bool}{wxDbFreeConnection}{\param{wxDb *}{pDb}}
\func{void}{wxDbCloseConnections}{\void}
\func{int}{wxDbConnectionsInUse}{\void}
\func{bool}{wxDbSqlLog}{\param{wxDbSqlLogState }{state}, \param{const wxChar *}{filename = SQL_LOG_FILENAME}}
\func{bool}{wxDbGetDataSource}{\param{HENV }{henv}, \param{char *}{Dsn}, \param{SWORD }{DsnMax}, \param{char *}{DsDesc}, \param{SWORD }{DsDescMax}, \param{UWORD }{direction = SQL_FETCH_NEXT}}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxDb::wxDb}\label{wxdbconstr}
\func{}{wxDb}{\void}
Default constructor.
\func{}{wxDb}{\param{HENV\& }{aHenv}, \param{bool }{FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS}}
Constructor, used to create an ODBC connection to a data source.
\wxheading{Parameters}
\docparam{aHenv}{Environment handle used for this connection.}
\docparam{FwdOnlyCursors}{Will cursors created for use with this datasource connection only allow forward scrolling cursors.}
\wxheading{Remarks}
This is the constructor for the wxDb class. The wxDb object must
be created and opened before any database activity can occur.
\wxheading{Example}
\begin{verbatim}
wxDbConnectInf ConnectInf;
....Set values for member variables of ConnectInf here
wxDb sampleDB(ConnectInf.Henv);
if (!sampleDB.Open(ConnectInf.Dsn, ConnectInf.Uid, ConnectInf.AuthStr))
{
// Error opening data source
}
\end{verbatim}
\membersection{wxDb::Catalog}\label{wxdbcatalog}
\func{bool}{Catalog}{\param{char *}{ userID}, \param{char *}{fileName = SQL_CATALOG_FILENAME}}
Allows a data "dictionary" of the data source to be created, dumping pertinent information about all data tables to which the user specified in userID has access.
\wxheading{Parameters}
\docparam{userID}{Database user name to use in accessing the database. All tables to which this user has rights will be evaluated in the catalog.}
\docparam{fileName}{OPTIONAL argument. Name of the text file to create and write the DB catalog to.}
\wxheading{Return value}
Returns TRUE if the catalog request was successful, of FALSE if there was some reason the catalog could not be generated
\wxheading{Example}
\begin{verbatim}
============== ============== ================ ========= =======
TABLE NAME COLUMN NAME DATA TYPE PRECISION LENGTH
============== ============== ================ ========= =======
EMPLOYEE RECID (0008)NUMBER 15 8
EMPLOYEE USER_ID (0012)VARCHAR2 13 13
EMPLOYEE FULL_NAME (0012)VARCHAR2 26 26
EMPLOYEE PASSWORD (0012)VARCHAR2 26 26
EMPLOYEE START_DATE (0011)DATE 19 16
\end{verbatim}
\membersection{wxDb::Close}\label{wxdbclose}
\func{void}{Close}{\void}
Closes the database connection.
\wxheading{Remarks}
At the end of your program, when you have finished all of your database work, you must close the ODBC connection to the data source. There are actually four steps involved in doing this as illustrated in the example.
Any wxDbTable instances which use this connection must be deleted before closing the database connection.
\wxheading{Example}
\begin{verbatim}
// Commit any open transactions on the data source
sampleDB.CommitTrans();
// Delete any remaining wxDbTable objects allocated with new
delete parts;
// Close the wxDb connection when finished with it
sampleDB.Close();
// Free Environment Handle that ODBC uses
if (SQLFreeEnv(Db.Henv) != SQL_SUCCESS)
{
// Error freeing environment handle
}
\end{verbatim}
\membersection{wxDb::CommitTrans}\label{wxdbcommittrans}
\func{bool}{CommitTrans}{\void}
Permanently "commits" changes (insertions/deletions/updates) to the database.
\wxheading{Return value}
Returns TRUE if the commit was successful, or FALSE if the commit failed.
\wxheading{Remarks}
Transactions begin implicitly as soon as you make a change to the database. At any time thereafter, you can save your work to the database ("Commit") or roll back all of your changes ("Rollback"). Calling this member function commits all open transactions on this ODBC connection.
\wxheading{Special Note : {\it Cursors} }
\normalbox{It is important to understand that different database/ODBC driver combinations handle
transactions differently. One thing in particular that you must pay attention to is
cursors, in regard to transactions. Cursors are what allow you to scroll through
records forward and backward and to manipulate records as you scroll through them.
When you issue a query, a cursor is created behind the scenes. The cursor keeps track
of the query and keeps track of the current record pointer. After you commit or
rollback a transaction, the cursor may be closed automatically. This means you must
requery the data source before you can perform any additional work against the wxDbTable
object. This is only necessary however if the data source closes the cursor after a
commit or rollback. Use the wxDbTable::IsCursorClosedOnCommit() member function to
determine the data source's transaction behavior. Note, it would be very inefficient
to just assume the data source closes the cursor and always requery. This could put
a significant, unnecessary load on data sources that leave the cursors open after a
transaction.}
\membersection{wxDb::CreateView}\label{wxdbcreateviews}
\func{bool}{CreateView}{\param{char *}{ viewName}, \param{char *}{ colList}, \param{char *}{pSqlStmt}}
Creates a SQL VIEW.
\wxheading{Parameters}
\docparam{viewName}{The name of the view. e.g. PARTS_V}
\docparam{colList}{{\it OPTIONAL} Pass in a comma delimited list of column names if you wish to explicitly name each column in the result set. If not desired, pass in an empty string.}
\docparam{pSqlStmt}{Pointer to the select statement portion of the CREATE VIEW statement. Must be a complete, valid SQL SELECT statement.}
\wxheading{Remarks}
A 'view' is a logical table that derives columns from one or more other tables or views. Once the view is created, it can be queried exactly like any other table in the database.
NOTE: Views are not available with all datasources. Oracle is one example of a datasouce which does support views.
\wxheading{Example}
\begin{verbatim}
// Incomplete code sample
db.CreateView("PARTS_SD1", "PN, PD, QTY",
"SELECT PART_NO, PART_DESC, QTY_ON_HAND * 1.1 FROM PARTS \
WHERE STORAGE_DEVICE = 1");
// PARTS_SD1 can now be queried just as if it were a data table.
// e.g. SELECT PN, PD, QTY FROM PARTS_SD1
\end{verbatim}
\membersection{wxDb::DispAllErrors}\label{wxdbdispallerrors}
\func{bool}{DispAllErrors}{\param{HENV}{ aHenv}, {\param}{HDBC}{ aHdbc = SQL_NULL_HDBC}, {\param}{HSTMT}{ aHstmt = SQL_NULL_HSTMT}}
Logs all database errors that occurred as a result of the last executed database command. This logging also includes debug logging when compiled in debug mode via \helpref{wxLogDebug}{wxlogdebug}. If logging is turned on via \helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging}, then an entry is also logged to the defined log file.
\wxheading{Parameters}
\docparam{aHenv}{A handle to the ODBC environment.}
\docparam{aHdbc}{A handle to the ODBC connection. Pass this in if the ODBC function call that erred out required a hdbc or hstmt argument.}
\docparam{AHstmt}{A handle to the ODBC statement being executed against. Pass this in if the ODBC function call that erred out required a hstmt argument.}
\wxheading{Remarks}
This member function will display all of the ODBC error messages for the last ODBC function call that was made. Normally used internally within the ODBC class library. Would be used externally if calling ODBC functions directly (i.e. SQLFreeEnv()).
\wxheading{See also}
\helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging}, wxDbSqlLog
\wxheading{Example}
\begin{verbatim}
if (SQLExecDirect(hstmt, (UCHAR FAR *) pSqlStmt, SQL_NTS) != SQL_SUCCESS)
// Display all ODBC errors for this stmt
return(db.DispAllErrors(db.henv, db.hdbc, hstmt));
\end{verbatim}
\membersection{wxDb::DispNextError}\label{wxdbdispnexterror}
\func{void}{DispNextError}{\void}
\wxheading{Remarks}
This function is normally used internally within the ODBC class library.
It could be used externally if calling ODBC functions directly. This
function works in conjunction with \helpref{wxDb::GetNextError}{wxdbgetnexterror} when errors (or
sometimes informational messages) returned from ODBC need to be analyzed
rather than simply displaying them as an error. GetNextError() retrieves
the next ODBC error from the ODBC error queue. The wxDb member variables
"sqlState", "nativeError" and "errorMsg" could then be evaluated. To
display the error retrieved, DispNextError() could then be called.
The combination of GetNextError() and DispNextError() can be used to
iteratively step through the errors returned from ODBC evaluating each
one in context and displaying the ones you choose.
\wxheading{Example}
\begin{verbatim}
// Drop the table before attempting to create it
sprintf(sqlStmt, "DROP TABLE %s", tableName);
// Execute the drop table statement
if (SQLExecDirect(hstmt,(UCHAR FAR *)sqlStmt,SQL_NTS) != SQL_SUCCESS)
{
// Check for sqlState = S0002, "Table or view not found".
// Ignore this error, bomb out on any other error.
pDb->GetNextError(henv, hdbc, hstmt);
if (strcmp(pDb->sqlState, "S0002"))
{
pDb->DispNextError(); // Displayed error retrieved
pDb->DispAllErrors(henv, hdbc, hstmt); // Display all other errors, if any
pDb->RollbackTrans(); // Rollback the transaction
CloseCursor(); // Close the cursor
return(FALSE); // Return Failure
}
}
\end{verbatim}
\membersection{wxDb::DropView}\label{wxdbdropview}
\func{bool}{DropView}{\param{const char *}{viewName}}
Drops the data table view named in 'viewName'.
\wxheading{Parameters}
\docparam{viewName}{Name of the view to be dropped.}
\wxheading{Remarks}
If the view does not exist, this function will return TRUE. Note that views are not supported with all data sources.
\membersection{wxDb::ExecSql}\label{wxdbexecsql}
\func{bool}{ExecSql}{\param{char *}{pSqlStmt}}
Allows a native SQL command to be executed directly against the datasource. In addition to being able to run any standard SQL command, use of this function allows a user to (potentially) utilize features specific to the datasource they are connected to that may not be available through ODBC. The ODBC driver will pass the specified command directly to the datasource.
\wxheading{Parameters}
\docparam{pSqlStmt}{Pointer to the SQL statement to be executed.}
\wxheading{Remarks}
This member extends the wxDb class and allows you to build and execute ANY VALID
SQL statement against the data source. This allows you to extend the class
library by being able to issue any SQL statement that the data source is capable
of processing.
\wxheading{See also}
\helpref{wxDb::GetData}{wxdbgetdata}, \helpref{wxDb::GetNext}{wxdbgetnext}
\membersection{wxDb::FwdOnlyCursors}\label{wxdbfwdonlycursors}
\func{bool}{FwdOnlyCursors}{\void}
Indicates whether this connection to the datasource only allows forward scrolling cursors or not. This state is set at connection creation time.
\wxheading{Remarks}
In wxWindows v2.4 release, this function will be deprecated to use a renamed version of the function called wxDb::IsFwdOnlyCursors() to match the normal wxWindows naming conventions for class member functions.
\wxheading{See also}
\helpref{wxDb::IsFwdOnlyCursors}{wxdbisfwdonlycursors}, \helpref{wxDb::wxDb}{wxdbconstr}, \helpref{wxDbGetConnection}{wxdbfunctions}
\membersection{wxDb::GetCatalog}\label{wxdbgetcatalog}
\func{wxDbInf *}{GetCatalog}{\param{char *}{userID}}
Returns a wxDbInf pointer that points to the catalog(data source) name, schema, number of tables accessible to the current user, and a wxDbTableInf pointer to all data pertaining to all tables in the users catalog.
\wxheading{Parameters}
\docparam{userID}{Owner of the table. Specify a userID when the datasource you are connected to allows multiple unique tables with the same name to be owned by different users. {\it userID} is evaluated as follows:}
\begin{verbatim}
userID == NULL ... UserID is ignored (DEFAULT)
userID == "" ... UserID set equal to 'this->uid'
userID != "" ... UserID set equal to 'userID'
\end{verbatim}
\wxheading{Remarks}
The returned catalog will only contain catalog entries for tables to which the user specified in 'userID' has sufficient privileges. If no user is specified (NULL passed in), a catalog pertaining to all tables in the datasource accessible via this connection will be returned.
\membersection{wxDb::GetColumnCount}\label{wxdbgetcolumncount}
\func{int}{GetColumnCount}{\param{char *}{tableName}, \param{const char *}{userID}}
\wxheading{Parameters}
\docparam{tableName}{A table name you wish to obtain column information about.}
\docparam{userID}{Name of the user that owns the table(s). Required for some datasources for situations where there may be multiple tables with the same name in the datasource, but owned by different users. {\it userID} is evaluated in the following manner:}
\begin{verbatim}
userID == NULL ... UserID is ignored (DEFAULT)
userID == "" ... UserID set equal to 'this->uid'
userID != "" ... UserID set equal to 'userID'
\end{verbatim}
\wxheading{Return value}
Returns a count of how many columns are in the specified table. If an error occurs retrieving the number of columns the function will return a -1.
\membersection{wxDb::GetColumns}\label{wxdbgetcolumns}
\func{wxDbColInf *}{GetColumns}{\param{char *}{tableName}, \param{int *}{numCols}, \param{const char *}{userID=NULL}}
\func{wxDbColInf *}{GetColumns}{\param{char *}{tableName[]}, \param{const char *}{userID}}
\wxheading{Parameters}
\docparam{tableName}{A table name you wish to obtain column information about.}
\docparam{numCols}{A pointer to a integer which will hold a count of the number of columns returned by this function}
\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.}
\docparam{userID}{Name of the user that owns the table(s). Required for some datasources for situations where there may be multiple tables with the same name in the datasource, but owned by different users. {\it userID} is evaluated in the following manner:}
\begin{verbatim}
userID == NULL ... UserID is ignored (DEFAULT)
userID == "" ... UserID set equal to 'this->uid'
userID != "" ... UserID set equal to 'userID'
\end{verbatim}
\wxheading{Return value}
This function returns an array of wxDbColInf structures. This allows you to obtain
information regarding the columns of your table(s). If no columns were found, or
an error occurred, this pointer will be zero (null).
THE CALLING FUNCTION IS RESPONSIBLE FOR DELETING THE {\it wxDbColInf} MEMORY WHEN IT IS
FINISHED WITH IT.
\normalbox{ALL column bindings associated with this wxDb instance are unbound
by this function. This function should use its own wxDb instance
to avoid undesired unbinding of columns.}
\wxheading{See also}
\helpref{wxDbColInf}{wxdbcolinf}
\wxheading{Example}
\begin{verbatim}
char *tableList[] = {"PARTS", 0};
wxDbColInf *colInf = pDb->GetColumns(tableList);
if (colInf)
{
// Use the column inf
.......
// Destroy the memory
delete [] colInf;
}
\end{verbatim}
\membersection{wxDb::GetData}\label{wxdbgetdata}
\func{bool}{GetData}{\param{UWORD}{ colNo}, \param{SWORD}{ cType}, \param{PTR}{ pData}, \param{SDWORD}{ maxLen}, \param{SDWORD FAR *}{ cbReturned} }
Used to retrieve result set data without binding column values to memory variables (i.e. not using a wxDbTable instance to access table data).
\wxheading{Parameters}
\docparam{colNo}{Ordinal number of column in the result set to be returned.}
\docparam{cType}{The C data type that is to be returned.}
\docparam{pData}{Memory buffer which will hold the data returned by the call to this function.}
\docparam{maxLen}{Maximum size of the buffer that will hold the returned value.}
\docparam{cbReturned}{Pointer to the buffer containing the length of the actual data returned. If this value comes back as SQL_NULL_DATA, then the GetData() call has failed.}
\wxheading{See also}
\helpref{wxDb::GetNext}{wxdbgetnext}, \helpref{wxDb::ExecSql}{wxdbexecsql}
\wxheading{Example}
\begin{verbatim}
SDWORD cb;
ULONG reqQty;
wxString sqlStmt;
sqlStmt = "SELECT SUM(REQUIRED_QTY - PICKED_QTY) FROM ORDER_TABLE WHERE \
PART_RECID = 1450 AND REQUIRED_QTY > PICKED_QTY";
// Perform the query
if (!pDb->ExecSql(sqlStmt.c_str()))
{
// ERROR
return(0);
}
// Request the first row of the result set
if (!pDb->GetNext())
{
// ERROR
return(0);
}
Read column #1 of this row of the result set and store the value in 'reqQty'
if (!pDb->GetData(1, SQL_C_ULONG, &reqQty, 0, &cb))
{
// ERROR
return(0);
}
// Check for a NULL result
if (cb == SQL_NULL_DATA)
return(0);
\end{verbatim}
\wxheading{Remarks}
When requesting multiple columns to be returned from the result set (for example, the SQL query
requested 3 columns be returned), the calls to GetData must request the columns in ordinal
sequence (1,2,3 or 1,3 or 2,3).
\membersection{wxDb::GetDatabaseName}\label{wxdbgetdatabasename}
\func{char *}{GetDatabaseName}{\void}
Returns the name of the database engine.
\membersection{wxDb::GetDataSource}\label{wxdbgetdatasource}
\func{char *}{GetDataSource}{\void}
Returns the ODBC datasource name.
\membersection{wxDb::GetHDBC}\label{wxdbgethdbc}
\func{HDBC}{GetHDBC}{\void}
Returns the ODBC handle to the database connection.
\membersection{wxDb::GetHENV}\label{wxdbgethenv}
\func{HENV}{GetHENV}{\void}
Returns the ODBC environment handle.
\membersection{wxDb::GetHSTMT}\label{wxdbgethstmt}
\func{HSTMT}{GetHSTMT}{\void}
Returns the ODBC statement handle associated with this database connection.
\membersection{wxDb::GetKeyFields}\label{wxdbgetkeyfields}
\func{int}{GetKeyFields}{\param{char *}{tableName}, \param{wxDbColInf *}{colInf}, \param{int}{nocols}}
Used to determine which columns are members of primary or non-primary indexes on the specified table. If a column is a member of a foreign key for some other table, that information is detected also.
This function is primarily for use by the \helpref{wxDb::GetColumns}{wxdbgetcolumns} function, but may be called if desired from the client application.
\wxheading{Parameters}
\docparam{tableName}{Name of the table for which the columns will be evaluated as to their inclusion in any indexes.}
\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.}
\docparam{nocols}{Number of columns defined in the instance of colInf.}
\wxheading{Return value}
Currently always returns TRUE.
\wxheading{See also}
\helpref{wxDbColInf}{wxdbcolinf}, \helpref{wxDb::GetColumns}{wxdbgetcolumns}
\membersection{wxDb::GetNext}\label{wxdbgetnext}
\func{bool}{GetNext}{\void}
Requests the next row in the result set obtained by issueing a query through a direct request using wxDb::ExecSql().
\wxheading{See also}
\helpref{wxDb::ExecSql}{wxdbexecsql}, \helpref{wxDb::GetData}{wxdbgetdata}
\membersection{wxDb::GetNextError}\label{wxdbgetnexterror}
\func{bool}{GetNextError}{\param{HENV}{ aHenv}, \param{HDBC}{ aHdbc = SQL_NULL_HDBC}, \param{HSTMT}{ aHstmt = SQL_NULL_HSTMT}}
\wxheading{Parameters}
\docparam{aHenv}{A handle to the ODBC environment.}
\docparam{aHdbc}{A handle to the ODBC connection. Pass this in if the ODBC function call that
erred out required a hdbc or hstmt argument.}
\docparam{AHstmt}{A handle to the ODBC statement being executed against. Pass this in if the
ODBC function call that erred out requires a hstmt argument.}
\wxheading{See also}
\helpref{wxDb::DispNextError}{wxdbdispnexterror}, \helpref{wxDb::DispAllErrors}{wxdbdispallerrors}
\wxheading{Example}
\begin{verbatim}
if (SQLExecDirect(hstmt, (UCHAR FAR *) pSqlStmt, SQL_NTS) != SQL_SUCCESS)
{
// Display all ODBC errors for this stmt
return(db.DispAllErrors(db.henv, db.hdbc, hstmt));
}
\end{verbatim}
\membersection{wxDb::GetPassword}\label{wxdbgetpassword}
\func{char *}{GetPassword}{\void}
Returns the password used to connect to the datasource.
\membersection{wxDb::GetTableCount}\label{wxdbgettablecount}
\func{int}{GetTableCount}{\void}
Returns the number of wxDbTable() instances currently using this data source connection.
\membersection{wxDb::GetUsername}\label{wxdbgetusername}
\func{char *}{GetUsername}{\void}
Returns the user name used to access the datasource.
\membersection{wxDb::Grant}\label{wxdbgrant}
\func{bool}{Grant}{\param{int}{ privileges}, \param{char *}{tableName}, \param{char *}{userList = "PUBLIC"}}
Use this member function to GRANT privileges to users for accessing tables in the datasource.
\wxheading{Parameters}
\docparam{privileges}{Use this argument to select which privileges you want to grant. Pass DB_GRANT_ALL to grant all privileges. To grant individual privileges pass one or more of the following OR'd together:}
\begin{verbatim}
DB_GRANT_SELECT = 1
DB_GRANT_INSERT = 2
DB_GRANT_UPDATE = 4
DB_GRANT_DELETE = 8
DB_GRANT_ALL = DB_GRANT_SELECT | DB_GRANT_INSERT |
DB_GRANT_UPDATE | DB_GRANT_DELETE
\end{verbatim}
\docparam{tableName}{The name of the table you wish to grant privileges on.}
\docparam{userList}{A comma delimited list of users to grant the privileges to. If this argument is not passed in, the privileges will be given to the general PUBLIC.}
\wxheading{Remarks}
Some databases require user names to be specified in all capital letters (i.e. Oracle). This function does not automatically capitalize the user names passed in the comma-separated list. This is the responsibility of the calling routine.
\wxheading{Example}
\begin{verbatim}
db.Grant(DB_GRANT_SELECT | DB_GRANT_INSERT, "PARTS", "mary, sue");
\end{verbatim}
\membersection{wxDb::IsFwdOnlyCursors}\label{wxdbisfwdonlycursors}
\func{bool}{IsFwdOnlyCursors}{\void}
Indicates whether this connection to the datasource only allows forward scrolling cursors or not. This state is set at connection creation time.
\wxheading{Remarks}
Added as of wxWindows v2.4 release, this function is a renamed version of wxDb::FwdOnlyCursors() to match the normal wxWindows naming conventions for class member functions.
This function is not available in versions prior to v2.4. You should use \helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors} for wxWindows versions priori to 2.4.
\wxheading{See also}
\helpref{wxDb::wxDb}{wxdbconstr}, \helpref{wxDbGetConnection}{wxdbfunctions}
\membersection{wxDb::IsOpen}\label{wxdbisopen}
\func{bool}{IsOpen}{\void}
Indicates whether the database connection to the datasource is currently opened.
\membersection{wxDb::Open}\label{wxdbopen}
\func{bool}{Open}{\param{char *}{Dsn}, \param{char *}{Uid}, \param{char *}{AuthStr}}
\wxheading{Parameters}
\docparam{Dsn}{Data source name. The name of the ODBC data source as
assigned when the data source is initially set up through the ODBC data
source manager.}
\docparam{Uid}{User ID. The name (ID) of the user you wish to connect as
to the data source. The user name (ID) determines what objects you
have access to in the datasource and what datasource privileges you have.
Privileges include being able to create new objects, update objects, delete
objects and so on. Users and privileges are normally administered by the
database administrator.}
\docparam{AuthStr}{The password associated witht the Uid.}
\wxheading{Remarks}
After a wxDb instance is created, it must then be opened. When opening a data source, there must be hree pieces of information passed. The data source name, user name (ID) and the password for the user. No database activity on the data source can be performed until it is opened. This would normally be done at program startup and the data source would remain open for the duration of the program run. Note: It is possible to have multiple data sources open at the same time to support distributed database connections.
\wxheading{Example}
\begin{verbatim}
wxDb sampleDB(Db.Henv);
if (!sampleDB.Open("Oracle 7.1 HP/UX", "gtasker", "myPassword"))
{
// Error opening data source
}
\end{verbatim}
\membersection{wxDb::RollbackTrans}\label{wxdbrollbacktrans}
\func{bool}{RollbackTrans}{\void}
Function to "rollback" changes made to the database. After an insert/update/delete, the operation may be "undone" by issuing this command any time before a \helpref{wxDb::CommitTrans}{wxdbcommittrans} is called on the database connection.
\wxheading{Remarks}
Transactions begin implicitly as soon as you make a change to the database. At any time thereafter, you can save your work to the database (using \helpref{wxDb::CommitTrans}{wxdbcommittrans}) or undo all of your changes using this function.
\normalbox{Calling this member function rolls back ALL open (uncommitted) transactions on this ODBC connection.}
\wxheading{See also}
\helpref{wxDb::CommitTrans}{wxdbcommittrans} for a special note on cursors
\membersection{wxDb::SetSqlLogging}\label{wxdbsetsqllogging}
\func{bool}{SetSqlLogging}{\param{wxDbSqlLogState}{ state}, \param{const wxChar *}{filename = SQL_LOG_FILENAME}, \param{bool}{ append = FALSE}}
\wxheading{Parameters}
\docparam{state}{Either sqlLogOFF or sqlLogON (see \helpref{enum wxDbSqlLogState}{wxdbcolfor}). Turns logging of SQL commands sent to the data source OFF or ON.}
\docparam{filename}{{\it OPTIONAL}. Name of the file to which the log text is to be written.}
\docparam{append}{{\it OPTIONAL}. Whether the file is appended to or overwritten.}
\wxheading{Remarks}
When called with {\it sqlLogON}, all commands sent to the data source engine are logged to the file specified by {\it filename}. Logging is done by embedded WriteSqlLog() calls in the database member functions, or may be manually logged by adding calls to WriteSqlLog() in your own source code.
When called with {\it sqlLogOFF}, the logging file is closed, and any calls to WriteSqlLog() are ignored.
\membersection{wxDb::TableExists}\label{wxdbtablexists}
\func{bool}{TableExists}{\param{const char *}{tableName}, \param{const char *}{userID=NULL}, \param{const char *}{path=NULL}}
Checks the ODBC data source for the existence of a table. If a {\it userID} is specified, then the table must be accessible by that user (user must have at least minimal privileges to the table).
\wxheading{Parameters}
\docparam{tableName}{Name of the table to check for the existence of}
\docparam{userID}{Owner of the table. Specify a userID when the datasource you are connected
to allows multiple unique tables with the same name to be owned by different users. {\it userID}
is evaluated as follows:}
\begin{verbatim}
userID == NULL ... UserID is ignored (DEFAULT)
userID == "" ... UserID set equal to 'this->uid'
userID != "" ... UserID set equal to 'userID'
\end{verbatim}
\wxheading{Remarks}
{\it tableName} may refer to a table, view, alias or synonym.
This function does not indicate whether or not the user has privileges to query or perform other functions on the table.
\membersection{wxDb::TranslateSqlState}\label{wxdbtranslatesqlstate}
\func{int}{TranslateSqlState}{\param{const wxChar *}{SQLState}}
\wxheading{Parameters}
\docparam{SQLState}{Converts an ODBC sqlstate to an internal error code.}
\wxheading{Return value}
Returns the internal class DB_ERR code. See \helpref{wxDb::DB_STATUS}{wxdb} definition.
\membersection{wxDb::WriteSqlLog}\label{wxdbwritesqllog}
\func{bool}{WriteSqlLog}{\param{const wxChar *}{logMsg}}
\wxheading{Parameters}
\docparam{logMsg}{Free form string to be written to the log file.}
\wxheading{Remarks}
Very useful debugging tool that may be turned on/off during run time. The
passed in string {\it logMsg} will be written to a log file if SQL logging
is turned on (see \helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging} for details on turning logging on/off).
\wxheading{Return value}
If SQL logging is off when a call to WriteSqlLog() is made, or there is a
failure to write the log message to the log file, the function returns
FALSE without performing the requested log, otherwise TRUE is returned.
\wxheading{See also}
\helpref{wxDb::SetSqlLogging}{wxdbsetsqllogging}
\begin{comment} % George: this is a duplicate of one above (only with more text)
\membersection{wxDb::IsFwdOnlyCursors}\label{wxdbisfwdonlycursors}
\func{bool}{IsFwdOnlyCursors}{\void}
\wxheading{Remarks}
This setting indicates whether this database connection was created
as being capable of using only forward scrolling cursors. This function
does NOT indicate if the ODBC driver or datasource supports backward
scrolling cursors. There is no standard way of detecting if the driver
or datasource can support backward scrolling cursors.
If a wxDb instance was created as being forward only cursors, then even if
the datasource and ODBC driver support backward scrolling cursors, then
tables using this database connection can only use forward scrolling
cursors.
The default setting of whether a wxDb connection to a database allows
forward-only or also backward scrolling cursors is defined in setup.h by
the wxODBC_FWD_ONLY_CURSORS value. This default setting can be overridden
when the wxDb connection is initially created (see \helpref{wxDb constructor}{wxdbconstr}).
\wxheading{Return value}
Returns TRUE if this datasource connection is defined as using only forward
scrolling cursors, or FALSE if the connection is defined as being capable
of supporting backward scrolling cursors (see note above).
\wxheading{See also}
\helpref{wxDb constructor}{wxdbconstr}
\end{comment}
\membersection{wxDb::Dbms}\label{wxdbdbms}
\func{wxDBMS }{Dbms}{\void}
\wxheading{Remarks}
The return value will be of the enumerated type wxDBMS. This enumerated
type contains a list of all the currently tested and supported databases.
Additional databases may be work with these classes, but these databases
returned by this function have been tested and confirmed to work with
these ODBC classes.
enum wxDBMS includes:
\begin{verbatim}
dbmsUNIDENTIFIED
dbmsORACLE
dbmsSYBASE_ASA
dbmsSYBASE_ASE
dbmsMY_SQL_SERVER
dbmsMY_SQL
dbmsPOSTGRES
dbmsACCESS
dbmsDBASE
dbmsINFORMIX
\end{verbatim}
There are known issues with conformance to the ODBC standards with several
datasources listed above. Please see the overview for specific details on
which datasource have which issues.
\wxheading{Return value}
The return value will indicate which of the supported datasources is
currently connected to by this connection. In the event that the
datasource is not recognized, a value of 'dbmsUNIDENTIFIED' is returned.
\membersection{wxDb::SetDebugErrorMessages}\label{wxdbsetdebugerrormessages}
\func{void}{SetDebugErrorMessages}{\param{bool }{state}}
\docparam{state}{Either TRUE (debug messages are displayed) or FALSE (debug
messages are not displayed.}
\wxheading{Remarks}
Turns on/off debug error messages from the ODBC class library. When
this function is passed TRUE, errors are reported to the user automatically
in a text or pop-up dialog when an ODBC error occurs. When passed FALSE,
errors are silently handled.
When compiled in release mode (FINAL=1), this setting has no affect.
\wxheading{See also}
\helpref{wxDb constructor}{wxdbconstr}
\membersection{wxDb::LogError}\label{wxdblogerror}
\func{void}{LogError}{\param{const char *}{errMsg} \param{const char *}{SQLState=0}}
\docparam{errMsg}{Free-form text to display describing the error to be logged.}
\docparam{SQLState}{Native SQL state error}
\wxheading{Remarks}
Calling this function will enter a log message in the error list maintained
for the database connection. This log message is free form and can be
anything the programmer wants to enter in the error list.
If SQL logging is turned on, the call to this function will also log the
text into the SQL log file.
\wxheading{See also}
\helpref{wxDb::WriteSqlLog}{wxdbwritesqllog}
\section{\class{wxDbColInf}}\label{wxdbcolinf}
Used with the \helpref{wxDb::GetColumns}{wxdbgetcolumns} functions for obtaining all retrievable information about a columns definition.
\section{\class{wxDbColFor}}\label{wxdbcolfor}
Beginning support for handling international formatting specifically on dates and floats.
Only one function is provided with this class currently:
\membersection{wxDbColFor::Format}\label{wxdbcolforformat}
\func{int}{Format}{\param{int }{Nation}, \param{int }{dbDataType}, \param{SWORD }{sqlDataType}, \param{short }{columnSize}, \param{short }{decimalDigits}}\label{wxdbcolforformat}
Work in progress, and should be inter-related with wxLocale
\section{\class{wxDbInf}}\label{wxdbinf}
Contains information regarding the database connection (data source name,
number of tables, etc). A pointer to a wxDbTableInf is included in this
class so a program can create a wxDbTableInf array instance to maintain all
information about all tables in the datasource to have all the datasource's
information in one memory structure.
\section{\class{wxDbTable}}\label{wxdbtable}
A wxDbTable instance provides re-usable access to rows of data in
a table contained within the associated ODBC data source
\wxheading{Include files}
<wx/dbtable.h>\\
<wx/db.h>
\latexignore{\rtfignore{\wxheading{Members}}}
\wxheading{Helper classes and data structures}
The following classes and structs are defined in dbtable.cpp/.h for use with the wxDbTable class.
\begin{verbatim}
class wxDbColDef : Bound column definitions for use by a wxDbTable
instance
class wxDbColDataPtr : Pointer to dynamic column definitions for use with
a wxDbTable instance
class wxDbIdxDef : Used in creation of non-primary indexes
\end{verbatim}
\wxheading{Constants}
\begin{verbatim}
wxDB_DEFAULT_CURSOR Index number of the cursor that each table will use
by default.
wxDB_QUERY_ONLY Used to indicate whether a table that is opened is
for query only, or if insert/update/deletes will
be performed on the table. Less overhead (cursors
and memory) are allocated for query only tables, plus
read access times are faster with some datasources.
wxDB_ROWID_LEN [Oracle specific] - Used when CanUpdateByRowID() is
true. Optimizes updates so they are faster by
updating on the Oracle-specific ROWID column rather
than some other index.
wxDB_DISABLE_VIEW Use to indicate when a database view should not be
if a table is normally set up to use a view.
[Currently unsupported.]
\end{verbatim}
\wxheading{Remarks}
\wxheading{See also}
\helpref{wxDbTable}{wxdbtable}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxDbTable::wxDbTable}\label{wxdbtableconstr}
\func{}{wxDbTable}{\param{wxDb *}{pwxDb}, \param{const char *}{tblName}, \param{const int }{nCols},\param{const char *}{qryTblName = 0}, \param{bool}{qryOnly = !wxDB_QUERY_ONLY},\param{const char *}{tblPath=NULL}}
Default constructor.
\wxheading{Parameters}
\docparam{pSqlStmt}{}
\docparam{typeOfDel}{}
\docparam{pWhereClause}{Default is 0.}
\membersection{wxDbTable::wxDbTable}\label{wxdbtabledestr}
\func{virtual}{\destruct{wxDbTable}}{}
Virtual default destructor.
\membersection{wxDbTable::BuildDeleteStmt}\label{wxdbtablebuilddeletestmt}
\func{void}{BuildSelectStmt}{\param{char *}{pSqlStmt}, \param{int }{typeOfDel}, \param{const char *}{pWhereClause=0}}
\wxheading{Parameters}
\docparam{pSqlStmt}{}
\docparam{typeOfDel}{}
\docparam{pWhereClause}{Default is 0.}
\membersection{wxDbTable::BuildSelectStmt}\label{wxdbtablebuildselectstmt}
\func{void}{BuildSelectStmt}{\param{char *}{pSqlStmt}, \param{int }{typeOfSelect}, \param{bool }{distinct}}
\wxheading{Parameters}
\docparam{pSqlStmt}{}
\docparam{typeOfSelect}{}
\docparam{distinct}{}
\membersection{wxDbTable::BuildUpdateStmt}\label{wxdbtablebuildupdatestmt}
\func{void}{BuildSelectStmt}{\param{char *}{pSqlStmt}, \param{int }{typeOfUpd}, \param{const char *}{pWhereClause=0}}
\wxheading{Parameters}
\docparam{pSqlStmt}{}
\docparam{typeOfUpd}{}
\docparam{pWhereClause}{Default is 0.}
\membersection{wxDbTable::BuildWhereStmt}\label{wxdbtablebuildwherestmt}
\func{void}{BuildSelectStmt}{\param{char *}{pWhereClause}, \param{int }{typeOfWhere}, \param{const char *}{qualTableName=0}, \param{const char *}{useLikeComparison=FALSE}}
\wxheading{Parameters}
\docparam{pWhereClause}{}
\docparam{typeOfWhere}{}
\docparam{qualTableName}{Default is 0.}
\docparam{useLikeComparison}{Default is FALSE.}
\membersection{wxDbTable::CanSelectForUpdate}\label{wxdbtablecanselectforupdate}
\func{bool}{CanSelectForUpdate}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::CanUpdateByROWID}\label{wxdbtablecanupdatebyrowid}
\func{bool}{CanUpdateByROWID}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::ClearMemberVars}\label{wxdbtableclearmembervars}
\func{void}{ClearMemberVars}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::CloseCursor}\label{wxdbtableclosecursor}
\func{bool}{CloseCursor}{\param{HSTMT}{cursor}}
\wxheading{Parameters}
\docparam{cursor}{}
\wxheading{Remarks}
\membersection{wxDbTable::Count}\label{wxdbtablecount}
\func{ULONG}{Count}{\param{const char *}{args="*"}}
\wxheading{Parameters}
\docparam{args}{Default is "*".}
\wxheading{Remarks}
\membersection{wxDbTable::CreateIndex}\label{wxdbtablecreateindex}
\func{bool}{CreateIndex}{\param{const char *}{idxName}, \param{bool}{unique}, \param{int }{noIdxCols}, \param{wxDbIdxDef *}{pIdxDefs}, \param{bool }{attemptDrop=TRUE}}
\wxheading{Parameters}
\docparam{idxName}{}
\docparam{unique}{}
\docparam{noIdxCols}{}
\docparam{pIdxDefs}{}
\docparam{attemptDrop}{Default is TRUE.}
\wxheading{Remarks}
\membersection{wxDbTable::CreateTable}\label{wxdbtablecreatetable}
\func{bool}{CreateTable}{\param{bool }{attemptDrop=TRUE}}
\wxheading{Parameters}
\docparam{attemptDrop}{Default is TRUE.}
\wxheading{Remarks}
\membersection{wxDbTable::DB_STATUS}\label{wxdbtabledbstatus}
\func{bool}{DB_STATUS}{\void}
Accessor function for the private member variable DB_STATUS.
\membersection{wxDbTable::IsColNull}\label{wxdbtableiscolnull}
\func{bool}{IsColNull}{\param{int }{colNo}}
\wxheading{Parameters}
\docparam{colNo}{}
\wxheading{Remarks}
\membersection{wxDbTable::Delete}\label{wxdbtabledelete}
\func{bool}{Delete}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::DeleteCursor}\label{wxdbtabledeletecursor}
\func{bool}{DeleteCursor}{\param{HSTMT }{hstmtDel}}
\wxheading{Parameters}
\docparam{hstmtDel}{}
\wxheading{Remarks}
\membersection{wxDbTable::DeleteWhere}\label{wxdbtabledeletewhere}
\func{bool}{DeleteWhere}{\param{const char *}{pWhereClause}}
\wxheading{Parameters}
\docparam{pWhereClause}{}
\wxheading{Remarks}
\membersection{wxDbTable::DeleteMatching}\label{wxdbtabledeletematching}
\func{bool}{DeleteMatching}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::DropIndex}\label{wxdbtabledropindex}
\func{bool}{DropIndex}{\param{const char *}{idxName}}
\wxheading{Parameters}
\docparam{idxName}{}
\wxheading{Remarks}
\membersection{wxDbTable::DropTable}\label{wxdbtabledroptable}
\func{bool}{DropTable}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::GetColDefs}\label{wxdbtablegetcoldefs}
\func{wxDbColDef *}{GetColDefs}{}
\wxheading{Remarks}
\membersection{wxDbTable::GetCursor}\label{wxdbtablegetcursor}
\func{HSTMT}{GetCursor}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::GetDb}\label{wxdbtablegetdb}
\func{wxDb *}{GetDb}{}
Accessor function for the private member variable pDb which is a pointer to the datasource connection that this wxDbTable instance uses.
\wxheading{Remarks}
\membersection{wxDbTable::GetFirst}\label{wxdbtablegetfirst}
\func{bool}{GetFirst}{\void}
\wxheading{Remarks}
This function can only be used if the datasource connection used by the wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the connection does not allow backward scrolling cursors, this function will return FALSE, and the data contained in the bound columns will be undefined.
\wxheading{See also}
\helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors}
\membersection{wxDbTable::GetFromClause}\label{wxdbtablegetfromclause}
\func{const char *}{GetFromClause}{}
Accessor function that returns the current FROM setting assigned with the \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause}.
\membersection{wxDbTable::GetLast}\label{wxdbtablegetlast}
\func{bool}{GetLast}{\void}
\wxheading{Remarks}
This function can only be used if the datasource connection used by the wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the connection does not allow backward scrolling cursors, this function will return FALSE, and the data contained in the bound columns will be undefined.
\wxheading{See also}
\helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors}
\membersection{wxDbTable::GetNewCursor}\label{wxdbtablegetnewcursor}
\func{HSTMT *}{GetNewCursor}{\param{bool }{setCursor=FALSE}, \param{bool }{bindColumns=TRUE}}
\wxheading{Parameters}
\docparam{setCursor}{Default is FALSE.}
\docparam{bindColumns}{Default is TRUE.}
\wxheading{Remarks}
\membersection{wxDbTable::GetNext}\label{wxdbtablegetnext}
\func{bool}{GetNext}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::GetNumberOfColumns}\label{wxdbtablegetnumberofcolumns}
\func{bool}{GetNumberOfColumns}{}
Accessor function that returns the number of columns that are statically bound for access by the wxDbTable instance.
\membersection{wxDbTable::GetOrderByClause}\label{wxdbtablegetorderbyclause}
\func{const char *}{GetOrderByClause}{}
Accessor function that returns the current ORDER BY setting assigned with the \helpref{wxDbTable::SetOrderByClause}{wxdbtablesetorderbyclause}.
\membersection{wxDbTable::GetPrev}\label{wxdbtablegetprev}
\func{bool}{GetPrev}{\void}
\wxheading{Remarks}
This function can only be used if the datasource connection used by the wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the connection does not allow backward scrolling cursors, this function will return FALSE, and the data contained in the bound columns will be undefined.
\wxheading{See also}
\helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors}
\membersection{wxDbTable::GetQueryTableName}\label{wxdbtablegetquerytablename}
\func{const char *}{GetQueryTableName}{}
\wxheading{Remarks}
\membersection{wxDbTable::GetRowNum}\label{wxdbtablegetrownum}
\func{UWORD}{GetRowNum}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::GetTableName}\label{wxdbtablegettablename}
\func{const char *}{GetTableName}{}
\wxheading{Remarks}
\membersection{wxDbTable::GetTablePath}\label{wxdbtablegettablepath}
\func{const char *}{GetTablePath}{}
\wxheading{Remarks}
\membersection{wxDbTable::GetWhereClause}\label{wxdbtablegetwhereclause}
\func{const char *}{GetWhereClause}{}
Accessor function that returns the current WHERE setting assigned with the \helpref{wxDbTable::SetWhereClause}{wxdbtablesetwhereclause}
\membersection{wxDbTable::Insert}\label{wxdbtableinsert}
\func{int}{Insert}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::IsCursorClosedOnCommit}\label{wxdbtableiscursorclosedoncommit}
\func{bool}{IsCursorClosedOnCommit}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::IsQueryOnly}\label{wxdbtableisqueryonly}
\func{bool}{IsQueryOnly}{}
Accessor function that returns a value indicating if this wxDbTable instance was created to allow only queries to be performed on the bound columns. If this function returns TRUE, then no actions may be performed using this wxDbTable instance that would modify (insert/delete/update) the table's data.
\membersection{wxDbTable::Open}\label{wxdbtableopen}
\func{bool}{Open}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::Query}\label{wxdbtablequery}
\func{virtual bool}{Query}{\param{bool}{forUpdate=FALSE}, \param{bool}{distinct=FALSE}}
\wxheading{Parameters}
\docparam{forUpdate}{Default is FALSE.}
\docparam{distinct}{Default is FALSE.}
\wxheading{Remarks}
\membersection{wxDbTable::QueryBySqlStmt}\label{wxdbtablequerybysqlstmt}
\func{bool}{QueryBySqlStmt}{\param{const char *}{pSqlStmt}}
\wxheading{Parameters}
\docparam{pSqlStmt}{}
\wxheading{Remarks}
\membersection{wxDbTable::QueryMatching}\label{wxdbtablequerymatching}
\func{virtual bool}{QueryMatching}{\param{bool}{forUpdate=FALSE}, \param{bool}{distinct=FALSE}}
\wxheading{Parameters}
\docparam{forUpdate}{Default is FALSE.}
\docparam{distinct}{Default is FALSE.}
\wxheading{Remarks}
\membersection{wxDbTable::QueryOnKeyFields}\label{wxdbtablequeryonkeyfields}
\func{bool}{QueryOnKeyFields}{\param{bool}{forUpdate=FALSE}, \param{bool}{distinct=FALSE}}
\wxheading{Parameters}
\docparam{forUpdate}{Default is FALSE.}
\docparam{distinct}{Default is FALSE.}
\wxheading{Remarks}
\membersection{wxDbTable::Refresh}\label{wxdbtablerefresh}
\func{bool}{Refresh}{\void}
\wxheading{Remarks}
\membersection{wxDbTable::SetColDefs}\label{wxdbtablesetcoldefs}
\func{void}{SetColDefs}{\param{int }{index}, \param{const char *}{fieldName}, \param{int }{dataType}, \param{void *}{pData}, \param{int }{cType}, \param{int }{size}, \param{bool }{keyField = FALSE}, \param{bool }{upd = TRUE}, \param{bool }{insAllow = TRUE}, \param{bool }{derivedCol = FALSE}}
\func{wxDbColDataPtr *}{SetColDefs}{\param{wxDbColInf *}{colInfs}, \param{ULONG }{numCols}}
\wxheading{Parameters}
\docparam{index}{}
\docparam{fieldName}{}
\docparam{dataType}{}
\docparam{pData}{}
\docparam{cType}{}
\docparam{size}{}
\docparam{keyField}{Default is FALSE.}
\docparam{upd}{Default is TRUE.}
\docparam{insAllow}{Default is TRUE.}
\docparam{derivedCol}{Default is FALSE.}
\docparam{colInfs}{}
\docparam{numCols}{}
\wxheading{Remarks}
\membersection{wxDbTable::SetCursor}\label{wxdbtablesetcursor}
\func{bool}{Open}{\param{HSTMT *}{hstmtActivate = (void **) wxDB_DEFAULT_CURSOR}}
\wxheading{Parameters}
\docparam{hstmtActivate}{Default is wxDB_DEFAULT_CURSOR.}
\wxheading{Remarks}
\membersection{wxDbTable::SetFromClause}\label{wxdbtablesetfromclause}
\func{void}{SetFromClause}{\param{const wxString& }{From}}
\wxheading{Parameters}
\docparam{From}{}
\membersection{wxDbTable::SetNull}\label{wxdbtablesetnull}
\func{bool}{SetNull}{\param{int }{colNo}}
\func{bool}{SetNull}{\param{const char *}{colName}}
\wxheading{Parameters}
\docparam{colNo}{}
\docparam{colName}{}
\wxheading{Remarks}
\membersection{wxDbTable::SetOrderByClause}\label{wxdbtablesetorderbyclause}
\func{void}{SetOrderByClause}{\param{const wxString& }{OrderBy}}
\wxheading{Parameters}
\docparam{OrderBy}{}
\membersection{wxDbTable::SetQueryTimeout}\label{wxdbtablesetquerytimeout}
\func{bool}{SetQueryTimeout}{\param{UDWORD }{nSeconds}}
\wxheading{Parameters}
\docparam{nSeconds}{}
\wxheading{Remarks}
\membersection{wxDbTable::SetWhereClause}\label{wxdbtablesetwhereclause}
\func{void}{SetWhereClause}{\param{const wxString& }{Where}}
\wxheading{Parameters}
\docparam{Where}{}
\membersection{wxDbTable::Update}\label{wxdbtableupdate}
\func{bool}{Update}{\void}
\func{bool}{Update}{\param{const char *}{pSqlStmt}}
\wxheading{Parameters}
\docparam{pSqlStmt}{}
\wxheading{Remarks}
\membersection{wxDbTable::UpdateWhere}\label{wxdbtableupdatewhere}
\func{bool}{UpdateWhere}{\param{const char *}{pWhereClause}}
\wxheading{Parameters}
\docparam{pWhereClause}{}
\wxheading{Remarks}
\membersection{wxDbTable::operator $++$}\label{wxdbtableplusplus}
\func{bool}{operator $++$}{\void}
Same as \helpref{wxDbTable::GetNext}{wxdbtablegetnext}
\wxheading{See also}
\helpref{wxDbTable::GetNext}{wxdbtablegetnext}
\membersection{wxDbTable::operator $--$}\label{wxdbtableminusminus}
\func{bool}{operator $--$}{\void}
Same as \helpref{wxDbTable::GetPrev}{wxdbtablegetprev}
\wxheading{See also}
\helpref{wxDbTable::GetPrev}{wxdbtablegetprev}
\section{\class{wxDbTableInf}}\label{wxdbtableinf}
Currently only used by wxDb::GetCatalog() internally and wxDbInf class,
but may be used in future releases for user functions. Contains information
describing the table (Name, type, etc). A pointer to a wxDbColInf array
instance is included so a program can create a wxDbColInf array instance
(using \helpref{wxDb::GetColumns}{wxdbgetcolumns}) to maintain all information about the columns
of a table in one memory structure.