gSAFE  1.3.8
Public Member Functions | List of all members
HXBaseRecordSync Class Reference

#include <xbioconn.h>

Inheritance diagram for HXBaseRecordSync:
HBase

Public Member Functions

 HXBaseRecordSync ()
 
void assign (QString htablefieldsqlname, QString xbasefieldname)
 
void clearAssigns (void)
 
int syncHTableToXBase (HTable *record, HXBaseFileWriter *dbf)
 
int syncXBaseToHTable (HXBaseFileReader *dbf, HTable *record)
 
- Public Member Functions inherited from HBase
 HBase (void)
 
 ~HBase (void)
 
QString getWhoami (void)
 

Additional Inherited Members

- Protected Attributes inherited from HBase
QString whoami
 

Detailed Description

The HXBaseRecordSync enables you to easely syncronise a HTable record to Xbase and reverse. After you assign the gSAFE fields (HDataField) to XBase fields you can copy the whole record in one step. Look this exaples:

Import an XBase (.dbf) table to SQL table with gsafe by record to record. (Note: This is not a directy copy, both tables can contains more field's than copyed)

int r;
HXBaseRecordSync sync; //Make a syncronizer object
HTable *t = myHFactory->genHTable("Dbf1Table"); //Generate/define a gSAFE record (HTable)
HXBaseFileReader *dbf = new HXBaseFileReader(new HCodepage852(),true); //Make a dbf reader object
sync.assign("name","NAME_CHAR");
sync.assign("age","AGE_NUM");
if(dbf->open("FILE.DBF"))
{
//error
}
r = dbf->firstRecord();
while(r == 0)
{
sync.syncXBaseToHTable(dbf,t); //sync the current xbase record to the HTable
t->insertRecord(); //Insert the HTable record to the sql table
r = dbf->nextRecord();
}
dbf->close();
delete dbf;
delete t;

Export a complete sql table by record to record to XBase (.dbf) file. (Note: This is not a directy copy, both tables can contains more field's than copyed)

HXBaseRecordSync sync; //Make a syncronizer object
HTable *t = myfactory->genHTable("partner"); //Generate/define a gSAFE record (HTable)
HXBaseFileWriter *dbf = new HXBaseFileWriter(new HCodepage852(),true); //Make a dbf writer object
dbf->defineField("NAME",Char,40); //Define the fields of dbf file
dbf->defineField("ADDRESS",Char,40);
sync.assign("name","NAME"); //Assign the XBase field to Sql field
sync.assign("address","ADDRESS");
if(dbf->create("EXPORT.DBF",3)) //Create the XBase file
{
//error
}
HPlainDataMatrix *m = t->submitNResultQuery(1,"SELECT key FROM partner ORDER BY name;","Error");
m->firstRow();
do
{
sync.syncHTableToXBase(t,dbf);
dbf->appendRecord();
}
while(m->nextRow());
dbf->close();
delete dbf;
delete t;

Definition at line 110 of file xbioconn.h.

Constructor & Destructor Documentation

HXBaseRecordSync::HXBaseRecordSync ( void  )

Creates a HXBaseRecordSync object

Definition at line 26 of file xbioconn.cpp.

Member Function Documentation

void HXBaseRecordSync::assign ( QString  htablefieldsqlname,
QString  xbasefieldname 
)

Add a new gSAFE - XBase field assign

Definition at line 37 of file xbioconn.cpp.

void HXBaseRecordSync::clearAssigns ( void  )

Clears all gSAFE - XBase field assign

Definition at line 42 of file xbioconn.cpp.

int HXBaseRecordSync::syncHTableToXBase ( HTable record,
HXBaseFileWriter dbf 
)

Sync the assugned data from gSAFE Htable to XBase

Definition at line 47 of file xbioconn.cpp.

int HXBaseRecordSync::syncXBaseToHTable ( HXBaseFileReader dbf,
HTable record 
)

Sync the assugned data from XBase to gSAFE Htable

Definition at line 94 of file xbioconn.cpp.


The documentation for this class was generated from the following files: