Contents Up Previous Next 原文へのリンク

wxRecordSet

Each wxRecordSet represents an ODBC database query. You can make multiple queries at a time by using multiple wxRecordSets with a wxDatabase or you can make your queries in sequential order using the same wxRecordSet.

Note: this class is considered obsolete, replaced by the Remstar wxDB/wxDbTable classes

Derived from

wxObject

Include files

<wx/odbc.h>

See also

wxRecordSet overview, wxDatabase overview

Members

wxRecordSet::wxRecordSet
wxRecordSet::~wxRecordSet
wxRecordSet::AddNew
wxRecordSet::BeginQuery
wxRecordSet::BindVar
wxRecordSet::CanAppend
wxRecordSet::Cancel
wxRecordSet::CanRestart
wxRecordSet::CanScroll
wxRecordSet::CanTransact
wxRecordSet::CanUpdate
wxRecordSet::ConstructDefaultSQL
wxRecordSet::Delete
wxRecordSet::Edit
wxRecordSet::EndQuery
wxRecordSet::ExecuteSQL
wxRecordSet::FillVars
wxRecordSet::GetColName
wxRecordSet::GetColType
wxRecordSet::GetColumns
wxRecordSet::GetCurrentRecord
wxRecordSet::GetDatabase
wxRecordSet::GetDataSources
wxRecordSet::GetDefaultConnect
wxRecordSet::GetDefaultSQL
wxRecordSet::GetErrorCode
wxRecordSet::GetFieldData
wxRecordSet::GetFieldDataPtr
wxRecordSet::GetFilter
wxRecordSet::GetForeignKeys
wxRecordSet::GetNumberCols
wxRecordSet::GetNumberFields
wxRecordSet::GetNumberParams
wxRecordSet::GetNumberRecords
wxRecordSet::GetPrimaryKeys
wxRecordSet::GetOptions
wxRecordSet::GetResultSet
wxRecordSet::GetSortString
wxRecordSet::GetSQL
wxRecordSet::GetTableName
wxRecordSet::GetTables
wxRecordSet::GetType
wxRecordSet::GoTo
wxRecordSet::IsBOF
wxRecordSet::IsFieldDirty
wxRecordSet::IsFieldNull
wxRecordSet::IsColNullable
wxRecordSet::IsEOF
wxRecordSet::IsDeleted
wxRecordSet::IsOpen
wxRecordSet::Move
wxRecordSet::MoveFirst
wxRecordSet::MoveLast
wxRecordSet::MoveNext
wxRecordSet::MovePrev
wxRecordSet::Query
wxRecordSet::RecordCountFinal
wxRecordSet::Requery
wxRecordSet::SetFieldDirty
wxRecordSet::SetDefaultSQL
wxRecordSet::SetFieldNull
wxRecordSet::SetOptions
wxRecordSet::SetTableName
wxRecordSet::SetType
wxRecordSet::Update


wxRecordSet::wxRecordSet

wxRecordSet(wxDatabase *db, int type = wxOPEN_TYPE_DYNASET, int opt = wxOPTION_DEFAULT)

Constructor. db is a pointer to the wxDatabase instance you wish to use the wxRecordSet with. Currently there are two possible values of type:

The option parameter is not used yet.

The constructor appends the wxRecordSet object to the parent database's list of wxRecordSet objects, for later destruction when the wxDatabase is destroyed.


wxRecordSet::~wxRecordSet

~wxRecordSet()

Destructor. All data except that stored in user-defined variables will be lost. It also unlinks the wxRecordSet object from the parent database's list of wxRecordSet objects.


wxRecordSet::AddNew

void AddNew()

Not implemented.


wxRecordSet::BeginQuery

bool BeginQuery(int openType, const wxString& sql = NULL, int options = wxOPTION_DEFAULT)

Not implemented.


wxRecordSet::BindVar

void * BindVar(int col, void *buf, long size)

Binds a user-defined variable to the column col. Whenever the current field's data changes, it will be copied into buf (maximum size bytes).

void * BindVar(const wxString& col, void *buf, long size)

The same as above, but uses the column name as the identifier.


wxRecordSet::CanAppend

bool CanAppend()

Not implemented.


wxRecordSet::Cancel

void Cancel()

Not implemented.


wxRecordSet::CanRestart

bool CanRestart()

Not implemented.


wxRecordSet::CanScroll

bool CanScroll()

Not implemented.


wxRecordSet::CanTransact

bool CanTransact()

Not implemented.


wxRecordSet::CanUpdate

bool CanUpdate()

Not implemented.


wxRecordSet::ConstructDefaultSQL

bool ConstructDefaultSQL()

Not implemented.


wxRecordSet::Delete

bool Delete()

Deletes the current record. Not implemented.


wxRecordSet::Edit

void Edit()

Not implemented.


wxRecordSet::EndQuery

bool EndQuery()

Not implemented.


wxRecordSet::ExecuteSQL

bool ExecuteSQL(const wxString& sql)

Directly executes a SQL statement. The data will be presented as a normal result set. Note that the recordset must have been created as a snapshot, not dynaset. Dynasets will be implemented in the near future.

Examples of common SQL statements are given in A selection of SQL commands.


wxRecordSet::FillVars

void FillVars(int recnum)

Fills in the user-defined variables of the columns. You can set these variables with wxQueryCol::BindVar. This function will be automatically called after every successful database operation.


wxRecordSet::GetColName

wxString GetColName(int col)

Returns the name of the column at position col. Returns NULL if col does not exist.


wxRecordSet::GetColType

short GetColType(int col)

Returns the data type of the column at position col. Returns SQL_TYPE_NULL if col does not exist.

short GetColType(const wxString& name)

The same as above, but uses the column name as the identifier.

See ODBC SQL data types for a list of possible data types.


wxRecordSet::GetColumns

bool GetColumns(const wxString& table = NULL)

Returns the columns of the table with the specified name. If no name is given the class member tablename will be used. If both names are NULL nothing will happen. The data will be presented as a normal result set, organized as follows:

0 (VARCHAR) TABLE_QUALIFIER
1 (VARCHAR) TABLE_OWNER
2 (VARCHAR) TABLE_NAME
3 (VARCHAR) COLUMN_NAME
4 (SMALLINT) DATA_TYPE
5 (VARCHAR) TYPE_NAME
6 (INTEGER) PRECISION
7 (INTEGER) LENGTH
8 (SMALLINT) SCALE
9 (SMALLINT) RADIX
10 (SMALLINT) NULLABLE
11 (VARCHAR) REMARKS


wxRecordSet::GetCurrentRecord

long GetCurrentRecord()

Not implemented.


wxRecordSet::GetDatabase

wxDatabase * GetDatabase()

Returns the wxDatabase object bound to a wxRecordSet.


wxRecordSet::GetDataSources

bool GetDataSources()

Gets the currently-defined data sources via the ODBC manager. The data will be presented as a normal result set. See the documentation for the ODBC function SQLDataSources for how the data is organized.

Example:

  wxDatabase Database;

  wxRecordSet *Record = new wxRecordSet(&Database);

  if (!Record->GetDataSources()) {
    char buf[300];
    sprintf(buf, "%s %s\n", Database.GetErrorClass(), Database.GetErrorMessage());
    frame->output->SetValue(buf);
  }
  else {
    do {
      frame->DataSource->Append((char*)Record->GetFieldDataPtr(0, SQL_CHAR));
    } while (Record->MoveNext());
  }

wxRecordSet::GetDefaultConnect

wxString GetDefaultConnect()

Not implemented.


wxRecordSet::GetDefaultSQL

wxString GetDefaultSQL()

Not implemented.


wxRecordSet::GetErrorCode

wxRETCODE GetErrorCode()

Returns the error code of the last ODBC action. This will be one of:

SQL_ERROR General error.
SQL_INVALID_HANDLE An invalid handle was passed to an ODBC function.
SQL_NEED_DATA ODBC expected some data.
SQL_NO_DATA_FOUND No data was found by this ODBC call.
SQL_SUCCESS The call was successful.
SQL_SUCCESS_WITH_INFO The call was successful, but further information can be obtained from the ODBC manager.


wxRecordSet::GetFieldData

bool GetFieldData(int col, int dataType, void *dataPtr)

Copies the current data of the column at position col into the buffer dataPtr. To be sure to get the right type of data, the user has to pass the correct data type. The function returns FALSE if col does not exist or the wrong data type was given.

bool GetFieldData(const wxString& name, int dataType, void *dataPtr)

The same as above, but uses the column name as the identifier.

See ODBC SQL data types for a list of possible data types.


wxRecordSet::GetFieldDataPtr

void * GetFieldDataPtr(int col, int dataType)

Returns the current data pointer of the column at position col. To be sure to get the right type of data, the user has to pass the data type. Returns NULL if col does not exist or if dataType is incorrect.

void * GetFieldDataPtr(const wxString& name, int dataType)

The same as above, but uses the column name as the identifier.

See ODBC SQL data types for a list of possible data types.


wxRecordSet::GetFilter

wxString GetFilter()

Returns the current filter.


wxRecordSet::GetForeignKeys

bool GetPrimaryKeys(const wxString& ptable = NULL, const wxString& ftable = NULL)

Returns a list of foreign keys in the specified table (columns in the specified table that refer to primary keys in other tables), or a list of foreign keys in other tables that refer to the primary key in the specified table.

If ptable contains a table name, this function returns a result set containing the primary key of the specified table.

If ftable contains a table name, this functions returns a result set of containing all of the foreign keys in the specified table and the primary keys (in other tables) to which they refer.

If both ptable and ftable contain table names, this function returns the foreign keys in the table specified in ftable that refer to the primary key of the table specified in ptable. This should be one key at most.

GetForeignKeys returns results as a standard result set. If the foreign keys associated with a primary key are requested, the result set is ordered by FKTABLE_QUALIFIER, FKTABLE_OWNER, FKTABLE_NAME, and KEY_SEQ. If the primary keys associated with a foreign key are requested, the result set is ordered by PKTABLE_QUALIFIER, PKTABLE_OWNER, PKTABLE_NAME, and KEY_SEQ. The following table lists the columns in the result set.

0 (VARCHAR) PKTABLE_QUALIFIER
1 (VARCHAR) PKTABLE_OWNER
2 (VARCHAR) PKTABLE_NAME
3 (VARCHAR) PKCOLUMN_NAME
4 (VARCHAR) FKTABLE_QUALIFIER
5 (VARCHAR) FKTABLE_OWNER
6 (VARCHAR) FKTABLE_NAME
7 (VARCHAR) FKCOLUMN_NAME
8 (SMALLINT) KEY_SEQ
9 (SMALLINT) UPDATE_RULE
10 (SMALLINT) DELETE_RULE
11 (VARCHAR) FK_NAME
12 (VARCHAR) PK_NAME


wxRecordSet::GetNumberCols

long GetNumberCols()

Returns the number of columns in the result set.


wxRecordSet::GetNumberFields

int GetNumberFields()

Not implemented.


wxRecordSet::GetNumberParams

int GetNumberParams()

Not implemented.


wxRecordSet::GetNumberRecords

long GetNumberRecords()

Returns the number of records in the result set.


wxRecordSet::GetPrimaryKeys

bool GetPrimaryKeys(const wxString& table = NULL)

Returns the column names that comprise the primary key of the table with the specified name. If no name is given the class member tablename will be used. If both names are NULL nothing will happen. The data will be presented as a normal result set, organized as follows:

0 (VARCHAR) TABLE_QUALIFIER
1 (VARCHAR) TABLE_OWNER
2 (VARCHAR) TABLE_NAME
3 (VARCHAR) COLUMN_NAME
4 (SMALLINT) KEY_SEQ
5 (VARCHAR) PK_NAME


wxRecordSet::GetOptions

int GetOptions()

Returns the options of the wxRecordSet. Options are not supported yet.


wxRecordSet::GetResultSet

bool GetResultSet()

Copies the data presented by ODBC into wxRecordSet. Depending on the wxRecordSet type all or only one record(s) will be copied. Usually this function will be called automatically after each successful database operation.


wxRecordSet::GetSortString

wxString GetSortString()

Not implemented.


wxRecordSet::GetSQL

wxString GetSQL()

Not implemented.


wxRecordSet::GetTableName

wxString GetTableName()

Returns the name of the current table.


wxRecordSet::GetTables

bool GetTables()

Gets the tables of a database. The data will be presented as a normal result set, organized as follows:

0 (VARCHAR) TABLE_QUALIFIER
1 (VARCHAR) TABLE_OWNER
2 (VARCHAR) TABLE_NAME
3 (VARCHAR) TABLE_TYPE (TABLE, VIEW, SYSTEM TABLE, GLOBAL TEMPORARY, LOCAL TEMPORARY, ALIAS, SYNONYM, or database-specific type)
4 (VARCHAR) REMARKS


wxRecordSet::GetType

int GetType()

Returns the type of the wxRecordSet: wxOPEN_TYPE_DYNASET or wxOPEN_TYPE_SNAPSHOT. See the wxRecordSet description for details.


wxRecordSet::GoTo

bool GoTo(long n)

Moves the cursor to the record with the number n, where the first record has the number 0.


wxRecordSet::IsBOF

bool IsBOF()

Returns TRUE if the user tried to move the cursor before the first record in the set.


wxRecordSet::IsFieldDirty

bool IsFieldDirty(int field)

Returns TRUE if the given field has been changed but not saved yet.

bool IsFieldDirty(const wxString& name)

Same as above, but uses the column name as the identifier.


wxRecordSet::IsFieldNull

bool IsFieldNull(int field)

Returns TRUE if the given field has no data.

bool IsFieldNull(const wxString& name)

Same as above, but uses the column name as the identifier.


wxRecordSet::IsColNullable

bool IsColNullable(int col)

Returns TRUE if the given column may contain no data.

bool IsColNullable(const wxString& name)

Same as above, but uses the column name as the identifier.


wxRecordSet::IsEOF

bool IsEOF()

Returns TRUE if the user tried to move the cursor behind the last record in the set.


wxRecordSet::IsDeleted

bool IsDeleted()

Not implemented.


wxRecordSet::IsOpen

bool IsOpen()

Returns TRUE if the parent database is open.


wxRecordSet::Move

bool Move(long rows)

Moves the cursor a given number of rows. Negative values are allowed.


wxRecordSet::MoveFirst

bool MoveFirst()

Moves the cursor to the first record.


wxRecordSet::MoveLast

bool MoveLast()

Moves the cursor to the last record.


wxRecordSet::MoveNext

bool MoveNext()

Moves the cursor to the next record.


wxRecordSet::MovePrev

bool MovePrev()

Moves the cursor to the previous record.


wxRecordSet::Query

bool Query(const wxString& columns, const wxString& table, const wxString& filter = NULL)

Start a query. An SQL string of the following type will automatically be generated and executed: "SELECT columns FROM table WHERE filter".


wxRecordSet::RecordCountFinal

bool RecordCountFinal()

Not implemented.


wxRecordSet::Requery

bool Requery()

Re-executes the last query. Not implemented.


wxRecordSet::SetFieldDirty

void SetFieldDirty(int field, bool dirty = TRUE)

Sets the dirty tag of the field field. Not implemented.

void SetFieldDirty(const wxString& name, bool dirty = TRUE)

Same as above, but uses the column name as the identifier.


wxRecordSet::SetDefaultSQL

void SetDefaultSQL(const wxString& s)

Not implemented.


wxRecordSet::SetFieldNull

void SetFieldNull(void *p, bool isNull = TRUE)

Not implemented.


wxRecordSet::SetOptions

void SetOptions(int opt)

Sets the options of the wxRecordSet. Not implemented.


wxRecordSet::SetTableName

void SetTableName(const wxString& tablename)

Specify the name of the table you want to use.


wxRecordSet::SetType

void SetType(int type)

Sets the type of the wxRecordSet. See the wxRecordSet class description for details.


wxRecordSet::Update

bool Update()

Writes back the current record. Not implemented.