1 \section{\class{wxRecordSet
}}\label{wxrecordset
} 
   3 Each wxRecordSet represents an ODBC database query. You can make multiple queries
 
   4 at a time by using multiple wxRecordSets with a wxDatabase or you can make
 
   5 your queries in sequential order using the same wxRecordSet.
 
   7 Note: this class is considered obsolete, replaced by the Remstar 
 
  10 \wxheading{Derived from
} 
  12 \helpref{wxObject
}{wxobject
} 
  14 \wxheading{Include files
} 
  20 \helpref{wxRecordSet overview
}{wxrecordsetoverview
}, 
\helpref{wxDatabase overview
}{wxdatabaseoverview
} 
  22 \latexignore{\rtfignore{\wxheading{Members
}}} 
  24 \membersection{wxRecordSet::wxRecordSet
} 
  26 \func{}{wxRecordSet
}{\param{wxDatabase *
}{db
}, 
\param{int
}{ type = wxOPEN
\_TYPE\_DYNASET},
 
  27  \param{int
}{ opt = wxOPTION
\_DEFAULT}} 
  29 Constructor. 
{\it db
} is a pointer to the wxDatabase instance you wish to use the
 
  30 wxRecordSet with. Currently there are two possible values of 
{\it type
}:
 
  32 \begin{itemize
}\itemsep=
0pt
 
  33 \item wxOPEN
\_TYPE\_DYNASET: Loads only one record at a time into memory. The other
 
  34 data of the result set will be loaded dynamically when
 
  35 moving the cursor. This is the default type.
 
  36 \item wxOPEN
\_TYPE\_SNAPSHOT: Loads all records of a result set at once. This will
 
  37 need much more memory, but will result in
 
  38 faster access to the ODBC data.
 
  41 The 
{\it option
} parameter is not used yet.
 
  43 The constructor appends the wxRecordSet object to the parent database's list of
 
  44 wxRecordSet objects, for later destruction when the wxDatabase is destroyed.
 
  46 \membersection{wxRecordSet::
\destruct{wxRecordSet
}} 
  48 \func{}{\destruct{wxRecordSet
}}{\void} 
  50 Destructor. All data except that stored in user-defined variables will be lost.
 
  51 It also unlinks the wxRecordSet object from the parent database's list of
 
  54 \membersection{wxRecordSet::AddNew
} 
  56 \func{void
}{AddNew
}{\void} 
  60 \membersection{wxRecordSet::BeginQuery
} 
  62 \func{bool
}{BeginQuery
}{\param{int
}{ openType
}, 
\param{const wxString\& 
}{sql = NULL
}, 
\param{int
}{ options = wxOPTION
\_DEFAULT}} 
  66 \membersection{wxRecordSet::BindVar
} 
  68 \func{void *
}{BindVar
}{\param{int
}{ col
}, 
\param{void *
}{buf
}, 
\param{long
}{ size
}} 
  70 Binds a user-defined variable to the column col. Whenever the current field's
 
  71 data changes, it will be copied into buf (maximum 
{\it size
} bytes).
 
  73 \func{void *
}{BindVar
}{\param{const wxString\& 
}{col
}, 
\param{void *
}{buf
}, 
\param{long
}{ size
}} 
  75 The same as above, but uses the column name as the identifier.
 
  77 \membersection{wxRecordSet::CanAppend
} 
  79 \func{bool
}{CanAppend
}{\void} 
  83 \membersection{wxRecordSet::Cancel
} 
  85 \func{void
}{Cancel
}{\void} 
  89 \membersection{wxRecordSet::CanRestart
} 
  91 \func{bool
}{CanRestart
}{\void} 
  95 \membersection{wxRecordSet::CanScroll
} 
  97 \func{bool
}{CanScroll
}{\void} 
 101 \membersection{wxRecordSet::CanTransact
} 
 103 \func{bool
}{CanTransact
}{\void} 
 107 \membersection{wxRecordSet::CanUpdate
} 
 109 \func{bool
}{CanUpdate
}{\void} 
 113 \membersection{wxRecordSet::ConstructDefaultSQL
} 
 115 \func{bool
}{ConstructDefaultSQL
}{\void} 
 119 \membersection{wxRecordSet::Delete
} 
 121 \func{bool
}{Delete
}{\void} 
 123 Deletes the current record. Not implemented.
 
 125 \membersection{wxRecordSet::Edit
} 
 127 \func{void
}{Edit
}{\void} 
 131 \membersection{wxRecordSet::EndQuery
} 
 133 \func{bool
}{EndQuery
}{\void} 
 137 \membersection{wxRecordSet::ExecuteSQL
}\label{wxrecordsetexecutesql
} 
 139 \func{bool
}{ExecuteSQL
}{\param{const wxString\& 
}{sql
}} 
 141 Directly executes a SQL statement. The data will be presented as a normal
 
 142 result set. Note that the recordset must have been created as a snapshot, not
 
 143 dynaset. Dynasets will be implemented in the near future.
 
 145 Examples of common SQL statements are given in 
\helpref{A selection of SQL commands
}{sqlcommands
}.
 
 147 \membersection{wxRecordSet::FillVars
} 
 149 \func{void
}{FillVars
}{\param{int
}{ recnum
}} 
 151 Fills in the user-defined variables of the columns. You can set these
 
 152 variables with wxQueryCol::BindVar. This function will be automatically
 
 153 called after every successful database operation.
 
 155 \membersection{wxRecordSet::GetColName
} 
 157 \func{wxString
}{GetColName
}{\param{int
}{ col
}} 
 159 Returns the name of the column at position 
{\it col
}. Returns NULL if 
{\it col
} does not
 
 162 \membersection{wxRecordSet::GetColType
} 
 164 \func{short
}{GetColType
}{\param{int
}{ col
}} 
 166 Returns the data type of the column at position 
{\it col
}. Returns SQL
\_TYPE\_NULL 
 167 if 
{\it col
} does not exist.
 
 169 \func{short
}{GetColType
}{\param{const wxString\& 
}{ name
}} 
 171 The same as above, but uses the column name as the identifier.
 
 173 See 
\helpref{ODBC SQL data types
}{sqltypes
} for a list
 
 174 of possible data types.
 
 176 \membersection{wxRecordSet::GetColumns
} 
 178 \func{bool
}{GetColumns
}{\param{const wxString\& 
}{table = NULL
}} 
 180 Returns the columns of the table with the specified name. If no name is
 
 181 given the class member 
{\it tablename
} will be used. If both names are NULL
 
 182 nothing will happen. The data will be presented as a normal result set, organized
 
 185 \begin{twocollist
}\itemsep=
0pt
 
 186 \twocolitem{0 (VARCHAR)
}{TABLE
\_QUALIFIER} 
 187 \twocolitem{1 (VARCHAR)
}{TABLE
\_OWNER} 
 188 \twocolitem{2 (VARCHAR)
}{TABLE
\_NAME} 
 189 \twocolitem{3 (VARCHAR)
}{COLUMN
\_NAME} 
 190 \twocolitem{4 (SMALLINT)
}{DATA
\_TYPE} 
 191 \twocolitem{5 (VARCHAR)
}{TYPE
\_NAME} 
 192 \twocolitem{6 (INTEGER)
}{PRECISION
} 
 193 \twocolitem{7 (INTEGER)
}{LENGTH
} 
 194 \twocolitem{8 (SMALLINT)
}{SCALE
} 
 195 \twocolitem{9 (SMALLINT)
}{RADIX
} 
 196 \twocolitem{10 (SMALLINT)
}{NULLABLE
} 
 197 \twocolitem{11 (VARCHAR)
}{REMARKS
} 
 200 \membersection{wxRecordSet::GetCurrentRecord
} 
 202 \func{long
}{GetCurrentRecord
}{\void} 
 206 \membersection{wxRecordSet::GetDatabase
} 
 208 \func{wxDatabase *
}{GetDatabase
}{\void} 
 210 Returns the wxDatabase object bound to a wxRecordSet.
 
 212 \membersection{wxRecordSet::GetDataSources
}\label{wxrecordsetgetdatasources
} 
 214 \func{bool
}{GetDataSources
}{\void} 
 216 Gets the currently-defined data sources via the ODBC manager. The data will be presented
 
 217 as a normal result set. See the documentation for the ODBC function SQLDataSources for how the data
 
 225   wxRecordSet *Record = new wxRecordSet(&Database);
 
 227   if (!Record->GetDataSources()) 
{ 
 229     sprintf(buf, "
%s %s\n", Database.GetErrorClass(), Database.GetErrorMessage()); 
 230     frame->output->SetValue(buf);
 
 234       frame->DataSource->Append((char*)Record->GetFieldDataPtr(
0, SQL_CHAR));
 
 235     } while (Record->MoveNext());
 
 239 \membersection{wxRecordSet::GetDefaultConnect
} 
 241 \func{wxString
}{GetDefaultConnect
}{\void} 
 245 \membersection{wxRecordSet::GetDefaultSQL
} 
 247 \func{wxString
}{GetDefaultSQL
}{\void} 
 251 \membersection{wxRecordSet::GetErrorCode
} 
 253 \func{wxRETCODE
}{GetErrorCode
}{\void} 
 255 Returns the error code of the last ODBC action. This will be one of:
 
 257 \begin{twocollist
}\itemsep=
0pt
 
 258 \twocolitem{SQL
\_ERROR}{General error.
} 
 259 \twocolitem{SQL
\_INVALID\_HANDLE}{An invalid handle was passed to an ODBC function.
} 
 260 \twocolitem{SQL
\_NEED\_DATA}{ODBC expected some data.
} 
 261 \twocolitem{SQL
\_NO\_DATA\_FOUND}{No data was found by this ODBC call.
} 
 262 \twocolitem{SQL
\_SUCCESS}{The call was successful.
} 
 263 \twocolitem{SQL
\_SUCCESS\_WITH\_INFO}{The call was successful, but further information can be
 
 264 obtained from the ODBC manager.
} 
 267 \membersection{wxRecordSet::GetFieldData
}\label{wxrecordsetgetfielddata
} 
 269 \func{bool
}{GetFieldData
}{\param{int
}{ col
}, 
\param{int
}{ dataType
}, 
\param{void *
}{dataPtr
}} 
 271 Copies the current data of the column at position 
{\it col
} into the buffer
 
 272 \rtfsp{\it dataPtr
}. To be sure to get the right type of data, the user has to pass the
 
 273 correct data type. The function returns false if 
{\it col
} does not
 
 274 exist or the wrong data type was given.
 
 276 \func{bool
}{GetFieldData
}{\param{const wxString\& 
}{name
}, 
\param{int
}{ dataType
}, 
\param{void *
}{dataPtr
}} 
 278 The same as above, but uses the column name as the identifier.
 
 280 See 
\helpref{ODBC SQL data types
}{sqltypes
} for a list
 
 281 of possible data types.
 
 283 \membersection{wxRecordSet::GetFieldDataPtr
}\label{wxrecordsetgetfielddataptr
} 
 285 \func{void *
}{GetFieldDataPtr
}{\param{int
}{ col
}, 
\param{int
}{ dataType
}} 
 287 Returns the current data pointer of the column at position 
{\it col
}.
 
 288 To be sure to get the right type of data, the user has to pass the
 
 289 data type. Returns NULL if 
{\it col
} does not exist or if 
{\it dataType
} is
 
 292 \func{void *
}{GetFieldDataPtr
}{\param{const wxString\& 
}{name
}, 
\param{int
}{ dataType
}} 
 294 The same as above, but uses the column name as the identifier.
 
 296 See 
\helpref{ODBC SQL data types
}{sqltypes
} for a list
 
 297 of possible data types.
 
 299 \membersection{wxRecordSet::GetFilter
} 
 301 \func{wxString
}{GetFilter
}{\void} 
 303 Returns the current filter.
 
 305 \membersection{wxRecordSet::GetForeignKeys
} 
 307 \func{bool
}{GetPrimaryKeys
}{\param{const wxString\& 
}{ptable = NULL
}, 
\param{const wxString\& 
}{ftable
 
 310 Returns a list of foreign keys in the specified table (columns in the
 
 311 specified table that refer to primary keys in other tables), or
 
 312 a list of foreign keys in other tables that refer to the primary key in
 
 315 If 
{\it ptable
} contains a table name, this function returns a result
 
 316 set containing the primary key of the specified table.
 
 318 If 
{\it ftable
} contains a table name, this functions returns a result set
 
 319 of containing all of the foreign keys in the specified table and the
 
 320 primary keys (in other tables) to which they refer.
 
 322 If both 
{\it ptable
} and 
{\it ftable
} contain table names, this
 
 323 function returns the foreign keys in the table specified in 
{\it 
 324 ftable
} that refer to the primary key of the table specified in 
{\it 
 325 ptable
}. This should be one key at most.
 
 327 GetForeignKeys returns results as a standard result set. If the foreign
 
 328 keys associated with a primary key are requested, the result set is
 
 329 ordered by FKTABLE
\_QUALIFIER, FKTABLE
\_OWNER, FKTABLE
\_NAME, and KEY
\_SEQ.
 
 330 If the primary keys associated with a foreign key are requested, the
 
 331 result set is ordered by PKTABLE
\_QUALIFIER, PKTABLE
\_OWNER, PKTABLE
\_NAME,
 
 332 and KEY
\_SEQ. The following table lists the columns in the result set. 
 
 334 \begin{twocollist
}\itemsep=
0pt
 
 335 \twocolitem{0 (VARCHAR)
}{PKTABLE
\_QUALIFIER} 
 336 \twocolitem{1 (VARCHAR)
}{PKTABLE
\_OWNER} 
 337 \twocolitem{2 (VARCHAR)
}{PKTABLE
\_NAME} 
 338 \twocolitem{3 (VARCHAR)
}{PKCOLUMN
\_NAME} 
 339 \twocolitem{4 (VARCHAR)
}{FKTABLE
\_QUALIFIER} 
 340 \twocolitem{5 (VARCHAR)
}{FKTABLE
\_OWNER} 
 341 \twocolitem{6 (VARCHAR)
}{FKTABLE
\_NAME} 
 342 \twocolitem{7 (VARCHAR)
}{FKCOLUMN
\_NAME} 
 343 \twocolitem{8 (SMALLINT)
}{KEY
\_SEQ} 
 344 \twocolitem{9 (SMALLINT)
}{UPDATE
\_RULE} 
 345 \twocolitem{10 (SMALLINT)
}{DELETE
\_RULE} 
 346 \twocolitem{11 (VARCHAR)
}{FK
\_NAME} 
 347 \twocolitem{12 (VARCHAR)
}{PK
\_NAME} 
 350 \membersection{wxRecordSet::GetNumberCols
} 
 352 \func{long
}{GetNumberCols
}{\void} 
 354 Returns the number of columns in the result set.
 
 356 \membersection{wxRecordSet::GetNumberFields
} 
 358 \func{int
}{GetNumberFields
}{\void} 
 362 \membersection{wxRecordSet::GetNumberParams
} 
 364 \func{int
}{GetNumberParams
}{\void} 
 368 \membersection{wxRecordSet::GetNumberRecords
} 
 370 \func{long
}{GetNumberRecords
}{\void} 
 372 Returns the number of records in the result set.
 
 374 \membersection{wxRecordSet::GetPrimaryKeys
} 
 376 \func{bool
}{GetPrimaryKeys
}{\param{const wxString\& 
}{table = NULL
}} 
 378 Returns the column names that comprise the primary key of the table with the specified name. If no name is
 
 379 given the class member 
{\it tablename
} will be used. If both names are NULL
 
 380 nothing will happen. The data will be presented as a normal result set, organized
 
 383 \begin{twocollist
}\itemsep=
0pt
 
 384 \twocolitem{0 (VARCHAR)
}{TABLE
\_QUALIFIER} 
 385 \twocolitem{1 (VARCHAR)
}{TABLE
\_OWNER} 
 386 \twocolitem{2 (VARCHAR)
}{TABLE
\_NAME} 
 387 \twocolitem{3 (VARCHAR)
}{COLUMN
\_NAME} 
 388 \twocolitem{4 (SMALLINT)
}{KEY
\_SEQ} 
 389 \twocolitem{5 (VARCHAR)
}{PK
\_NAME} 
 392 \membersection{wxRecordSet::GetOptions
} 
 394 \func{int
}{GetOptions
}{\void} 
 396 Returns the options of the wxRecordSet. Options are not supported yet.
 
 398 \membersection{wxRecordSet::GetResultSet
} 
 400 \func{bool
}{GetResultSet
}{\void} 
 402 Copies the data presented by ODBC into wxRecordSet. Depending on the
 
 403 wxRecordSet type all or only one record(s) will be copied.
 
 404 Usually this function will be called automatically after each successful
 
 407 \membersection{wxRecordSet::GetSortString
} 
 409 \func{wxString
}{GetSortString
}{\void} 
 413 \membersection{wxRecordSet::GetSQL
} 
 415 \func{wxString
}{GetSQL
}{\void} 
 419 \membersection{wxRecordSet::GetTableName
} 
 421 \func{wxString
}{GetTableName
}{\void} 
 423 Returns the name of the current table.
 
 425 \membersection{wxRecordSet::GetTables
} 
 427 \func{bool
}{GetTables
}{\void} 
 429 Gets the tables of a database. The data will be presented as a normal result
 
 430 set, organized as follows:
 
 432 \begin{twocollist
}\itemsep=
0pt
 
 433 \twocolitem{0 (VARCHAR)
}{TABLE
\_QUALIFIER} 
 434 \twocolitem{1 (VARCHAR)
}{TABLE
\_OWNER} 
 435 \twocolitem{2 (VARCHAR)
}{TABLE
\_NAME} 
 436 \twocolitem{3 (VARCHAR)
}{TABLE
\_TYPE (TABLE, VIEW, SYSTEM TABLE, GLOBAL TEMPORARY, LOCAL TEMPORARY,
 
 437 ALIAS, SYNONYM, or database-specific type)
} 
 438 \twocolitem{4 (VARCHAR)
}{REMARKS
} 
 441 \membersection{wxRecordSet::GetType
} 
 443 \func{int
}{GetType
}{\void} 
 445 Returns the type of the wxRecordSet: wxOPEN
\_TYPE\_DYNASET or
 
 446 wxOPEN
\_TYPE\_SNAPSHOT. See the wxRecordSet description for details.
 
 448 \membersection{wxRecordSet::GoTo
} 
 450 \func{bool
}{GoTo
}{\param{long
}{ n
}} 
 452 Moves the cursor to the record with the number n, where  the first record
 
 455 \membersection{wxRecordSet::IsBOF
} 
 457 \func{bool
}{IsBOF
}{\void} 
 459 Returns true if the user tried to move the cursor before the first record
 
 462 \membersection{wxRecordSet::IsFieldDirty
} 
 464 \func{bool
}{IsFieldDirty
}{\param{int
}{ field
}} 
 466 Returns true if the given field has been changed but not saved yet.
 
 468 \func{bool
}{IsFieldDirty
}{\param{const wxString\& 
}{name
}} 
 470 Same as above, but uses the column name as the identifier.
 
 472 \membersection{wxRecordSet::IsFieldNull
} 
 474 \func{bool
}{IsFieldNull
}{\param{int
}{ field
}} 
 476 Returns true if the given field has no data.
 
 478 \func{bool
}{IsFieldNull
}{\param{const wxString\& 
}{ name
}} 
 480 Same as above, but uses the column name as the identifier.
 
 482 \membersection{wxRecordSet::IsColNullable
} 
 484 \func{bool
}{IsColNullable
}{\param{int
}{ col
}} 
 486 Returns true if the given column may contain no data.
 
 488 \func{bool
}{IsColNullable
}{\param{const wxString\& 
}{name
}} 
 490 Same as above, but uses the column name as the identifier.
 
 492 \membersection{wxRecordSet::IsEOF
} 
 494 \func{bool
}{IsEOF
}{\void} 
 496 Returns true if the user tried to move the cursor behind the last record
 
 499 \membersection{wxRecordSet::IsDeleted
} 
 501 \func{bool
}{IsDeleted
}{\void} 
 505 \membersection{wxRecordSet::IsOpen
} 
 507 \func{bool
}{IsOpen
}{\void} 
 509 Returns true if the parent database is open.
 
 511 \membersection{wxRecordSet::Move
} 
 513 \func{bool
}{Move
}{\param{long
}{ rows
}} 
 515 Moves the cursor a given number of rows. Negative values are allowed.
 
 517 \membersection{wxRecordSet::MoveFirst
} 
 519 \func{bool
}{MoveFirst
}{\void} 
 521 Moves the cursor to the first record.
 
 523 \membersection{wxRecordSet::MoveLast
} 
 525 \func{bool
}{MoveLast
}{\void} 
 527 Moves the cursor to the last record.
 
 529 \membersection{wxRecordSet::MoveNext
}\label{wxrecordsetmovenext
} 
 531 \func{bool
}{MoveNext
}{\void} 
 533 Moves the cursor to the next record.
 
 535 \membersection{wxRecordSet::MovePrev
}\label{wxrecordsetmoveprev
} 
 537 \func{bool
}{MovePrev
}{\void} 
 539 Moves the cursor to the previous record.
 
 541 \membersection{wxRecordSet::Query
} 
 543 \func{bool
}{Query
}{\param{const wxString\& 
}{columns
}, 
\param{const wxString\& 
}{table
}, 
\param{const wxString\& 
}{filter = NULL
}} 
 545 Start a query. An SQL string of the following type will automatically be
 
 546 generated and executed: ``SELECT columns FROM table WHERE filter".
 
 548 \membersection{wxRecordSet::RecordCountFinal
} 
 550 \func{bool
}{RecordCountFinal
}{\void} 
 554 \membersection{wxRecordSet::Requery
} 
 556 \func{bool
}{Requery
}{\void} 
 558 Re-executes the last query. Not implemented.
 
 560 \membersection{wxRecordSet::SetFieldDirty
} 
 562 \func{void
}{SetFieldDirty
}{\param{int
}{ field
}, 
\param{bool
}{ dirty = true
}} 
 564 Sets the dirty tag of the field field. Not implemented.
 
 566 \func{void
}{SetFieldDirty
}{\param{const wxString\& 
}{name
}, 
\param{bool
}{ dirty = true
}} 
 568 Same as above, but uses the column name as the identifier.
 
 570 \membersection{wxRecordSet::SetDefaultSQL
} 
 572 \func{void
}{SetDefaultSQL
}{\param{const wxString\& 
}{s
}} 
 576 \membersection{wxRecordSet::SetFieldNull
} 
 578 \func{void
}{SetFieldNull
}{\param{void *
}{p
}, 
\param{bool 
}{isNull = true
}} 
 582 \membersection{wxRecordSet::SetOptions
} 
 584 \func{void
}{SetOptions
}{\param{int
}{ opt
}} 
 586 Sets the options of the wxRecordSet. Not implemented.
 
 588 \membersection{wxRecordSet::SetTableName
} 
 590 \func{void
}{SetTableName
}{\param{const wxString\& 
}{tablename
}} 
 592 Specify the name of the table you want to use.
 
 594 \membersection{wxRecordSet::SetType
} 
 596 \func{void
}{SetType
}{\param{int
}{ type
}} 
 598 Sets the type of the wxRecordSet. See the wxRecordSet class description for details.
 
 600 \membersection{wxRecordSet::Update
} 
 602 \func{bool
}{Update
}{\void} 
 604 Writes back the current record. Not implemented.