X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cc81d32f2bf8c159f3b1bf6ddaf62e6d77720209..0a42e3b6ac17519f6fffe8a81cd53f29b72e4ec9:/docs/latex/wx/db.tex diff --git a/docs/latex/wx/db.tex b/docs/latex/wx/db.tex index 2910dd5f26..12cbfd6626 100644 --- a/docs/latex/wx/db.tex +++ b/docs/latex/wx/db.tex @@ -13,6 +13,10 @@ an introduction to using the ODBC classes. +\wxheading{Library} + +\helpref{wxOdbc}{librarieslist} + \wxheading{Helper classes and data structures} The following classes and structs are defined in db.cpp/.h for use with the wxDb class. @@ -66,21 +70,22 @@ NOTE: In a future release, all ODBC class constants will be prefaced with 'wx'. 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. @@ -254,8 +259,8 @@ 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}). +when the wxWidgets library is built. This behavior can be overridden when +an instance of a wxDb is created (see \helpref{wxDb constructor}{wxdbctor}). Default setting of this value true, as not all databases/drivers support both types of cursors. @@ -319,7 +324,7 @@ This function is used to request a "new" wxDb instance for use by the program. 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 @@ -355,7 +360,7 @@ cached connections created by calls to wxDbGetConnection(). \func{const wxChar *}{wxDbLogExtendedErrorMsg}{\param{const wxChar *}{userText}, \param{wxDb *}{pDb}, \param{wxChar *}{ErrFile}, \param{int }{ErrLine}} Writes a message to the wxLog window (stdout usually) when an internal -error situation occurs. This function only works in DEBUG builds +error situation occurs. \func{bool}{wxDbSqlLog}{\param{wxDbSqlLogState }{state}, \param{const wxString \&}{filename = SQL\_LOG\_FILENAME}} @@ -372,15 +377,15 @@ datasources. Repeatedly call this function to obtain all the datasources available through the ODBC driver manager on the current workstation. \begin{verbatim} - wxStringList strList; + wxArrayString strArray; while (wxDbGetDataSource(DbConnectInf.GetHenv(), Dsn, SQL_MAX_DSN_LENGTH+1, DsDesc, 255)) - strList.Add(Dsn); + strArray.Add(Dsn); \end{verbatim} \latexignore{\rtfignore{\wxheading{Members}}} -\membersection{wxDb::wxDb}\label{wxdbconstr} +\membersection{wxDb::wxDb}\label{wxdbctor} \func{}{wxDb}{\void} @@ -571,7 +576,7 @@ of a datasource which does support views. \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. @@ -596,7 +601,7 @@ Possible values returned by this function can be viewed in the \helpref{Enumerated types}{wxdbenumeratedtypes} section of wxDb. There are known issues with conformance to the ODBC standards with several -datasources supported by the wxWindows ODBC classes. Please see the overview +datasources supported by the wxWidgets ODBC classes. Please see the overview for specific details on which datasource have which issues. \wxheading{Return value} @@ -706,16 +711,43 @@ Drops the data table view named in 'viewName'. If the view does not exist, this function will return true. Note that views are not supported with all datasources. +\membersection{wxDb::EscapeSqlChars}\label{wxdbescapesqlchars} + +\func{wxString}{EscapeSqlChars}{\param{const wxString\& }{value}} + +This function is used internally by wxWidgets while building SQL statements. +It has been provided to help users who wish to explicity construct SQL +statements to be sent to the server. The function takes the value passed and +returns it with any special characters escaped. Which characters are +considered special depends on what type of datasource the object is connected +to. For example, most database servers use a backslash as the escape +character; if the value passed contains a backlash it will be replaced with a +double backslash before it is passed to the server. This function can be used +to avoid passing statements with syntax errors to the server as well as prevent +SQL injection attacks. + +\wxheading{Parameters} + +\docparam{value}{The value to be escaped.} + \membersection{wxDb::ExecSql}\label{wxdbexecsql} \func{bool}{ExecSql}{\param{const wxString \&}{pSqlStmt}} +\func{bool}{ExecSql}{\param{const wxString \&}{pSqlStmt}, \param{wxDbColInf **}{columns}, \param{short \&}{numcols}} + 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. +To get column amount and column names or other information about returned columns, pass {\it 'columns'} and {\it 'numcols'} parameters to the function also. + \wxheading{Parameters} \docparam{pSqlStmt}{Pointer to the SQL statement to be executed.} +\docparam{columns}{On success, this function will set this pointer to point to array of \helpref{wxDbColInf}{wxdbcolinf} objects, holding information about columns returned by the query. You need to call delete[] for the pointer you pass here after you don't use it anymore to prevent memory leak.} + +\docparam{numcols}{Reference to variable where amount of objects in {\it 'columns'}-parameter will be set.} + \wxheading{Remarks} This member extends the wxDb class and allows you to build and execute ANY VALID @@ -731,7 +763,7 @@ of processing. \func{bool}{IsFwdOnlyCursors}{\void} -Older form (pre-2.3/2.4 of wxWindows) of the +Older form (pre-2.3/2.4 of wxWidgets) of the \helpref{wxDb::IsFwdOnlyCursors}{wxdbisfwdonlycursors}. This method is provided for backward compatibility only. The method \helpref{wxDb::IsFwdOnlyCursors}{wxdbisfwdonlycursors} should be @@ -841,7 +873,7 @@ to avoid undesired unbinding of columns.} \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 @@ -849,7 +881,7 @@ variables (i.e. not using a wxDbTable instance to access table data). \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}} @@ -941,7 +973,7 @@ Returns the ODBC statement handle associated with this database connection. \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. @@ -951,7 +983,7 @@ This function is primarily for use by the \helpref{wxDb::GetColumns}{wxdbgetcolu \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} @@ -1083,7 +1115,7 @@ 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 value of wxODBC\_FWD\_ONLY\_CURSORS. This default setting can be overridden when the wxDb connection is initially created (see -\helpref{wxDb constructor}{wxdbconstr} and \helpref{wxDbGetConnection}{wxdbfunctions}). +\helpref{wxDb constructor}{wxdbctor} and \helpref{wxDbGetConnection}{wxdbfunctions}). \wxheading{Return value} @@ -1093,17 +1125,17 @@ use backward scrolling cursors and their associated functions (see note above). \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 +Added as of wxWidgets v2.4 release, this function is a renamed version of +wxDb::FwdOnlyCursors() to match the normal wxWidgets 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 +use \helpref{wxDb::FwdOnlyCursors}{wxdbfwdonlycursors} for wxWidgets versions prior to 2.4. \wxheading{See also} -\helpref{wxDb constructor}{wxdbconstr}, \helpref{wxDbGetConnection}{wxdbfunctions} +\helpref{wxDb constructor}{wxdbctor}, \helpref{wxDbGetConnection}{wxdbfunctions} \membersection{wxDb::IsOpen}\label{wxdbisopen} @@ -1185,7 +1217,13 @@ used for behavioral descriptions. \membersection{wxDb::Open}\label{wxdbopen} \func{bool}{Open}{\param{const wxString \&}{Dsn}, \param{const wxString \&}{Uid}, -\param{const wxString \&}{AuthStr}} +\param{const wxString \&}{AuthStr}, \param{bool }{failOnDataTypeUnsupported}} + +\func{bool}{Open}{\param{const wxString \&}{inConnectStr}, +\param{bool }{failOnDataTypeUnsupported}} + +\func{bool}{Open}{\param{wxDbConnectInf *}{dbConnectInf}, +\param{bool }{failOnDataTypeUnsupported}} \func{bool}{Open}{\param{wxDb *}{copyDb}} @@ -1222,9 +1260,25 @@ 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 with the Uid.} -\docparam{copyDb}{Already completely configured and opened datasource connection -from which all Dsn, Uid, AuthStr, and data typing information is to be copied -from for use by this datasource connection.} +\docparam{failOnDataTypeUnsupporte}{As part of connecting to a database, the +wxDb::Open() function will query the database to find out the native types +that it supports. With some databases, some data types may not be supported, +or not sufficiently supported, for use with the wxODBC classes. Normally +a program should fail in this case, so as not to try to use a data type +that is not supported. This parameter allows the programmer to override the +failure if they wish and continue on using the connection.} +\docparam{dbConnectInf}{Contains a DSN, Uid, Password, or a connection string +to be used in opening a new connection to the database. If a connection +string is present, then the connection string will be used. If there is no +connection string present, then the DSN, Uid, and Password are used.} +\docparam{inConnectStr}{A valid ODBC connection string used to connect to a +database} +\docparam{copyDb}{Already completely configured and opened datasource +connection from which all Dsn, Uid, AuthStr, connection string, and data +typing information is to be copied from for use by this datasource +connection. If 'copyDb' used a connection string to create its connection +originally, then the connection being made by this call to wxDb::Open() will +use that same connection string.} \wxheading{Remarks} @@ -1313,7 +1367,7 @@ When compiled in release mode (FINAL=1), this setting has no affect. \wxheading{See also} -\helpref{wxDb constructor}{wxdbconstr} +\helpref{wxDb constructor}{wxdbctor} \membersection{wxDb::SetSqlLogging}\label{wxdbsetsqllogging} @@ -1333,7 +1387,7 @@ When called with {\it sqlLogOFF}, the logging file is closed, and any calls to \ \membersection{wxDb::SQLColumnName}\label{wxdbsqlcolumnname} -\func{const wxString}{SQLColumnName}{\param{const char *}{ colName}} +\func{const wxString}{SQLColumnName}{\param{const wxChar *}{ colName}} Returns the column name in a form ready for use in SQL statements. In most cases, the column name is returned verbatim. But some databases @@ -1355,7 +1409,7 @@ before including the column name in a SQL statement} \membersection{wxDb::SQLTableName}\label{wxdbsqltablename} -\func{const wxString}{SQLTableName}{\param{const char *}{ tableName}} +\func{const wxString}{SQLTableName}{\param{const wxChar *}{ tableName}} Returns the table name in a form ready for use in SQL statements. In most cases, the table name is returned verbatim. But some databases @@ -1421,7 +1475,7 @@ at least minimal privileges to the table). \docparam{tableName}{Name of the table on which to check privileges. {\it tableName} may refer to a table, view, alias or synonym.} \docparam{priv}{The table privilege being evaluated. May be one of the -following (or a datasource specific privilege): +following (or a datasource specific privilege):} \begin{verbatim} SELECT : The connected user is permitted to retrieve data for @@ -1442,28 +1496,29 @@ following (or a datasource specific privilege): example, a unique, referential, or table check constraint). \end{verbatim} -} + \docparam{userID}{{\it OPTIONAL.} User for which to determine if the privilege specified to be checked is granted or not. Default is "". -{\it userID} is evaluated as follows: +{\it userID} is evaluated as follows:} \begin{verbatim} userID == NULL ... NOT ALLOWED! userID == "" ... UserID set equal to 'this->uid' userID != "" ... UserID set equal to 'userID' \end{verbatim} -} + \docparam{schema}{{\it OPTIONAL.} 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. Specifying the table owner makes determination of the -users privileges MUCH faster. Default is NULL. {\it userID} is evaluated as follows: +users privileges MUCH faster. Default is NULL. {\it userID} is +evaluated as follows:} \begin{verbatim} schema == NULL ... Any owner (DEFAULT) schema == "" ... Owned by 'this->uid' schema != "" ... Owned by userID specified in 'schema' \end{verbatim} -} + \docparam{path}{{\it OPTIONAL.} Path to the table. Default is "". Currently unused.} @@ -1542,7 +1597,7 @@ This class is used to hold information about the columns bound to an instance of a wxDbTable object. Each instance of this class describes one column in the wxDbTable -object. When calling the \helpref{wxDb constructor}{wxdbconstr}, a +object. When calling the \helpref{wxDb constructor}{wxdbctor}, a parameter passed in indicates the number of columns that will be defined for the wxDbTable object. The constructor uses this information to allocate adequate memory for all of the column descriptions in your wxDbTable object. @@ -1579,7 +1634,13 @@ public. \wxheading{See also} \helpref{database classes overview}{odbcoverview}, -\helpref{wxDbTable::GetColDefs}{wxdbtablegetcoldefs}, \helpref{wxDb constructor}{wxdbconstr} +\helpref{wxDbTable::GetColDefs}{wxdbtablegetcoldefs}, \helpref{wxDb constructor}{wxdbctor} + +\wxheading{Include files} + + + +\latexignore{\rtfignore{\wxheading{Members}}} \membersection{wxDbColDef::Initialize}\label{wxdbcoldefinitialize} @@ -1592,12 +1653,12 @@ Beginning support for handling international formatting specifically on dates and floats. \begin{verbatim} - wxString s_Field; // Formated String for Output - wxString s_Format[7]; // Formated Objects - TIMESTAMP has + wxString s_Field; // Formatted String for Output + wxString s_Format[7]; // Formatted Objects - TIMESTAMP has the biggest (7) - wxString s_Amount[7]; // Formated Objects - amount of + wxString s_Amount[7]; // Formatted Objects - amount of things that can be formatted - int i_Amount[7]; // Formated Objects - + int i_Amount[7]; // Formatted Objects - TT MM YYYY HH MM SS m int i_Nation; // 0 = timestamp 1 = EU @@ -1619,6 +1680,16 @@ Only one function is provided with this class currently. See the \helpref{database classes overview}{odbcoverview} for an introduction to using the ODBC classes. +\wxheading{Include files} + + + +\wxheading{Library} + +\helpref{wxOdbc}{librarieslist} + +\latexignore{\rtfignore{\wxheading{Members}}} + \membersection{wxDbColFor::Format}\label{wxdbcolforformat} \func{int }{Format}{\param{int }{Nation}, \param{int }{dbDataType}, @@ -1675,6 +1746,16 @@ it is non-NULL. See the \helpref{database classes overview}{odbcoverview} for an introduction to using the ODBC classes. +\wxheading{Include files} + + + +\wxheading{Library} + +\helpref{wxOdbc}{librarieslist} + +\latexignore{\rtfignore{\wxheading{Members}}} + \membersection{wxDbColInf::Initialize}\label{wxdbcolinfinitialize} Simply initializes all member variables to a cleared state. Called by @@ -1688,7 +1769,7 @@ name, user ID, password and default directory path (used with dBase). Other optional fields held in this class are and file type, both for future functions planned to be added for creating/manipulating datasource definitions. -\membersection{wxDbConnectInf::wxDbConnectInf} +\membersection{wxDbConnectInf::wxDbConnectInf}\label{wxdbconnectinfctor} \func{}{wxDbConnectInf}{\void} @@ -1707,15 +1788,15 @@ one in to the function. \wxheading{Parameters} -\docparam{henv}{Environment handle used for this connection. See +\docparam{henv}{Environment handle used for this connection. See\rtfsp \helpref{wxDConnectInf::AllocHenv}{wxdbconnectinfallochenv} for how to create an SQL environment handle. NOTE: Passing in a NULL for this parameter will inform the constructor that it should create its own SQL environment handle. -If NULL is passed for this parameter, the constructor will call +If NULL is passed for this parameter, the constructor will call\rtfsp \helpref{wxDConnectInf::AllocHenv}{wxdbconnectinfallochenv} internally. A flag is set internally also to indicate that the HENV was created by the constructor so that when the default class destructor is called, the -destructor will call \helpref{wxDConnectInf::FreeHenv}{wxdbconnectinffreehenv} +destructor will call \helpref{wxDConnectInf::FreeHenv}{wxdbconnectinffreehenv}\rtfsp to free the environment handle automatically.} \docparam{dsn}{Name of the datasource to be used in creating wxDb instances for creating connection(s) to a datasource.} @@ -1759,7 +1840,7 @@ automatically, and manage the destruction of the handle. Handles the default destruction of the instance of the class. If the long form of the \helpref{wxDConnectInf}{wxdbconnectinf} was used, then this destructor -also takes care of calling +also takes care of calling\rtfsp \helpref{wxDConnectInf::FreeHenv}{wxdbconnectinffreehenv} to free the SQL environment handle. @@ -1783,10 +1864,10 @@ Frees the SQL environment handle being managed by the instance of this class. \wxheading{Remarks} -If the SQL environment handle was created using the long form of the +If the SQL environment handle was created using the long form of the\rtfsp \helpref{wxDbConnectInf}{wxdbconnectinf} constructor, then the flag indicating that the HENV should be destroyed when the classes destructor is called -is reset to be false, so that any future handles created using the +is reset to be false, so that any future handles created using the\rtfsp \helpref{wxDbConnectInf::AllocHenv}{wxdbconnectinfallochenv} function must be manually released with a call to this function. @@ -1954,6 +2035,15 @@ There are no constructors/destructors as of this time, and no member functions. See the \helpref{database classes overview}{odbcoverview} for an introduction to using the ODBC classes. + +\wxheading{Include files} + + + +\wxheading{Library} + +\helpref{wxOdbc}{librarieslist} + \section{\class{wxDbInf}}\label{wxdbinf} Contains information regarding the database connection (datasource name, @@ -1962,7 +2052,7 @@ 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. -Primarily, this class is used internally by the wxWindows ODBC classes. +Primarily, this class is used internally by the wxWidgets ODBC classes. \begin{verbatim} wxChar catalog[128+1]; @@ -1981,6 +2071,16 @@ it is non-NULL. See the \helpref{database classes overview}{odbcoverview} for an introduction to using the ODBC classes. +\wxheading{Include files} + + + +\wxheading{Library} + +\helpref{wxOdbc}{librarieslist} + +\latexignore{\rtfignore{\wxheading{Members}}} + \membersection{wxDbInf::Initialize}\label{wxdbinfinitialize} Simply initializes all member variables to a cleared state. Called by @@ -1998,6 +2098,10 @@ an introduction to using the ODBC classes. \\ +\wxheading{Library} + +\helpref{wxOdbc}{librarieslist} + \latexignore{\rtfignore{\wxheading{Members}}} \wxheading{Helper classes and data structures} @@ -2144,7 +2248,7 @@ this function. 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. @@ -2160,9 +2264,9 @@ by this function. \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} @@ -2175,9 +2279,10 @@ WHERE and FROM clauses specified using \helpref{wxDbTable::SetWhereClause}{wxdbt and \helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} are ignored by this function. -\membersection{wxDbTable::BuildWhereStmt}\label{wxdbtablebuildwherestmt} -\func{void}{BuildSelectStmt}{\param{wxString \&}{pWhereClause}, +\membersection{wxDbTable::BuildWhereClause}\label{wxdbtablebuildwhereclause} + +\func{void}{BuildWhereClause}{\param{wxString \&}{pWhereClause}, \param{int }{typeOfWhere}, \param{const wxString \&}{qualTableName=""}, \param{bool }{useLikeComparison=false}} @@ -2210,6 +2315,7 @@ If using 'typeOfWhere' set to DB\_WHERE\_MATCHING, any bound columns currently containing a NULL value are not included in the WHERE clause's list of columns to use in the comparison. + \membersection{wxDbTable::CanSelectForUpdate}\label{wxdbtablecanselectforupdate} \func{bool}{CanSelectForUpdate}{\void} @@ -2264,26 +2370,26 @@ to an Oracle datasource or not. // 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, @@ -2390,11 +2496,11 @@ this function. \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{wxDbIdxDef *}{pIndexDefs}, \param{bool }{attemptDrop=true}} -This member function allows you to create secondary (non primary) indexes on +This member function allows you to create secondary (non-primary) indexes on your tables. You first create your table, normally specifying a primary index, and then create any secondary indexes on the table. Indexes in relational model are not required. You do not need indexes to look up records @@ -2406,11 +2512,11 @@ take advantage of those indexes. \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{wxDbIdxDef}{wxdbidxdef} 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.} @@ -2420,7 +2526,7 @@ 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 @@ -2429,12 +2535,12 @@ indexes from being inserted into the table when violating a unique index's 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{wxDbIdxDef}{wxdbidxdef} 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{wxDbIdxDef}{wxdbidxdef} structure. The fifth parameter is provided to handle the differences in datasources as to whether they will automatically overwrite existing indexes with the same @@ -2459,18 +2565,18 @@ after executing this function. \begin{verbatim} // Create a secondary index on the PARTS table - wxDbIdxDef idxDef[2]; // 2 columns make up the index + wxDbIdxDef 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} @@ -2668,18 +2774,18 @@ this function. \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} @@ -2719,7 +2825,7 @@ of this function). \wxheading{Parameters} -\docparam{From}{A comma separated list of table names that are to be outer +\docparam{From}{A comma separated list of table names that are to be inner joined with the base table's columns so that the joined table's columns may be returned in the result set or used as a portion of a comparison with the base table's columns. NOTE that the base tables name must NOT be included @@ -3040,20 +3146,20 @@ this function to commit or rollback the insertion. \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.} \wxheading{Remarks} -NULL column support is currently not fully implemented as of wxWindows 2.4. +NULL column support is currently not fully implemented as of wxWidgets 2.4. \membersection{wxDbTable::IsCursorClosedOnCommit}\label{wxdbtableiscursorclosedoncommit} @@ -3094,6 +3200,13 @@ cursors, (insert/select and update if connection is not wxDB\_QUERY\_ONLY) and constructs the insert statement that is to be used for inserting data as a new row in the datasource. +NOTE: To retrieve data into an opened table, the of the table must be bound +to the variables in the program via call(s) to +\helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs} before calling Open(). + +See the \helpref{database classes overview}{odbcoverview} for +an introduction to using the ODBC classes. + \wxheading{Parameters} \docparam{checkPrivileges}{Indicates whether the Open() function should check @@ -3127,6 +3240,7 @@ function can significantly speed up the privileges checks. \helpref{wxDb::TableExists}{wxdbtableexists}, \helpref{wxDb::TablePrivileges}{wxdbtableprivileges} +\helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs} \membersection{wxDbTable::OrderBy}\label{wxdbtableorderby} @@ -3186,7 +3300,7 @@ records to be retrieved (e.g. All users with a first name of "JOHN"). Use \helpref{wxDbTable::SetOrderByClause}{wxdbtablesetorderbyclause} to change the sequence in which records are returned in the result set from the datasource (e.g. Ordered by LAST\_NAME). Use -\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} to allow outer +\helpref{wxDbTable::SetFromClause}{wxdbtablesetfromclause} to allow inner joining of the base table (the one being associated with this instance of wxDbTable) with other tables which share a related field. @@ -3274,7 +3388,7 @@ wxDbTable constructor, it is specified how many columns are in the wxDbTable object. The SELECT statement must return exactly that many columns. \item The columns must be returned in the same sequence as specified -when defining the bounds columns using wxDbTable::SetColDefs(), +when defining the bounds columns \helpref{wxDbTable::SetColDefs}{wxdbtablesetcoldefs}, and the columns returned must be of the proper data type. For example, if column 3 is defined in the wxDbTable bound column definitions to be a float, the SELECT statement must return a @@ -3282,7 +3396,7 @@ float for column 3 (e.g. PRICE * 1.10 to increase the price by 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. @@ -3322,7 +3436,7 @@ either \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} or ---------------------- // 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 @@ -3332,10 +3446,10 @@ either \helpref{wxDbTable::GetFirst}{wxdbtablegetfirst} or 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 @@ -3481,10 +3595,10 @@ table's columns are refreshed to reflect the current data in the database. \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}} @@ -3501,6 +3615,8 @@ wxDbTable constructor was called.} DB_DATA_TYPE_INTEGER : non-floating point numbers DB_DATA_TYPE_FLOAT : floating point numbers DB_DATA_TYPE_DATE : dates + DB_DATA_TYPE_BLOB : binary large objects + DB_DATA_TYPE_MEMO : large strings \end{verbatim} \docparam{pData}{Pointer to the data object that will hold the column's @@ -3510,7 +3626,8 @@ representation of the data is converted to to be stored in {\it pData}. 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 @@ -3527,11 +3644,11 @@ Other valid types are available also, but these are the most common ones:} \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 @@ -3544,6 +3661,14 @@ to by {\it colInfs}, which are to have column definitions created from them.} 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. @@ -3560,10 +3685,10 @@ were to be copied over to another datasource or table. \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; @@ -3571,13 +3696,13 @@ were to be copied over to another datasource or table. 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} -\func{bool}{SetCursor}{\param{HSTMT *}{hstmtActivate = (void **) wxDB\_DEFAULT\_CURSOR}} +\func{void}{SetCursor}{\param{HSTMT *}{hstmtActivate = (void **) wxDB\_DEFAULT\_CURSOR}} \wxheading{Parameters} @@ -3609,14 +3734,14 @@ and saving a pointer to that cursor. \func{void}{SetFromClause}{\param{const wxString \&}{From}} Accessor function for setting the private class member wxDbTable::from -that indicates what other tables should be outer joined with the wxDbTable's +that indicates what other tables should be inner joined with the wxDbTable's base table for access to the columns in those other tables. Synonym to this function is one form of \helpref{wxDbTable::From}{wxdbtablefrom} \wxheading{Parameters} -\docparam{From}{A comma separated list of table names that are to be outer +\docparam{From}{A comma separated list of table names that are to be inner joined with the base table's columns so that the joined table's columns may be returned in the result set or used as a portion of a comparison with the base table's columns. NOTE that the base tables name must NOT be included @@ -3626,7 +3751,7 @@ in constructing query statements.} \wxheading{Remarks} Used by the \helpref{wxDbTable::Query}{wxdbtablequery} and -\helpref{wxDbTable::Count}{wxdbtablecount} member functions to allow outer +\helpref{wxDbTable::Count}{wxdbtablecount} member functions to allow inner joining of records from multiple tables. Do {\bf not} include the keyword "FROM" when setting the FROM clause. @@ -3641,7 +3766,7 @@ the datasource knows on which column values the tables should be joined on. \begin{verbatim} ... // Base table is the "LOCATION" table, and it is being - // outer joined to the "PART" table via the the field "PART_NUMBER" + // inner joined to the "PART" table via the field "PART_NUMBER" // that can be related between the two tables. location->SetWhereClause("LOCATION.PART_NUMBER = PART.PART_NUMBER") location->SetFromClause("PART"); @@ -3655,7 +3780,7 @@ the datasource knows on which column values the tables should be joined on. \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}} @@ -3669,7 +3794,7 @@ the actual column name to be specified. \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 @@ -3775,7 +3900,7 @@ Do {\bf not} include the keywords "WHERE" when setting the WHERE clause. // Using parameters and multiple logical combinations parts->Where("((QTY > 10) OR (ON_ORDER > 0)) AND ON_HOLD = 0"); ... - // This query uses an outer join (requiring a FROM clause also) + // This query uses an inner join (requiring a FROM clause also) // that joins the PART and LOCATION table on he common field // PART_NUMBER. parts->Where("PART.ON_HOLD = 0 AND \ @@ -3925,6 +4050,16 @@ Eventually, accessor functions will be added for this class See the \helpref{database classes overview}{odbcoverview} for an introduction to using the ODBC classes. +\wxheading{Include files} + + + +\wxheading{Library} + +\helpref{wxOdbc}{librarieslist} + +\latexignore{\rtfignore{\wxheading{Members}}} + \membersection{wxDbTableInf::Initialize}\label{wxdbtableinfinitialize} Simply initializes all member variables to a cleared state. Called by @@ -3943,11 +4078,15 @@ an introduction to using the wxDbGrid classes. +\wxheading{Library} + +\helpref{wxDbgrid}{librarieslist} + \latexignore{\rtfignore{\wxheading{Members}}} -\membersection{wxDbGridColInfo::wxDbGridColInfo}\label{wxdbgridcolinfo} +\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 @@ -3956,7 +4095,7 @@ see two different ways for adding columns. \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} @@ -3965,7 +4104,7 @@ construction, NULL terminates the list. Use Null also if using two step constru See the database grid example in \helpref{wxDbGridTableBase}{wxdbgridtablebase} to see two different ways for adding columns. -\membersection{wxDbGridColInfo::\destruct{wxDbGridColInfo}} +\membersection{wxDbGridColInfo::\destruct{wxDbGridColInfo}}\label{wxdbgridcolinfodtor} \func{}{\destruct{wxDbGridColInfo}}{} @@ -3973,7 +4112,7 @@ Destructor. \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 @@ -3985,7 +4124,7 @@ constructor. Changes made to this datatype after the \helpref{wxDbGridTableBase} 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} @@ -3997,7 +4136,7 @@ info structure as this is the structure which informs the grid of how you want t \helpref{wxDbTable}{wxdbtable}. If no datatype conversion or the referenced column number does not exist the the behavior is undefined. -See the example at \helpref{wxDbGridColInfo::wxDbGridColInfo}{wxdbgridcolinfo}. +See the example at \helpref{wxDbGridColInfo::wxDbGridColInfo}{wxdbgridcolinfoctor}. \section{\class{wxDbGridTableBase}}\label{wxdbgridtablebase} @@ -4022,6 +4161,10 @@ that the client keeps ownership. +\wxheading{Library} + +\helpref{wxDbgrid}{librarieslist} + \wxheading{Example}