41 if (connDb ==
nullptr)
47 "values ($1, $2, $3)");
52 stmt->
SetInt(1, parameter_type);
57 cout <<
"ERROR: inserting new parameter to the Database has been failed" << endl;
68 db_server->
Statement(
"SELECT currval(pg_get_serial_sequence('parameter_','parameter_id'))");
77 cout <<
"ERROR: no last ID in DB!" << endl;
81 parameter_id = stmt_last->
GetInt(0);
85 cout <<
"ERROR: getting last ID has been failed!" << endl;
91 tmp_parameter_id = parameter_id;
93 tmp_parameter_name = parameter_name;
94 int tmp_parameter_type;
95 tmp_parameter_type = parameter_type;
97 tmp_is_array = is_array;
99 return new UniParameter(connDb, tmp_parameter_id, tmp_parameter_name, tmp_parameter_type, tmp_is_array);
106 if (connDb ==
nullptr)
113 "where parameter_id = %d",
119 cout <<
"ERROR: getting parameter from the database has been failed" << endl;
131 cout <<
"ERROR: parameter was not found in the database" << endl;
138 int tmp_parameter_id;
139 tmp_parameter_id = stmt->
GetInt(0);
142 int tmp_parameter_type;
143 tmp_parameter_type = stmt->
GetInt(2);
145 tmp_is_array = stmt->
GetInt(3);
149 return new UniParameter(connDb, tmp_parameter_id, tmp_parameter_name, tmp_parameter_type, tmp_is_array);
156 if (connDb ==
nullptr)
163 "where lower(parameter_name) = lower('%s')",
164 parameter_name.Data());
169 cout <<
"ERROR: getting parameter from the database has been failed" << endl;
181 cout <<
"ERROR: parameter was not found in the database" << endl;
188 int tmp_parameter_id;
189 tmp_parameter_id = stmt->
GetInt(0);
192 int tmp_parameter_type;
193 tmp_parameter_type = stmt->
GetInt(2);
195 tmp_is_array = stmt->
GetInt(3);
199 return new UniParameter(connDb, tmp_parameter_id, tmp_parameter_name, tmp_parameter_type, tmp_is_array);
206 if (connDb ==
nullptr)
213 "where parameter_id = %d",
219 cout <<
"ERROR: getting parameter from the database has been failed" << endl;
246 if (connDb ==
nullptr)
253 "where lower(parameter_name) = lower('%s')",
254 parameter_name.Data());
259 cout <<
"ERROR: getting parameter from the database has been failed" << endl;
286 if (connDb ==
nullptr)
292 "where parameter_id = $1");
296 stmt->
SetInt(0, parameter_id);
300 cout <<
"ERROR: deleting parameter from the dataBase has been failed" << endl;
316 if (connDb ==
nullptr)
322 "where lower(parameter_name) = lower($1)");
330 cout <<
"ERROR: deleting parameter from the DataBase has been failed" << endl;
346 if (connDb ==
nullptr)
357 cout <<
"ERROR: getting all 'parameters' from the dataBase has been failed" << endl;
368 cout <<
"Table 'parameter_':" << endl;
370 cout <<
"parameter_id: ";
371 cout << (stmt->
GetInt(0));
372 cout <<
", parameter_name: ";
374 cout <<
", parameter_type: ";
375 cout << (stmt->
GetInt(2));
376 cout <<
", is_array: ";
377 cout << (stmt->
GetInt(3));
391 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
398 "set parameter_name = $1 "
399 "where parameter_id = $2");
408 cout <<
"ERROR: updating information about parameter has been failed" << endl;
423 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
430 "set parameter_type = $1 "
431 "where parameter_id = $2");
435 stmt->
SetInt(0, parameter_type);
440 cout <<
"ERROR: updating information about parameter has been failed" << endl;
455 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
463 "where parameter_id = $2");
467 stmt->
SetInt(0, is_array);
472 cout <<
"ERROR: updating information about parameter has been failed" << endl;
487 cout <<
"Table 'parameter_'";
503 "where lower(parameter_name) = lower('%s')",
504 parameter_name.Data());
509 cout <<
"ERROR: getting a record with the parameter from 'parameter_' table has been failed" << endl;
518 cout <<
"ERROR: the parameter with name '" << parameter_name <<
"' was not found" << endl;
523 parameter_id = stmt->
GetInt(0);
524 int parameter_type = stmt->
GetInt(2);
528 if (parameter_type != enum_parameter_type) {
529 cout <<
"ERROR: '" << parameter_name <<
"' parameter has not the same type (type = " << parameter_type
530 <<
", but " << enum_parameter_type <<
" used)" << endl;
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
static TString Format(const char *fmt,...)
static UniConnection * Open()
TSQLServer * GetSQLServer()
static int DeleteParameter(int parameter_id)
delete parameter from the database
static bool CheckAndGetParameterID(TSQLServer *db_server, TString parameter_name, enumValueType enum_parameter_type, int ¶meter_id)
static UniParameter * GetParameter(int parameter_id)
get parameter from the database
int SetParameterName(TString parameter_name)
set parameter name of the current parameter
void Print()
print information about current parameter
UniConnection * connectionDB
connection to the database
int i_parameter_type
parameter type
UniParameter(UniConnection *db_connect, int parameter_id, TString parameter_name, int parameter_type, bool is_array)
int SetIsArray(bool is_array)
set is array of the current parameter
static int PrintAll()
print all parameters
int i_parameter_id
parameter id
int SetParameterType(int parameter_type)
set parameter type of the current parameter
static UniParameter * CreateParameter(TString parameter_name, int parameter_type, bool is_array)
add new parameter to the database
TString str_parameter_name
parameter name
static int CheckParameterExists(int parameter_id)
check parameter exists in the database: 1- true, 0 - false, <0 - database operation error