43 if (connDb ==
nullptr)
49 "values ($1, $2, $3)");
54 stmt->
SetInt(1, is_active);
62 cout <<
"ERROR: inserting new person to the Database has been failed" << endl;
72 TSQLStatement* stmt_last = db_server->
Statement(
"SELECT currval(pg_get_serial_sequence('person_','person_id'))");
81 cout <<
"ERROR: no last ID in DB!" << endl;
89 cout <<
"ERROR: getting last ID has been failed!" << endl;
95 tmp_person_id = person_id;
97 tmp_person_name = person_name;
99 tmp_is_active = is_active;
101 if (email ==
nullptr)
104 tmp_email =
new TString(*email);
106 return new ElogPerson(connDb, tmp_person_id, tmp_person_name, tmp_is_active, tmp_email);
113 if (connDb ==
nullptr)
120 "where person_id = %s",
126 cout <<
"ERROR: getting person from the database has been failed" << endl;
138 cout <<
"ERROR: person was not found in the database" << endl;
150 tmp_is_active = stmt->
GetInt(2);
159 return new ElogPerson(connDb, tmp_person_id, tmp_person_name, tmp_is_active, tmp_email);
166 if (connDb ==
nullptr)
173 "where person_id = %s",
179 cout <<
"ERROR: getting person from the database has been failed" << endl;
206 if (connDb ==
nullptr)
212 "where person_id = $1");
220 cout <<
"ERROR: deleting person from the dataBase has been failed" << endl;
236 if (connDb ==
nullptr)
247 cout <<
"ERROR: getting all 'persons' from the dataBase has been failed" << endl;
258 cout <<
"Table 'person_':" << endl;
260 cout <<
"person_id: ";
262 cout <<
", person_name: ";
264 cout <<
", is_active: ";
265 cout << (stmt->
GetInt(2));
284 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
291 "set person_name = $1 "
292 "where person_id = $2");
301 cout <<
"ERROR: updating information about person has been failed" << endl;
316 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
323 "set is_active = $1 "
324 "where person_id = $2");
328 stmt->
SetInt(0, is_active);
333 cout <<
"ERROR: updating information about person has been failed" << endl;
348 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
356 "where person_id = $2");
360 if (email ==
nullptr)
368 cout <<
"ERROR: updating information about person has been failed" << endl;
376 if (email ==
nullptr)
388 cout <<
"Table 'person_'";
402 if (connDb ==
nullptr) {
403 cout <<
"ERROR: connection to the eLog Database was failed" << endl;
411 "where lower(person_name) like lower('%s')",
412 person_name_part.
Data());
417 cout <<
"ERROR: getting person from the database has been failed" << endl;
432 if (connRecord ==
nullptr) {
433 cout <<
"ERROR: connection to the eLog database for a record was failed" << endl;
442 tmp_is_active = stmt->
GetInt(2);
449 arrayResult->
Add((
TObject*)
new ElogPerson(connDb, tmp_person_id, tmp_person_name, tmp_is_active, tmp_email));
462 if (connDb ==
nullptr)
469 "where lower(person_name) like lower('%s')",
470 person_name_part.
Data());
475 cout <<
"ERROR: checking persons in the database has been failed" << endl;
492 int person_count = stmt->
GetInt(0);
505 if (connDb ==
nullptr)
511 "where lower(person_name) like lower($1)");
519 cout <<
"ERROR: deleting persons from the database has been failed" << endl;
532 return deleted_count;
static ElogConnection * Open()
TSQLServer * GetSQLServer()
static int CheckPersonExistsByName(TString person_name_part)
check persons exists in the database by name or its part: >=1 - person count, 0 - false,...
bool b_is_active
is active
int SetIsActive(bool is_active)
set is active of the current person
static ElogPerson * CreatePerson(TString person_name, bool is_active, TString *email)
add new person to the database
static int PrintAll()
print all persons
static int DeletePersonByName(TString person_name_part)
delete persons from the database by name or its part >=1 - affected count, 0 - persons not found,...
static TObjArray * GetPersonByName(TString person_name_part)
get persons from the database by name or its part
static ElogPerson * GetPerson(TString person_id)
get person from the database
void Print()
print information about current person
int SetEmail(TString *email)
set email of the current person
ElogConnection * connectionDB
connection to the database
int SetPersonName(TString person_name)
set person name of the current person
static int CheckPersonExists(TString person_id)
check person exists in the database: 1 - true, 0 - false, <0 - database operation error
static int DeletePerson(TString person_id)
delete person from the database
TString str_person_name
person name
ElogPerson(ElogConnection *db_connect, TString person_id, TString person_name, bool is_active, TString *email)
TString str_person_id
person id
virtual void SetOwner(Bool_t enable=kTRUE)
void Add(TObject *obj) override
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 Int_t GetNumAffectedRows()
virtual Bool_t SetString(Int_t, const char *, Int_t=256)
virtual Int_t GetInt(Int_t)
virtual Bool_t IsNull(Int_t)
virtual Bool_t Process()=0
virtual Bool_t SetInt(Int_t, Int_t)
virtual Bool_t SetNull(Int_t)
virtual Bool_t StoreResult()=0
const char * Data() const
static TString Format(const char *fmt,...)