49 if (connDb ==
nullptr)
55 "values ($1, $2, $3, $4)");
59 if (contact_name ==
nullptr)
64 if (phones ==
nullptr)
75 cout <<
"ERROR: inserting new contact to the Database has been failed" << endl;
85 TSQLStatement* stmt_last = db_server->
Statement(
"SELECT currval(pg_get_serial_sequence('contact_','contact_id'))");
94 cout <<
"ERROR: no last ID in DB!" << endl;
98 contact_id = stmt_last->
GetInt(0);
102 cout <<
"ERROR: getting last ID has been failed!" << endl;
108 tmp_contact_id = contact_id;
110 if (contact_name ==
nullptr)
111 tmp_contact_name =
nullptr;
113 tmp_contact_name =
new TString(*contact_name);
115 tmp_contact_desc = contact_desc;
117 if (phones ==
nullptr)
118 tmp_phones =
nullptr;
120 tmp_phones =
new TString(*phones);
122 if (email ==
nullptr)
125 tmp_email =
new TString(*email);
127 return new ElogContact(connDb, tmp_contact_id, tmp_contact_name, tmp_contact_desc, tmp_phones, tmp_email);
134 if (connDb ==
nullptr)
141 "where contact_id = %d",
147 cout <<
"ERROR: getting contact from the database has been failed" << endl;
159 cout <<
"ERROR: contact was not found in the database" << endl;
167 tmp_contact_id = stmt->
GetInt(0);
170 tmp_contact_name =
nullptr;
177 tmp_phones =
nullptr;
188 return new ElogContact(connDb, tmp_contact_id, tmp_contact_name, tmp_contact_desc, tmp_phones, tmp_email);
195 if (connDb ==
nullptr)
202 "where contact_id = %d",
208 cout <<
"ERROR: getting contact from the database has been failed" << endl;
235 if (connDb ==
nullptr)
241 "where contact_id = $1");
245 stmt->
SetInt(0, contact_id);
249 cout <<
"ERROR: deleting contact from the dataBase has been failed" << endl;
265 if (connDb ==
nullptr)
276 cout <<
"ERROR: getting all 'contacts' from the dataBase has been failed" << endl;
287 cout <<
"Table 'contact_':" << endl;
289 cout <<
"contact_id: ";
290 cout << (stmt->
GetInt(0));
291 cout <<
", contact_name: ";
296 cout <<
", contact_desc: ";
298 cout <<
", phones: ";
321 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
328 "set contact_name = $1 "
329 "where contact_id = $2");
333 if (contact_name ==
nullptr)
341 cout <<
"ERROR: updating information about contact has been failed" << endl;
349 if (contact_name ==
nullptr)
361 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
368 "set contact_desc = $1 "
369 "where contact_id = $2");
378 cout <<
"ERROR: updating information about contact has been failed" << endl;
393 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
401 "where contact_id = $2");
405 if (phones ==
nullptr)
413 cout <<
"ERROR: updating information about contact has been failed" << endl;
421 if (phones ==
nullptr)
433 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
441 "where contact_id = $2");
445 if (email ==
nullptr)
453 cout <<
"ERROR: updating information about contact has been failed" << endl;
461 if (email ==
nullptr)
473 cout <<
"Table 'contact_'";
static ElogConnection * Open()
TSQLServer * GetSQLServer()
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 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
static TString Format(const char *fmt,...)