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
- dbmsVIRTUOSO
- dbmsDB2
- dbmdINTERBASE
-\end{verbatim}
+\begin{itemize}\itemsep=0pt
+\item DB2
+\item DBase (IV, V)**
+\item Firebird
+\item INFORMIX
+\item Interbase
+\item MS SQL Server (v7 - minimal testing)
+\item MS Access (97, 2000, 2002, and 2003)
+\item MySQL (2.x and 3.5 - use the 2.5x drivers though)
+\item Oracle (v7, v8, v8i)
+\item Pervasive SQL
+\item PostgreSQL
+\item Sybase (ASA and ASE)
+\item XBase Sequiter
+\item VIRTUOSO
+\end{itemize}
See the remarks in \helpref{wxDb::Dbms}{wxdbdbms} for exceptions/issues with each of these database engines.
The wxDb instance returned is also opened (see \helpref{wxDb::Open}{wxdbopen}).
This function (along with wxDbFreeConnection() and wxDbCloseConnection())
-maintain a cached of wxDb instances for user/re-use by a program. When a
+maintain a cache of wxDb instances for user/re-use by a program. When a
program needs a wxDb instance, it may call this function to obtain a wxDb
instance. If there is a wxDb instance in the cache that is currently unused
that matches the connection requirements specified in {\it'pDbConfig'} then
\begin{verbatim}
// Incomplete code sample
db.CreateView("PARTS_SD1", "PN, PD, QTY",
- "SELECT PART_NO, PART_DESC, QTY_ON_HAND * 1.1 FROM PARTS \
+ "SELECT PART_NUM, 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.
\membersection{wxDb::GetData}\label{wxdbgetdata}
-\func{bool}{GetData}{\param{UWORD}{ colNo}, \param{SWORD}{ cType},
+\func{bool}{GetData}{\param{UWORD}{ colNumber}, \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
\wxheading{Parameters}
-\docparam{colNo}{Ordinal number of the desired column in the result set to be
+\docparam{colNumber}{Ordinal number of the desired column in the result set to be
returned.}
\docparam{cType}{The C data type that is to be returned. See a partial list
in \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}}
\membersection{wxDb::GetKeyFields}\label{wxdbgetkeyfields}
-\func{int }{GetKeyFields}{\param{const wxString \&}{tableName}, \param{wxDbColInf *}{colInf}, \param{UWORD }{nocols}}
+\func{int }{GetKeyFields}{\param{const wxString \&}{tableName}, \param{wxDbColInf *}{colInf}, \param{UWORD }{numColumns}}
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.
\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.}
+\docparam{numColumns}{Number of columns defined in the instance of colInf.}
\wxheading{Return value}
Accessor function to assign the user ID for this class instance.
-\section{\class{wxDbIdxDef}}\label{wxdbidxdef}
+\section{\class{wxDbIndexDef}}\label{wxdbindexdef}
Used in creation of non-primary indexes. Currently there are no member
functions for this class.
\begin{itemize}\itemsep=0pt
\item \helpref{wxDbColDef}{wxdbcoldef}
\item \helpref{wxDbColDataPtr}{wxdbcoldataptr}
-\item \helpref{wxDbIdxDef}{wxdbidxdef}
+\item \helpref{wxDbIndexDef}{wxdbindexdef}
\end{itemize}
\wxheading{Constants}
Constructs the full SQL statement that can be used to update all rows matching
the criteria in the pWhereClause.
-If typeOfUpd is DB\_UPD\_KEYFIELDS, then the current values in the bound columns
+If typeOfUpdate is DB\_UPD\_KEYFIELDS, then the current values in the bound columns
are used to determine which row(s) in the table are to be updated. The
exception to this is when a datasource supports ROW IDs (Oracle). The ROW ID
column is used for efficiency purposes when available.
\docparam{pSqlStmt}{Pointer to storage for the SQL statement retrieved. To be
sure you have adequate space allocated for the SQL statement, allocate
DB\_MAX\_STATEMENT\_LEN bytes.}
-\docparam{typeOfUpd}{The type of update statement being performed. Can be one
+\docparam{typeOfUpdate}{The type of update statement being performed. Can be one
of two values: DB\_UPD\_KEYFIELDS or DB\_UPD\_WHERE.}
-\docparam{pWhereClause}{{\it OPTIONAL}. If the typeOfUpd is DB\_UPD\_WHERE,
+\docparam{pWhereClause}{{\it OPTIONAL}. If the typeOfUpdate is DB\_UPD\_WHERE,
then you must also pass in a SQL WHERE clause in this argument. Default is "".}
\wxheading{Remarks}
// Incomplete code sample
wxDbTable parts;
.....
- if (parts.CanUpdByROWID())
+ if (parts.CanUpdateByROWID())
{
// Note that the ROWID column must always be the last column selected
- sqlStmt = "SELECT PART_NO, PART_DESC, ROWID" FROM PARTS";
+ sqlStmt = "SELECT PART_NUM, PART_DESC, ROWID" FROM PARTS";
}
else
- sqlStmt = "SELECT PART_NO, PART_DESC FROM PARTS";
+ sqlStmt = "SELECT PART_NUM, PART_DESC FROM PARTS";
\end{verbatim}
\membersection{wxDbTable::ClearMemberVar}\label{wxdbtableclearmembervar}
-\func{void}{ClearMemberVar}{\param{UWORD }{colNo}, \param{bool }{setToNull=false}}
+\func{void}{ClearMemberVar}{\param{UWORD }{colNumber}, \param{bool }{setToNull=false}}
Same as \helpref{wxDbTable::ClearMemberVars}{wxdbtableclearmembervars} except
that this function clears only the specified column of its values, and
optionally sets the column to be a NULL column.
-\docparam{colNo}{Column number that is to be cleared. This number (between 0
-and (noCols-1)) is the index of the column definition created using the
+\docparam{colNumber}{Column number that is to be cleared. This number (between 0
+and (numColumns-1)) is the index of the column definition created using the
\helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs} function.}
\docparam{setToNull}{{\it OPTIONAL}. Indicates whether the column should be
flagged as being a NULL value stored in the bound memory variable. If true,
\membersection{wxDbTable::CreateIndex}\label{wxdbtablecreateindex}
-\func{bool}{CreateIndex}{\param{const wxString \&}{idxName}, \param{bool }{unique},
-\param{UWORD }{noIdxCols}, \param{wxDbIdxDef *}{pIdxDefs},
+\func{bool}{CreateIndex}{\param{const wxString \&}{IndexName}, \param{bool }{unique},
+\param{UWORD }{numIndexColumns}, \param{wxDbIndexDef *}{pIndexDefs},
\param{bool }{attemptDrop=true}}
This member function allows you to create secondary (non primary) indexes on
\wxheading{Parameters}
-\docparam{idxName}{Name of the Index. Name must be unique within the table
+\docparam{IndexName}{Name of the Index. Name must be unique within the table
space of the datasource.}
\docparam{unique}{Indicates if this index is unique.}
-\docparam{noIdxCols}{Number of columns in the index.}
-\docparam{pIdxDefs}{A pointer to an array wxDbIdxDef structures. }
+\docparam{numIndexColumns}{Number of columns in the index.}
+\docparam{pIndexDefs}{A pointer to an array \helpref{wxDbIndexDef}{wxdbindexdef} structures. }
\docparam{attemptDrop}{{\it OPTIONAL}. Indicates if the function should try
to execute a \helpref{wxDbTable::DropIndex}{wxdbtabledropindex} on the index
name provided before trying to create the index name. Default is true.}
The first parameter, index name, must be unique and should be given a
meaningful name. Common practice is to include the table name as a prefix
in the index name (e.g. For table PARTS, you might want to call your index
-PARTS\_IDX1). This will allow you to easily view all
+PARTS\_Index1). This will allow you to easily view all
of the indexes defined for a given table grouped together alphabetically.
The second parameter indicates if the index is unique or not. Uniqueness
uniqueness.
In the third parameter, specify how many columns are in your index. This
-number must match the number of columns defined in the 'pIdxDefs' parameter.
+number must match the number of columns defined in the 'pIndexDefs' parameter.
The fourth parameter specifies which columns make up the index using the
-wxDbIdxDef structure. For each column in the index, you must specify two
+\helpref{wxDbIndexDef}{wxdbindexdef} structure. For each column in the index, you must specify two
things, the column name and the sort order (ascending / descending). See
-the example below to see how to build and pass in the wxDbIdxDef structure.
+the example below to see how to build and pass in the \helpref{wxDbIndexDef}{wxdbindexdef} structure.
The fifth parameter is provided to handle the differences in datasources as
to whether they will automatically overwrite existing indexes with the same
\begin{verbatim}
// Create a secondary index on the PARTS table
- wxDbIdxDef idxDef[2]; // 2 columns make up the index
+ wxDbIndexDef IndexDef[2]; // 2 columns make up the index
- wxStrcpy(idxDef[0].ColName, "PART_DESC"); // Column 1
- idxDef[0].Ascending = true;
+ wxStrcpy(IndexDef[0].ColName, "PART_DESC"); // Column 1
+ IndexDef[0].Ascending = true;
- wxStrcpy(idxDef[1].ColName, "SERIAL_NO"); // Column 2
- idxDef[1].Ascending = false;
+ wxStrcpy(IndexDef[1].ColName, "SERIAL_NO"); // Column 2
+ IndexDef[1].Ascending = false;
// Create a name for the index based on the table's name
wxString indexName;
- indexName.Printf("%s_IDX1",parts->GetTableName());
- parts->CreateIndex(indexName, true, 2, idxDef);
+ indexName.Printf("%s_Index1",parts->GetTableName());
+ parts->CreateIndex(indexName, true, 2, IndexDef);
\end{verbatim}
\membersection{wxDbTable::CreateTable}\label{wxdbtablecreatetable}
\membersection{wxDbTable::DropIndex}\label{wxdbtabledropindex}
-\func{bool}{DropIndex}{\param{const wxString \&}{idxName}}
+\func{bool}{DropIndex}{\param{const wxString \&}{IndexName}}
Allows an index on the associated table to be dropped (deleted) if the user
login has sufficient privileges to do so.
\wxheading{Parameters}
-\docparam{idxName}{Name of the index to be dropped.}
+\docparam{IndexName}{Name of the index to be dropped.}
\wxheading{Remarks}
-If the index specified in the 'idxName' parameter does not exist, an error
+If the index specified in the 'IndexName' parameter does not exist, an error
will be logged, and the function will return a result of false.
It is not necessary to call \helpref{wxDb::CommitTrans}{wxdbcommittrans}
\membersection{wxDbTable::IsColNull}\label{wxdbtableiscolnull}
-\func{bool }{IsColNull}{\param{UWORD }{colNo}} const
+\func{bool }{IsColNull}{\param{UWORD }{colNumber}} const
Used primarily in the ODBC class library to determine if a column value is
set to "NULL". Works for all data types supported by the ODBC class library.
\wxheading{Parameters}
-\docparam{colNo}{The column number of the bound column as defined by the
+\docparam{colNumber}{The column number of the bound column as defined by the
\helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}
calls which defined the columns accessible to this wxDbTable instance.}
10%).
\item The ROWID can be included in your SELECT statement as the {\bf last}
column selected, if the datasource supports it. Use
-wxDbTable::CanUpdByROWID() to determine if the ROWID can be
+wxDbTable::CanUpdateByROWID() to determine if the ROWID can be
selected from the datasource. If it can, much better
performance can be achieved on updates and deletes by including
the ROWID in the SELECT statement.
----------------------
// Table Join returning 3 columns
- SELECT part_no, part_desc, sd_name
+ SELECT PART_NUM, part_desc, sd_name
from parts, storage_devices
where parts.storage_device_id =
storage_devices.storage_device_id
SELECT count(*) from PARTS where container = 99
// Order by clause; ROWID, scalar function
- SELECT part_no, substring(part_desc, 1, 10), qty_on_hand + 1, ROWID
+ SELECT PART_NUM, substring(part_desc, 1, 10), qty_on_hand + 1, ROWID
from parts
where warehouse = 10
- order by part_no desc // descending order
+ order by PART_NUM desc // descending order
// Subquery
SELECT * from parts
\membersection{wxDbTable::SetColDefs}\label{wxdbtablesetcoldefs}
-\func{void}{SetColDefs}{\param{UWORD }{index}, \param{const wxString \&}{fieldName},
+\func{bool}{SetColDefs}{\param{UWORD }{index}, \param{const wxString \&}{fieldName},
\param{int }{dataType}, \param{void *}{pData}, \param{SWORD }{cType},
-\param{int }{size}, \param{bool }{keyField = false}, \param{bool }{upd = true},
-\param{bool }{insAllow = true}, \param{bool }{derivedCol = false}}
+\param{int }{size}, \param{bool }{keyField = false}, \param{bool }{updateable = true},
+\param{bool }{insertAllowed = true}, \param{bool }{derivedColumn = false}}
\func{wxDbColDataPtr *}{SetColDefs}{\param{wxDbColInf *}{colInfs}, \param{UWORD }{numCols}}
Other valid types are available also, but these are the most common ones:}
\begin{verbatim}
- SQL_C_CHAR // strings
+ SQL_C_CHAR // string - deprecated: use SQL_C_WXCHAR
+ SQL_C_WXCHAR // string - Used transparently in unicode or non-unicode builds
SQL_C_LONG
SQL_C_ULONG
SQL_C_SHORT
\docparam{size}{Maximum size in bytes of the {\it pData} object.}
\docparam{keyField}{{\it OPTIONAL}. Indicates if this column is part of the
primary index. Default is false.}
-\docparam{upd}{{\it OPTIONAL}. Are updates allowed on this column?
+\docparam{updateable}{{\it OPTIONAL}. Are updates allowed on this column?
Default is true.}
-\docparam{insAllow}{{\it OPTIONAL}. Inserts allowed on this column?
+\docparam{insertAllowed}{{\it OPTIONAL}. Inserts allowed on this column?
Default is true.}
-\docparam{derivedCol}{{\it OPTIONAL}. Is this a derived column (non-base
+\docparam{derivedColumn}{{\it OPTIONAL}. Is this a derived column (non-base
table column for query only)? Default is false.}
\docparam{colInfs}{Pointer to an array of wxDbColInf instances which contains
If {\it pData} is to hold a string of characters, be sure to include enough
space for the NULL terminator in pData and in the byte count of {\it size}.
+Using the first form of this function, if the column definition is not able
+to be created, a value of false is returned. If the specified index of the
+column exceeds the number of columns defined in the wxDbTable instance, an
+assert is thrown and logged (in debug builds) and a false is returned.
+
+A failure to create the column definition in the second form results in a
+value of NULL being returned.
+
Both forms of this function provide a shortcut for defining the columns in
your wxDbTable object. Use this function in any derived wxDbTable
constructor when describing the column/columns in the wxDbTable object.
\begin{verbatim}
// Long way not using this function
- wxStrcpy(colDefs[0].ColName, "PART_NO");
+ wxStrcpy(colDefs[0].ColName, "PART_NUM");
colDefs[0].DbDataType = DB_DATA_TYPE_VARCHAR;
colDefs[0].PtrDataObj = PartNumber;
- colDefs[0].SqlCtype = SQL_C_CHAR;
+ colDefs[0].SqlCtype = SQL_C_WXCHAR;
colDefs[0].SzDataObj = PART_NUMBER_LEN;
colDefs[0].KeyField = true;
colDefs[0].Updateable = false;
colDefs[0].DerivedCol = false;
// Shortcut using this function
- SetColDefs(0, "PART_NUMBER", DB_DATA_TYPE_VARCHAR, PartNumber,
- SQL_C_CHAR, PART_NUMBER_LEN, true, false,true,false);
+ SetColDefs(0, "PART_NUM", DB_DATA_TYPE_VARCHAR, PartNumber,
+ SQL_C_WXCHAR, PART_NUMBER_LEN, true, false, true, false);
\end{verbatim}
\membersection{wxDbTable::SetCursor}\label{wxdbtablesetcursor}
\membersection{wxDbTable::SetColNull}\label{wxdbtablesetcolnull}
-\func{bool}{SetColNull}{\param{UWORD }{colNo}, \param{bool }{set=true}}
+\func{bool}{SetColNull}{\param{UWORD }{colNumber}, \param{bool }{set=true}}
\func{bool}{SetColNull}{\param{const wxString \&}{colName},
\param{bool }{set=true}}
\wxheading{Parameters}
-\docparam{colNo}{Index into the column definitions used when first defining
+\docparam{colNumber}{Index into the column definitions used when first defining
this wxDbTable object.}
\docparam{colName}{Actual data table column name that is to be set to NULL.}
\docparam{set}{Whether the column is set to NULL or not. Passing true sets
\membersection{wxDbGridColInfo::wxDbGridColInfo}\label{wxdbgridcolinfoctor}
-\func{}{wxDbGridColInfo}{\param{int }{colNo}, \param{wxString }{type},
+\func{}{wxDbGridColInfo}{\param{int }{colNumber}, \param{wxString }{type},
\param{wxString }{title}, \param{wxDbGridColInfo *}{next}}
Default constructor. See the database grid example in \helpref{wxDbGridTableBase}{wxdbgridtablebase} to
\wxheading{Parameters}
-\docparam{colNo}{Column number in the \helpref{wxDbTable}{wxdbtable} instance to be used (first column is 0).}
+\docparam{colNumber}{Column number in the \helpref{wxDbTable}{wxdbtable} instance to be used (first column is 0).}
\docparam{type}{Column type ,wxString specifying the grid name for the datatype in this column, or
use wxGRID\_VALUE\_DBAUTO to determine the type automatically from the \helpref{wxDbColDef}{wxdbcoldef} definition}
\docparam{title}{The column label to be used in the grid display}
\membersection{wxDbGridColInfo::AddColInfo}\label{wxdbgridcolinfoaddcolinfo}
-\func{void}{AddColInfo}{\param{int }{colNo},
+\func{void}{AddColInfo}{\param{int }{colNumber},
\param{wxString }{type}, \param{wxString }{title}}
Use this member function for adding columns. See the database
not have any effect.
\wxheading{Parameters}
-\docparam{colNo}{Column number in the \helpref{wxDbTable}{wxdbtable} instance to be used (first column is 0).}
+\docparam{colNumber}{Column number in the \helpref{wxDbTable}{wxdbtable} instance to be used (first column is 0).}
\docparam{type}{Column type ,wxString specifying the grid name for the datatype in this column, or
use wxGRID\_VALUE\_DBAUTO to determine the type automatically from the \helpref{wxDbColDef}{wxdbcoldef} definition}
\docparam{title}{The column label to be used in the grid display}