36 if (connDb ==
nullptr)
47 stmt->
SetInt(1, is_active);
51 cout <<
"ERROR: inserting new trigger to the Database has been failed" << endl;
61 TSQLStatement* stmt_last = db_server->
Statement(
"SELECT currval(pg_get_serial_sequence('trigger_','trigger_id'))");
70 cout <<
"ERROR: no last ID in DB!" << endl;
74 trigger_id = stmt_last->
GetInt(0);
78 cout <<
"ERROR: getting last ID has been failed!" << endl;
84 tmp_trigger_id = trigger_id;
86 tmp_trigger_info = trigger_info;
88 tmp_is_active = is_active;
90 return new ElogTrigger(connDb, tmp_trigger_id, tmp_trigger_info, tmp_is_active);
97 if (connDb ==
nullptr)
104 "where trigger_id = %d",
110 cout <<
"ERROR: getting trigger from the database has been failed" << endl;
122 cout <<
"ERROR: trigger was not found in the database" << endl;
130 tmp_trigger_id = stmt->
GetInt(0);
134 tmp_is_active = stmt->
GetInt(2);
138 return new ElogTrigger(connDb, tmp_trigger_id, tmp_trigger_info, tmp_is_active);
145 if (connDb ==
nullptr)
152 "where lower(trigger_info) = lower('%s')",
153 trigger_info.
Data());
158 cout <<
"ERROR: getting trigger from the database has been failed" << endl;
170 cout <<
"ERROR: trigger was not found in the database" << endl;
178 tmp_trigger_id = stmt->
GetInt(0);
182 tmp_is_active = stmt->
GetInt(2);
186 return new ElogTrigger(connDb, tmp_trigger_id, tmp_trigger_info, tmp_is_active);
193 if (connDb ==
nullptr)
200 "where trigger_id = %d",
206 cout <<
"ERROR: getting trigger from the database has been failed" << endl;
233 if (connDb ==
nullptr)
240 "where lower(trigger_info) = lower('%s')",
241 trigger_info.
Data());
246 cout <<
"ERROR: getting trigger from the database has been failed" << endl;
273 if (connDb ==
nullptr)
279 "where trigger_id = $1");
283 stmt->
SetInt(0, trigger_id);
287 cout <<
"ERROR: deleting trigger from the dataBase has been failed" << endl;
303 if (connDb ==
nullptr)
309 "where lower(trigger_info) = lower($1)");
317 cout <<
"ERROR: deleting trigger from the DataBase has been failed" << endl;
333 if (connDb ==
nullptr)
344 cout <<
"ERROR: getting all 'triggers' from the dataBase has been failed" << endl;
355 cout <<
"Table 'trigger_':" << endl;
357 cout <<
"trigger_id: ";
358 cout << (stmt->
GetInt(0));
359 cout <<
", trigger_info: ";
361 cout <<
", is_active: ";
362 cout << (stmt->
GetInt(2));
376 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
383 "set trigger_info = $1 "
384 "where trigger_id = $2");
393 cout <<
"ERROR: updating information about trigger has been failed" << endl;
408 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
415 "set is_active = $1 "
416 "where trigger_id = $2");
420 stmt->
SetInt(0, is_active);
425 cout <<
"ERROR: updating information about trigger has been failed" << endl;
440 cout <<
"Table 'trigger_'";
static ElogConnection * Open()
TSQLServer * GetSQLServer()
static int PrintAll()
print all triggers
int SetTriggerInfo(TString trigger_info)
set trigger info of the current trigger
static int CheckTriggerExists(int trigger_id)
check trigger exists in the database: 1- true, 0 - false, <0 - database operation error
ElogConnection * connectionDB
connection to the database
static ElogTrigger * GetTrigger(int trigger_id)
get trigger from the database
static int DeleteTrigger(int trigger_id)
delete trigger from the database
void Print()
print information about current trigger
int i_trigger_id
trigger id
static ElogTrigger * CreateTrigger(TString trigger_info, bool is_active)
add new trigger to the database
TString str_trigger_info
trigger info
int SetIsActive(bool is_active)
set is active of the current trigger
ElogTrigger(ElogConnection *db_connect, int trigger_id, TString trigger_info, bool is_active)
bool b_is_active
is active
virtual TSQLStatement * Statement(const char *, Int_t=100)
virtual const char * GetString(Int_t)
virtual Bool_t NextIteration()=0
virtual Bool_t NextResultRow()=0
virtual Bool_t SetString(Int_t, const char *, Int_t=256)
virtual Int_t GetInt(Int_t)
virtual Bool_t Process()=0
virtual Bool_t SetInt(Int_t, Int_t)
virtual Bool_t StoreResult()=0
const char * Data() const
static TString Format(const char *fmt,...)