4 #include <RDBC/TSQLConnection.h>
5 #include <RDBC/TSQLDriverManager.h>
6 #include <RDBC/TSQLPreparedStatement.h>
20 static_cast<TSQLConnection*>(
nullptr));
23 const std::string& Tag)
25 , tablename(TableName)
41 const TString s_con =
"dsn=calibrations_backup_log; uid=phnxrc; pwd= ";
44 cout <<
"PgPostBankBackupLog::Init - connect to " << s_con << endl;
46 con = gSQLDriverManager->GetConnection(s_con);
49 cout <<
"PgPostBankBackupLog::Init - Error - "
50 <<
"cannot init connection to " << s_con << endl;
60 sqlcmd <<
"insert into calib_log (tablename,rid,ops,tag) values ('"
64 cout <<
"PgPostBankBackupLog::Init - make TSQLPreparedStatement "
65 << sqlcmd.str() << endl;
66 pstmt =
con->PrepareStatement(sqlcmd.str().c_str());
70 cout <<
"PgPostBankBackupLog::Init - Error - "
71 <<
"cannot prepare statement " << sqlcmd.str() << endl;
76 catch (std::exception&
e)
78 cout <<
"PgPostBankBackupLog::Init - Error - "
79 <<
"Initialization error "
91 cout <<
"PgPostBankBackupLog::Log - log rid = " << rid <<
", ops = "
92 << ops <<
" for table " <<
tablename <<
" and tag " <<
tag << endl;
98 pstmt->SetInt(1, rid);
99 pstmt->SetInt(2, (
int) ops);
102 const int res =
pstmt->ExecuteUpdate();
106 cout <<
"PgPostBankBackupLog::Log - Error - "
107 <<
"DATABASE: commit failed. "
108 <<
"Make sure you commit to the writable database " << endl;
114 catch (TSQLException&
e)
116 cout <<
"PgPostBankBackupLog::Log - Error - "
117 <<
" Exception caught during connection->commit()" << endl;
118 cout << e.GetMessage() << endl;