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 occured 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.}
\docparam{unsigned int {\bf nTables}}{Number of wxDbTable objects connected to this wxDb instance. {\bf FOR INTERNAL USE ONLY} by wxDbTable!!!}
{\it wxDbSqlTypeInfo {\bf typeInfVarchar}}
{\it wxDbSqlTypeInfo {\bf typeInfInteger}}
{\it wxDbSqlTypeInfo {\bf typeInfFloat}}
{\it wxDbSqlTypeInfo {\bf typeInfDate}}
\begin{indented}{1cm}
The four wxDbSqlTypeInfo member variables listed above contain information about logical data types VARCHAR, INTEGER, FLOAT and DATE.
This information is obtained from the ODBC driver by use of the ::SQLGetTypeInfo() function. The key piece of information is the type name the datasource uses for each logical data type. e.g. VARCHAR; Oracle calls it VARCHAR2.
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.
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 wxTable instances which use this connection must be deleted before closing the database connection.
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 wxTable
object. This is only necessary however if the data source closes the cursor after a
commit or rollback. Use the wxTable::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
\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.
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()).
\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 soruces.
\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
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.
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.}
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 wxDb::GetColumns() 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 wxDb::GetColumns()). This function populates the PkCol, PkTableName, and FkTableName members of the colInf structure.}
\docparam{nocols}{Number of columns defined in the instance of colInf.}
\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.
\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"))
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
\docparam{state}{Either sqlLogOFF or sqlLogON (see \helpref{enum wxDbSqlLogState}{wxdbenumsqllogstate}). 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.
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 privleges to query or perform other functions on the table.