#include <iostream> #include "ibpp/ibpp.h"
using namespace std;
int main() { cout << "Testing Firebird embedded with IBPP library" << endl;
try { cout << "Connecting to database test.fdb" << endl; IBPP::Database db1 = IBPP::DatabaseFactory("", "test.fdb", "SYSDBA", "masterkey"); db1->Connect();
cout << "Starting transaction" << endl; IBPP::Transaction tr1 = IBPP::TransactionFactory(db1); tr1->Start();
cout << "Preparing statement" << endl; IBPP::Statement st1 = IBPP::StatementFactory(db1, tr1); st1->Prepare("insert into table1 (x,s) values (1, 'milan')"); st1->Execute();
cout << "Reading data" << endl; st1->Prepare("select x,s from table1"); st1->Execute(); while (st1->Fetch()) { int x; string s; st1->Get(1, x); st1->Get(2, s); cout << "X = " << x << ", S = " << s << endl; } tr1->Commit(); } catch (IBPP::Exception& e) { cout << e.what() << endl; } return 0; }
|