PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFBDBRecord
Wrapper Class for the IDBRecord interface.
#include <SFBDBRecord.h.hpp>
class SFBDBRecord : public SFBBase;
SFMTYPEDEFWRAPPER(SFBDBRecord)

Inheritance diagram

 Inheritance diagram of SFBDBRecordClass

Version

BREW 2.0 BREW 2.1 BREW 3.1 BREW 4.0
O O O O

Reference

BREW API IDBRecord

Member

Public Functions
VoidPtr GetField( AEEDBFieldName* name , AEEDBFieldType* type , UInt16Ptr length )
Get the raw data, type, name and length of the current field.
Bool GetFieldDWord( UInt32Ptr field )
Get the 4-byte value of current field if the field type is AEE_FT_DWORD.
WCharPtr GetFieldString( Void )
Get the string of current field if the field type is AEEDB_FT_STRING.
Bool GetFieldWord( UInt16Ptr field )
Gget the 2-byte value of current field if the field type is AEE_FT_WORD.
UInt16 GetID( Void )
Get the ID of the specified record.
AEEDBFieldType NextField( AEEDBFieldName* name , UInt16Ptr length )
Get the next field in current record.
SFCError Remove( SFBDBRecordSmpPtr record )
Remove a record from the database and frees the SFBDBRecord object.
Void Reset( Void )
Make the first field of record the current field.
SFCError Update( AEEDBField* fields , SInt32 fieldsCount )
Update a record given a new set of field values.
Protected Functions
static
SFBBaseSmp
FactoryByCreate( AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface.
static
SFBBaseSmp
FactoryByQuery( SFBQuerySmpConstRef query , AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface using the SFBQuery instance.

SFBDBRecord::GetField
Get the raw data, type, name and length of the current field.
[ public ]
VoidPtr GetField(
    AEEDBFieldName* name   // pointer to the field name
    AEEDBFieldType* type   // pointer to the field type
    UInt16Ptr length       // pointer to length of the field (in bytes)
);

Example

Get the content of current field.

// create SFBDataMgr interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
SFBDBRecordSmp      record;
AEEDBFieldName      fieldName;
AEEDBFieldType      fieldType;
UInt16              len;
VoidPtr             data;

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get the record of specified index in database.
record = database->GetRecordByID(3);

// get next field
fieldType = record->NextField(&fieldName, &len);

// get the content of this field
data = record->GetField(&fieldName, &fieldType, &len);

Reference

BREW API IDBRECORD_GetField | AEEDBFieldType | AEEDBFieldName


SFBDBRecord::GetFieldDWord
Get the 4-byte value of current field if the field type is AEE_FT_DWORD.
[ public ]
Bool GetFieldDWord(
    UInt32Ptr field   // pointer to UInt32 returned by this function
);

Example

Get the 4-byte value of current field.

// create SFBDataMgr interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
SFBDBRecordSmp      record;
AEEDBFieldName      fieldName;
AEEDBFieldType      fieldType;
UInt16              len;
UInt32              val;

// open database.
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get the record of specified index in database
record = database->GetRecordByID(0);

// get next field
fieldType = record->NextField(&fieldName, &len);

// get the 4-byte value of this field
record->GetFieldDWord(&val);

Reference

BREW API IDBRECORD_GetFieldDWord


SFBDBRecord::GetFieldString
Get the string of current field if the field type is AEEDB_FT_STRING.
[ public ]
WCharPtr GetFieldString(Void);

Example

Get the string of current field.

// create SFBDataMgr interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
SFBDBRecordSmp      record;
AEEDBFieldName      fieldName;
AEEDBFieldType      fieldType;
UInt16              len;
SFXWideString       str;

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get the record of specified index in database.
record = database->GetRecordByID(5);

// get next field
fieldType = record->NextField(&fieldName, &len);

// get the string of this field
str = SFXWideString(record->GetFieldString());

Reference

BREW API IDBRECORD_GetFieldString


SFBDBRecord::GetFieldWord
Gget the 2-byte value of current field if the field type is AEE_FT_WORD.
[ public ]
Bool GetFieldWord(
    UInt16Ptr field   // pointer to UInt16 returned by this function
);

Example

Get the 2-byte value of current field.

// create SFBDataMgr interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
SFBDBRecordSmp      record;
AEEDBFieldName      fieldName;
AEEDBFieldType      fieldType;
UInt16              len;
UInt16              val;

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get the record of specified index in database
record = database->GetRecordByID(0);

// get next field
fieldType = record->NextField(&fieldName, &len);

// get the 2-byte value of this field
record->GetFieldWord(&val);

Reference

BREW API IDBRECORD_GetFieldWord


SFBDBRecord::GetID
Get the ID of the specified record.
[ public ]
UInt16 GetID(Void);

Example

Get the ID of the specified record.

// create SFBDataMgr Interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
SFBDBRecordSmp      record;
UInt16              id;

// create a field for record.
UInt32              val   = 32;
AEEDBField          field = {AEEDB_FT_DWORD, AEEDBFIELD_TEXT, 1, &val};

// open database.
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// create a record in database.
record = database->CreateRecord(&field, 1);

// get the ID of this record.
id = record->GetID();

Reference

BREW API IDBRECORD_GetID


SFBDBRecord::NextField
Get the next field in current record.
[ public ]
AEEDBFieldType NextField(
    AEEDBFieldName* name   // pointer to the next field name
    UInt16Ptr length       // pointer to length of the next field
);

Example

Get the next field in the record.

// create SFBDataMgr interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
SFBDBRecordSmp      record;
AEEDBFieldName      fieldName;
AEEDBFieldType      fieldType;
UInt16              size;

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get the record of specified index in database
record = database->GetRecordByID(0);

// get next field
fieldType = record->NextField(&fieldName, &size);

Reference

BREW API IDBRECORD_NextField | AEEDBFieldName | AEEDBFieldType


SFBDBRecord::Remove
Remove a record from the database and frees the SFBDBRecord object.
[ public ]
SFCError Remove(
    SFBDBRecordSmpPtr record   // SFBDBRecord Interface which needs to be removed
);

Example

Remove a record from the database

// create SFBDataMgr interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
SFBDBRecordSmp      record;

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get the record of specified index in database
record = database->GetRecordByID(0);

// remove the record, the record is also released
record->Remove(record);

Reference

BREW API IDBRECORD_Remove


SFBDBRecord::Reset
Make the first field of record the current field.
[ public ]
Void Reset(Void);

Reference

BREW API IDBRECORD_Reset | SFBDBRecord::NextField


SFBDBRecord::Update
Update a record given a new set of field values.
[ public ]
SFCError Update(
    AEEDBField* fields   // pointer to the new set of field values
    SInt32 fieldsCount   // number of fields in the new set
);

Example

Update a record.

// create SFBDataMgr interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
SFBDBRecordSmp      record;

// create a field for record
AChar               str[] = {"Update!!!"};
AEEDBField          field = {AEEDB_FT_STRING, AEEDBFIELD_TEXT, STRLEN(str), str};

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get the record of specified index in database
record = database->GetRecordByID(0);

// update record
record->Update(&field, 1);

Reference

BREW API IDBRECORD_Update