Dear Wysota the solution I used is the code bellow.
IBPP::Driver driver = IBPP::DriverFactory();
IBPP::Database db = driver->DatabaseFactory("127.0.0.1/3052", "DATABASE_PATH", "USER", "PASSWORD");
db->Connect();
IBPP::Transaction transaction = driver->TransactionFactory(db);
transaction->Start();
IBPP::Statement statement = driver->StatementFactory(db, transaction);
statement->Prepare(FBSQL.data());
statement->Execute();
QFile file("C:/Users/NAME/Desktop/sync.txt");
int total = 0;
QElapsedTimer timer;
timer.start();
std::string str_data = "";
int64_t int_data = 0;
double dbl_data = 0.0f;
while (statement->Fetch()) {
++total;
if (header.isEmpty()) {
for (int i = 1; i <= statement->Columns(); ++i) {
header.append(statement->ColumnName(i)).append("|");
}
header.chop(1);
file.write(header.append("\n"));
}
for (int i = 1; i <= statement->Columns(); ++i) {
switch (statement->ColumnType(i)) {
case IBPP::sdArray:
break;
case IBPP::sdBlob:
break;
case IBPP::sdDate:
break;
case IBPP::sdTime:
break;
case IBPP::sdTimestamp:
break;
case IBPP::sdString:
statement->Get(i, str_data);
line.append(str_data.c_str()).append("|");
break;
case IBPP::sdSmallint:
case IBPP::sdInteger:
case IBPP::sdLargeint:
statement->Get(i, int_data);
line.
append(QString::number(int_data
)).
append("|");
break;
case IBPP::sdFloat:
case IBPP::sdDouble:
statement->Get(i, dbl_data);
line.
append(QString::number(dbl_data
)).
append("|");
break;
}
}
line.chop(1);
file.write(line.append("\n"));
}
file.close();
qDebug() << "Records: " << total;
qDebug() << "Time: " << msecsToTime(timer.elapsed());
} else {
qDebug() << "Error: " << file.errorString();
}
statement->Close();
transaction->CommitRetain();
db->Disconnect();
IBPP::Driver driver = IBPP::DriverFactory();
IBPP::Database db = driver->DatabaseFactory("127.0.0.1/3052", "DATABASE_PATH", "USER", "PASSWORD");
db->Connect();
IBPP::Transaction transaction = driver->TransactionFactory(db);
transaction->Start();
IBPP::Statement statement = driver->StatementFactory(db, transaction);
statement->Prepare(FBSQL.data());
statement->Execute();
QFile file("C:/Users/NAME/Desktop/sync.txt");
int total = 0;
if (file.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
QElapsedTimer timer;
timer.start();
std::string str_data = "";
int64_t int_data = 0;
double dbl_data = 0.0f;
QByteArray header;
while (statement->Fetch()) {
++total;
if (header.isEmpty()) {
for (int i = 1; i <= statement->Columns(); ++i) {
header.append(statement->ColumnName(i)).append("|");
}
header.chop(1);
file.write(header.append("\n"));
}
QByteArray line;
for (int i = 1; i <= statement->Columns(); ++i) {
switch (statement->ColumnType(i)) {
case IBPP::sdArray:
break;
case IBPP::sdBlob:
break;
case IBPP::sdDate:
break;
case IBPP::sdTime:
break;
case IBPP::sdTimestamp:
break;
case IBPP::sdString:
statement->Get(i, str_data);
line.append(str_data.c_str()).append("|");
break;
case IBPP::sdSmallint:
case IBPP::sdInteger:
case IBPP::sdLargeint:
statement->Get(i, int_data);
line.append(QString::number(int_data)).append("|");
break;
case IBPP::sdFloat:
case IBPP::sdDouble:
statement->Get(i, dbl_data);
line.append(QString::number(dbl_data)).append("|");
break;
}
}
line.chop(1);
file.write(line.append("\n"));
}
file.close();
qDebug() << "Records: " << total;
qDebug() << "Time: " << msecsToTime(timer.elapsed());
} else {
qDebug() << "Error: " << file.errorString();
}
statement->Close();
transaction->CommitRetain();
db->Disconnect();
To copy to clipboard, switch view to plain text mode
Bookmarks