41 fNumIterations(niter),
45 fStmt->setPrefetchMemorySize(1000000);
46 fStmt->setPrefetchRowCount(niter);
47 fStmt->setMaxIterations(niter);
85#define CheckStatement(method, res) \
89 SetError(-1,"Statement is not correctly initialized",method); \
95#define CheckSetPar(method) \
97 CheckStatement(method, kFALSE); \
98 if (!IsParSettMode()) { \
99 SetError(-1,"Parameters cannot be set for this statement", method); \
103 TString errmsg("Invalid parameter number "); \
105 SetError(-1,errmsg.Data(),method); \
110#define CheckGetField(method, defres) \
113 if (!IsResultSet()) { \
114 SetError(-1,"There is no result set for statement", method); \
117 if ((npar < 0) || (npar >= fBufferSize)) { \
118 TString errmsg("Invalid parameter number "); \
120 SetError(-1,errmsg.Data(),method); \
168 fStmt->executeUpdate();
175 }
catch (oracle::occi::SQLException &oraex) {
176 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"Process");
191 return fStmt->getUpdateCount();
192 }
catch (oracle::occi::SQLException &oraex) {
193 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetNumAffectedRows");
207 Info(
"GetParametersNumber",
"Not implemented");
220 fStmt->setNull(npar+1, oracle::occi::OCCIINT);
223 }
catch (oracle::occi::SQLException &oraex) {
224 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetNull");
242 }
catch (oracle::occi::SQLException &oraex) {
243 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetInt");
259 }
catch (oracle::occi::SQLException &oraex) {
260 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetUInt");
274 fStmt->setNumber(npar+1, oracle::occi::Number(
value));
276 }
catch (oracle::occi::SQLException &oraex) {
277 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetLong");
290 fStmt->setNumber(npar+1, oracle::occi::Number((
long double)
value));
292 }
catch (oracle::occi::SQLException &oraex) {
293 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetLong64");
306 fStmt->setNumber(npar+1, oracle::occi::Number((
long double)
value));
308 }
catch (oracle::occi::SQLException &oraex) {
309 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetULong64");
324 }
catch (oracle::occi::SQLException &oraex) {
325 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetDouble");
341 fStmt->setDatabaseNCHARParam(npar+1,
true);
342 fStmt->setMaxParamSize(npar+1, maxsize);
347 }
catch (oracle::occi::SQLException &oraex) {
348 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetString");
364 fStmt->setMaxParamSize(npar+1, maxsize);
366 oracle::occi::Bytes buf((
unsigned char*) mem,
size);
368 fStmt->setBytes(npar+1, buf);
372 }
catch (oracle::occi::SQLException &oraex) {
373 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetBinary");
386 oracle::occi::Date tm =
fStmt->getDate(npar+1);
388 unsigned int o_month, o_day, o_hour, o_minute, o_second;
389 tm.getDate(o_year, o_month, o_day, o_hour, o_minute, o_second);
390 tm.setDate(year, month, day, o_hour, o_minute, o_second);
391 fStmt->setDate(npar+1, tm);
393 }
catch (oracle::occi::SQLException &oraex) {
394 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetDate");
408 oracle::occi::Date tm =
fStmt->getDate(npar+1);
410 unsigned int o_month, o_day, o_hour, o_minute, o_second;
411 tm.getDate(o_year, o_month, o_day, o_hour, o_minute, o_second);
412 tm.setDate(o_year, o_month, o_day, hour, min, sec);
413 fStmt->setDate(npar+1, tm);
415 }
catch (oracle::occi::SQLException &oraex) {
416 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetTime");
430 oracle::occi::Date tm(
fEnv, year, month, day, hour, min, sec);
431 fStmt->setDate(npar+1, tm);
433 }
catch (oracle::occi::SQLException &oraex) {
434 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetDatime");
448 oracle::occi::Timestamp tm(
fEnv, year, month, day, hour, min, sec, frac);
449 fStmt->setTimestamp(npar+1, tm);
451 }
catch (oracle::occi::SQLException &oraex) {
452 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetTimestamp");
466 setVector(
fStmt, npar+1,
value, schemaName, typeName);
468 }
catch (oracle::occi::SQLException &oraex) {
469 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVInt");
483 setVector(
fStmt, npar+1,
value, schemaName, typeName);
485 }
catch (oracle::occi::SQLException &oraex) {
486 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVUInt");
500 std::vector<oracle::occi::Number> nvec;
501 for (std::vector<Long_t>::const_iterator it =
value.begin();
504 nvec.push_back(oracle::occi::Number(*it));
506 setVector(
fStmt, npar+1, nvec, schemaName, typeName);
508 }
catch (oracle::occi::SQLException &oraex) {
509 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVLong");
522 std::vector<oracle::occi::Number> nvec;
523 for (std::vector<Long64_t>::const_iterator it =
value.begin();
526 nvec.push_back(oracle::occi::Number((
long double)*it));
528 setVector(
fStmt, npar+1, nvec, schemaName, typeName);
530 }
catch (oracle::occi::SQLException &oraex) {
531 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVLong64");
544 std::vector<oracle::occi::Number> nvec;
545 for (std::vector<ULong64_t>::const_iterator it =
value.begin();
548 nvec.push_back(oracle::occi::Number((
long double)*it));
550 setVector(
fStmt, npar+1, nvec, schemaName, typeName);
552 }
catch (oracle::occi::SQLException &oraex) {
553 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVULong64");
566 setVector(
fStmt, npar+1,
value, schemaName, typeName);
568 }
catch (oracle::occi::SQLException &oraex) {
569 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVDouble");
585 fStmt->executeUpdate();
589 fStmt->addIteration();
595 }
catch (oracle::occi::SQLException &oraex) {
596 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"NextIteration");
610 if (
fStmt->status() == oracle::occi::Statement::RESULT_SET_AVAILABLE) {
619 }
catch (oracle::occi::SQLException &oraex) {
620 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"StoreResult");
636 fResult->setMaxColumnSize(nfield+1, maxsize);
638 fStmt->setMaxParamSize(nfield+1, maxsize);
640 }
catch (oracle::occi::SQLException &oraex) {
641 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetMaxFieldSize");
664 if (
fBuffer[npar].namebuf.empty())
665 fBuffer[npar].
namebuf = (*fFieldInfo)[npar].getString(oracle::occi::MetaData::ATTR_NAME);
679 SetError(-1,
"There is no result set for statement",
"NextResultRow");
691 if (
fResult->next() == oracle::occi::ResultSet::END_OF_FETCH) {
697 }
catch (oracle::occi::SQLException &oraex) {
698 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"NextResultRow");
700 if (oraex.getErrorCode()==32108)
701 Info(
"NextResultRow",
"Use TSQLStatement::SetMaxFieldSize() to solve a problem");
716 return fResult->isNull(npar+1);
717 }
catch (oracle::occi::SQLException &oraex) {
718 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"IsNull");
736 }
catch (oracle::occi::SQLException &oraex) {
737 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetInt");
754 res =
fResult->getUInt(npar+1);
755 }
catch (oracle::occi::SQLException &oraex) {
756 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetUInt");
775 }
catch (oracle::occi::SQLException &oraex) {
776 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetLong");
794 }
catch (oracle::occi::SQLException &oraex) {
795 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetLong64");
813 }
catch (oracle::occi::SQLException &oraex) {
814 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetULong64");
831 res =
fResult->getDouble(npar+1);
832 }
catch (oracle::occi::SQLException &oraex) {
833 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetDouble");
850 if (
fResult->isNull(npar+1))
return nullptr;
852 int datatype = (*fFieldInfo)[npar].getInt(oracle::occi::MetaData::ATTR_DATA_TYPE);
858 int prec = (*fFieldInfo)[npar].getInt(oracle::occi::MetaData::ATTR_PRECISION);
859 int scale = (*fFieldInfo)[npar].getInt(oracle::occi::MetaData::ATTR_SCALE);
861 if ((scale == 0) || (prec == 0)) {
862 res =
fResult->getString(npar+1);
864 double double_val =
fResult->getDouble(npar+1);
875 res =
fResult->getString(npar+1);
881 case SQLT_TIMESTAMP_TZ:
882 case SQLT_TIMESTAMP_LTZ:
886 res =
fResult->getString(npar+1);
887 Info(
"getString",
"Type %d may not be supported", datatype);
890 int len = res.length();
895 strncpy((
char *)
fBuffer[npar].membuf, res.c_str(),
len+1);
900 }
catch (oracle::occi::SQLException &oraex) {
901 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetString");
920 if (
fBuffer[npar].bufsize >= 0) {
929 int datatype = (*fFieldInfo)[npar].getInt(oracle::occi::MetaData::ATTR_DATA_TYPE);
933 oracle::occi::Bytes parbytes =
fResult->getBytes(npar+1);
935 size = parbytes.length();
944 parbytes.getBytes((
unsigned char *) mem,
size);
951 oracle::occi::Blob parblob =
fResult->getBlob(npar+1);
953 size = parblob.length();
962 parblob.read(
size, (
unsigned char *) mem,
size);
969 oracle::occi::Clob parclob =
fResult->getClob(npar+1);
971 size = parclob.length();
980 parclob.read(
size, (
unsigned char *) mem,
size);
989 oracle::occi::Bfile parbfile =
fResult->getBfile(npar+1);
991 size = parbfile.length();
1000 parbfile.read(
size, (
unsigned char *) mem,
size);
1007 Error(
"GetBinary",
"Oracle data type %d not supported", datatype);
1008 SetError(-1,
"Unsupported type for binary convertion",
"GetBinary");
1014 }
catch (oracle::occi::SQLException &oraex) {
1015 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetBinary");
1027 Int_t hour, min, sec;
1029 return GetDatime(npar, year, month, day, hour, min, sec);
1037 Int_t year, month, day;
1039 return GetDatime(npar, year, month, day, hour, min, sec);
1050 if (!
fResult->isNull(npar+1)) {
1051 int datatype = (*fFieldInfo)[npar].getInt(oracle::occi::MetaData::ATTR_DATA_TYPE);
1053 if (datatype!=SQLT_DAT)
return kFALSE;
1055 oracle::occi::Date tm =
fResult->getDate(npar+1);
1057 unsigned int o_month, o_day, o_hour, o_minute, o_second;
1058 tm.getDate(o_year, o_month, o_day, o_hour, o_minute, o_second);
1059 year = (
Int_t) o_year;
1060 month = (
Int_t) o_month;
1061 day = (
Int_t) o_day;
1062 hour = (
Int_t) o_hour;
1063 min = (
Int_t) o_minute;
1064 sec = (
Int_t) o_second;
1067 }
catch (oracle::occi::SQLException &oraex) {
1068 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetDatime");
1082 if (!
fResult->isNull(npar+1)) {
1083 int datatype = (*fFieldInfo)[npar].getInt(oracle::occi::MetaData::ATTR_DATA_TYPE);
1085 if ((datatype!=SQLT_TIMESTAMP) &&
1086 (datatype!=SQLT_TIMESTAMP_TZ) &&
1087 (datatype!=SQLT_TIMESTAMP_LTZ))
return kFALSE;
1089 oracle::occi::Timestamp tm =
fResult->getTimestamp(npar+1);
1091 unsigned int o_month, o_day, o_hour, o_minute, o_second, o_frac;
1092 tm.getDate(o_year, o_month, o_day);
1093 tm.getTime(o_hour, o_minute, o_second, o_frac);
1094 year = (
Int_t) o_year;
1095 month = (
Int_t) o_month;
1096 day = (
Int_t) o_day;
1097 hour = (
Int_t) o_hour;
1098 min = (
Int_t) o_minute;
1099 sec = (
Int_t) o_second;
1100 frac = (
Int_t) o_frac;
1103 }
catch (oracle::occi::SQLException &oraex) {
1104 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetTimestamp");
1120 }
catch (oracle::occi::SQLException &oraex) {
1121 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVInt");
1136 }
catch (oracle::occi::SQLException &oraex) {
1137 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVUInt");
1150 std::vector<oracle::occi::Number> res;
1152 getVector(
fResult, npar+1, res);
1153 for (std::vector<oracle::occi::Number>::const_iterator it = res.begin();
1159 }
catch (oracle::occi::SQLException &oraex) {
1160 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVLong");
1172 std::vector<oracle::occi::Number> res;
1174 getVector(
fResult, npar+1, res);
1175 for (std::vector<oracle::occi::Number>::const_iterator it = res.begin();
1181 }
catch (oracle::occi::SQLException &oraex) {
1182 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVLong64");
1194 std::vector<oracle::occi::Number> res;
1196 getVector(
fResult, npar+1, res);
1197 for (std::vector<oracle::occi::Number>::const_iterator it = res.begin();
1203 }
catch (oracle::occi::SQLException &oraex) {
1204 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVULong64");
1219 }
catch (oracle::occi::SQLException &oraex) {
1220 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVDouble");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned long long ULong64_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
#define CheckStatement(method, res)
#define CheckSetPar(method)
#define CheckGetField(method, defres)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
TOracleStatement(const TOracleStatement &)=delete
Bool_t SetVInt(Int_t npar, const std::vector< Int_t > value, const char *schemaName, const char *typeName) final
Set vector of integer values for parameter npar.
oracle::occi::Statement * fStmt
UInt_t GetUInt(Int_t npar) final
return field value as unsigned integer
Double_t GetDouble(Int_t npar) final
return field value as double
void SetBufferSize(Int_t size)
Set buffer size, which is used to keep string values of currently fetched column.
Long64_t GetLong64(Int_t npar) final
return field value as 64-bit integer
const char * GetString(Int_t npar) final
return field value as string
Bool_t SetDouble(Int_t npar, Double_t value) final
Set double value for parameter npar.
ULong64_t GetULong64(Int_t npar) final
return field value as unsigned 64-bit integer
Bool_t SetLong64(Int_t npar, Long64_t value) final
Set 64-bit integer value for parameter npar.
Bool_t SetVLong64(Int_t npar, const std::vector< Long64_t > value, const char *schemaName, const char *typeName) final
Set vector of 64-bit integer values for parameter npar.
Bool_t SetUInt(Int_t npar, UInt_t value) final
Set unsigned integer value for parameter npar.
oracle::occi::Environment * fEnv
Bool_t GetVDouble(Int_t npar, std::vector< Double_t > &value) final
return field value as vector of doubles
Bool_t GetVULong64(Int_t npar, std::vector< ULong64_t > &value) final
return field value as vector of unsigned 64-bit integers
Bool_t NextResultRow() final
Move cursor to next row in result set.
Bool_t SetBinary(Int_t npar, void *mem, Long_t size, Long_t maxsize=0x1000) final
set parameter value as binary data
virtual ~TOracleStatement()
Destructor of TOracleStatement clas.
Int_t GetNumFields() final
Returns number of fields in result set.
Bool_t SetTimestamp(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec, Int_t frac=0) final
Set date & time value for parameter npar.
const char * GetFieldName(Int_t nfield) final
Return field name in result set.
Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final
Set date value for parameter npar.
Bool_t GetTime(Int_t npar, Int_t &hour, Int_t &min, Int_t &sec) final
return field value as time
Bool_t GetVLong(Int_t npar, std::vector< Long_t > &value) final
return field value as vector of long integers
Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256) final
Set string value for parameter npar.
Bool_t SetVUInt(Int_t npar, const std::vector< UInt_t > value, const char *schemaName, const char *typeName) final
Set vector of unsigned integer values for parameter npar.
Bool_t SetMaxFieldSize(Int_t nfield, Long_t maxsize) final
Defines maximum size for field which must be used for read or write operation Some Oracle types as LO...
void CloseBuffer()
Destroy buffers, used in data fetching.
Bool_t SetVULong64(Int_t npar, const std::vector< ULong64_t > value, const char *schemaName, const char *typeName) final
Set vector of unsigned 64-bit integer values for parameter npar.
Bool_t GetVUInt(Int_t npar, std::vector< UInt_t > &value) final
return field value as vector of unsigned integers
Bool_t SetULong64(Int_t npar, ULong64_t value) final
Set unsigned 64-bit integer value for parameter npar.
Bool_t SetLong(Int_t npar, Long_t value) final
Set long integer value for parameter npar.
Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final
Set time value for parameter npar.
Bool_t NextIteration() final
Add next iteration for statement with parameters.
Int_t GetInt(Int_t npar) final
return field value as integer
Bool_t IsNull(Int_t) final
Checks if fieled value in result set is NULL.
Bool_t IsParSettMode() const
Bool_t GetVInt(Int_t npar, std::vector< Int_t > &value) final
return field value as vector of integers
Bool_t Process() final
Process SQL statement.
Long_t GetLong(Int_t npar) final
return field value as long integer
Bool_t GetTimestamp(Int_t npar, Int_t &year, Int_t &month, Int_t &day, Int_t &hour, Int_t &min, Int_t &sec, Int_t &frac) final
return field value as date & time
Bool_t SetNull(Int_t npar) final
Set NULL as value of parameter npar.
Int_t GetNumParameters() final
Return number of parameters in statement Not yet implemented for Oracle.
Bool_t SetDatime(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec) final
Set date & time value for parameter npar.
Bool_t GetBinary(Int_t npar, void *&mem, Long_t &size) final
Return field value as binary array Supports LONG, BLOB, CLOB, BFILE, CFILE types of columns Reads com...
void Close(Option_t *="") final
Close Oracle statement Removes and destroys all buffers and metainfo.
oracle::occi::Connection * fConn
Bool_t SetVLong(Int_t npar, const std::vector< Long_t > value, const char *schemaName, const char *typeName) final
Set vector of long integer values for parameter npar.
Bool_t SetVDouble(Int_t npar, const std::vector< Double_t > value, const char *schemaName, const char *typeName) final
Set vector of double values for parameter npar.
Bool_t IsResultSet() const
Bool_t GetDatime(Int_t npar, Int_t &year, Int_t &month, Int_t &day, Int_t &hour, Int_t &min, Int_t &sec) final
return field value as date & time
Bool_t StoreResult() final
Store result of statement processing.
Bool_t GetVLong64(Int_t npar, std::vector< Long64_t > &value) final
return field value as vector of 64-bit integers
Bool_t SetInt(Int_t npar, Int_t value) final
Set integer value for parameter npar.
Int_t GetNumAffectedRows() final
Return number of affected rows after statement Process() was called Make sense for queries like SELEC...
Bool_t GetDate(Int_t npar, Int_t &year, Int_t &month, Int_t &day) final
return field value as date
oracle::occi::ResultSet * fResult
std::vector< oracle::occi::MetaData > * fFieldInfo
static const char * GetFloatFormat()
return current printf format for float/double members, default "%e"
void SetError(Int_t code, const char *msg, const char *method=nullptr)
set new values for error fields if method specified, displays error message
void ClearError()
reset error fields
const char * Data() const