44 fNumIterations(niter),
48 fStmt->setPrefetchMemorySize(1000000);
49 fStmt->setPrefetchRowCount(niter);
50 fStmt->setMaxIterations(niter);
88#define CheckStatement(method, res) \
92 SetError(-1,"Statement is not correctly initialized",method); \
98#define CheckSetPar(method) \
100 CheckStatement(method, kFALSE); \
101 if (!IsParSettMode()) { \
102 SetError(-1,"Parameters cannot be set for this statement", method); \
106 TString errmsg("Invalid parameter number "); \
108 SetError(-1,errmsg.Data(),method); \
113#define CheckGetField(method, defres) \
116 if (!IsResultSet()) { \
117 SetError(-1,"There is no result set for statement", method); \
120 if ((npar<0) || (npar>=fBufferSize)) { \
121 TString errmsg("Invalid parameter number "); \
123 SetError(-1,errmsg.Data(),method); \
171 fStmt->executeUpdate();
178 }
catch (SQLException &oraex) {
179 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"Process");
194 return fStmt->getUpdateCount();
195 }
catch (SQLException &oraex) {
196 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetNumAffectedRows");
210 Info(
"GetParametersNumber",
"Not implemented");
223 fStmt->setNull(npar+1, OCCIINT);
226 }
catch (SQLException &oraex) {
227 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetNull");
242 fStmt->setInt(npar+1, value);
245 }
catch (SQLException &oraex) {
246 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetInt");
260 fStmt->setUInt(npar+1, value);
262 }
catch (SQLException &oraex) {
263 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetUInt");
277 fStmt->setNumber(npar+1, Number(value));
279 }
catch (SQLException &oraex) {
280 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetLong");
293 fStmt->setNumber(npar+1, Number((
long double)value));
295 }
catch (SQLException &oraex) {
296 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetLong64");
309 fStmt->setNumber(npar+1, Number((
long double)value));
311 }
catch (SQLException &oraex) {
312 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetULong64");
325 fStmt->setDouble(npar+1, value);
327 }
catch (SQLException &oraex) {
328 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetDouble");
344 fStmt->setDatabaseNCHARParam(npar+1,
true);
345 fStmt->setMaxParamSize(npar+1, maxsize);
348 fStmt->setString(npar+1, value);
350 }
catch (SQLException &oraex) {
351 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetString");
367 fStmt->setMaxParamSize(npar+1, maxsize);
369 Bytes buf((
unsigned char*) mem,
size);
371 fStmt->setBytes(npar+1, buf);
375 }
catch (SQLException &oraex) {
376 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetBinary");
389 Date tm =
fStmt->getDate(npar+1);
391 unsigned int o_month, o_day, o_hour, o_minute, o_second;
392 tm.getDate(o_year, o_month, o_day, o_hour, o_minute, o_second);
393 tm.setDate(year, month, day, o_hour, o_minute, o_second);
394 fStmt->setDate(npar+1, tm);
396 }
catch (SQLException &oraex) {
397 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetDate");
411 Date tm =
fStmt->getDate(npar+1);
413 unsigned int o_month, o_day, o_hour, o_minute, o_second;
414 tm.getDate(o_year, o_month, o_day, o_hour, o_minute, o_second);
415 tm.setDate(o_year, o_month, o_day, hour, min, sec);
416 fStmt->setDate(npar+1, tm);
418 }
catch (SQLException &oraex) {
419 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetTime");
433 Date tm(
fEnv, year, month, day, hour, min, sec);
434 fStmt->setDate(npar+1, tm);
436 }
catch (SQLException &oraex) {
437 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetDatime");
451 Timestamp tm(
fEnv, year, month, day, hour, min, sec, frac);
452 fStmt->setTimestamp(npar+1, tm);
454 }
catch (SQLException &oraex) {
455 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetTimestamp");
469 setVector(
fStmt, npar+1, value, schemaName, typeName);
471 }
catch (SQLException &oraex) {
472 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVInt");
486 setVector(
fStmt, npar+1, value, schemaName, typeName);
488 }
catch (SQLException &oraex) {
489 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVUInt");
503 std::vector<Number> nvec;
504 for (std::vector<Long_t>::const_iterator it = value.begin();
507 nvec.push_back(Number(*it));
509 setVector(
fStmt, npar+1, nvec, schemaName, typeName);
511 }
catch (SQLException &oraex) {
512 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVLong");
525 std::vector<Number> nvec;
526 for (std::vector<Long64_t>::const_iterator it = value.begin();
529 nvec.push_back(Number((
long double)*it));
531 setVector(
fStmt, npar+1, nvec, schemaName, typeName);
533 }
catch (SQLException &oraex) {
534 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVLong64");
547 std::vector<Number> nvec;
548 for (std::vector<ULong64_t>::const_iterator it = value.begin();
551 nvec.push_back(Number((
long double)*it));
553 setVector(
fStmt, npar+1, nvec, schemaName, typeName);
555 }
catch (SQLException &oraex) {
556 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVULong64");
569 setVector(
fStmt, npar+1, value, schemaName, typeName);
571 }
catch (SQLException &oraex) {
572 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetVDouble");
588 fStmt->executeUpdate();
592 fStmt->addIteration();
598 }
catch (SQLException &oraex) {
599 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"NextIteration");
613 if (
fStmt->status() == Statement::RESULT_SET_AVAILABLE) {
622 }
catch (SQLException &oraex) {
623 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"StoreResult");
639 fResult->setMaxColumnSize(nfield+1, maxsize);
641 fStmt->setMaxParamSize(nfield+1, maxsize);
643 }
catch (SQLException &oraex) {
644 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"SetMaxFieldSize");
667 if (
fBuffer[npar].namebuf.empty())
668 fBuffer[npar].
namebuf = (*fFieldInfo)[npar].getString(MetaData::ATTR_NAME);
682 SetError(-1,
"There is no result set for statement",
"NextResultRow");
696 if (
fResult->next() == oracle::occi::ResultSet::END_OF_FETCH) {
702 }
catch (SQLException &oraex) {
703 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"NextResultRow");
705 if (oraex.getErrorCode()==32108)
706 Info(
"NextResultRow",
"Use TSQLStatement::SetMaxFieldSize() to solve a problem");
721 return fResult->isNull(npar+1);
722 }
catch (SQLException &oraex) {
723 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"IsNull");
741 }
catch (SQLException &oraex) {
742 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetInt");
759 res =
fResult->getUInt(npar+1);
760 }
catch (SQLException &oraex) {
761 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetUInt");
780 }
catch (SQLException &oraex) {
781 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetLong");
799 }
catch (SQLException &oraex) {
800 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetLong64");
818 }
catch (SQLException &oraex) {
819 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetULong64");
836 res =
fResult->getDouble(npar+1);
837 }
catch (SQLException &oraex) {
838 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetDouble");
855 if (
fResult->isNull(npar+1))
return 0;
857 int datatype = (*fFieldInfo)[npar].getInt(MetaData::ATTR_DATA_TYPE);
863 int prec = (*fFieldInfo)[npar].getInt(MetaData::ATTR_PRECISION);
864 int scale = (*fFieldInfo)[npar].getInt(MetaData::ATTR_SCALE);
866 if ((scale == 0) || (prec == 0)) {
867 res =
fResult->getString(npar+1);
869 double double_val =
fResult->getDouble(npar+1);
880 res =
fResult->getString(npar+1);
886 case SQLT_TIMESTAMP_TZ:
887 case SQLT_TIMESTAMP_LTZ:
891 res =
fResult->getString(npar+1);
892 Info(
"getString",
"Type %d may not be supported", datatype);
895 int len = res.length();
900 strncpy((
char *)
fBuffer[npar].membuf, res.c_str(), len+1);
905 }
catch (SQLException &oraex) {
906 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetString");
925 if (
fBuffer[npar].bufsize >= 0) {
934 int datatype = (*fFieldInfo)[npar].getInt(MetaData::ATTR_DATA_TYPE);
938 Bytes parbytes =
fResult->getBytes(npar+1);
940 size = parbytes.length();
949 parbytes.getBytes((
unsigned char *) mem,
size);
956 Blob parblob =
fResult->getBlob(npar+1);
958 size = parblob.length();
967 parblob.read(
size, (
unsigned char *) mem,
size);
974 Clob parclob =
fResult->getClob(npar+1);
976 size = parclob.length();
985 parclob.read(
size, (
unsigned char *) mem,
size);
994 Bfile parbfile =
fResult->getBfile(npar+1);
996 size = parbfile.length();
1005 parbfile.read(
size, (
unsigned char *) mem,
size);
1012 Error(
"GetBinary",
"Oracle data type %d not supported", datatype);
1013 SetError(-1,
"Unsupported type for binary convertion",
"GetBinary");
1019 }
catch (SQLException &oraex) {
1020 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetBinary");
1032 Int_t hour, min, sec;
1034 return GetDatime(npar, year, month, day, hour, min, sec);
1042 Int_t year, month, day;
1044 return GetDatime(npar, year, month, day, hour, min, sec);
1055 if (!
fResult->isNull(npar+1)) {
1056 int datatype = (*fFieldInfo)[npar].getInt(MetaData::ATTR_DATA_TYPE);
1058 if (datatype!=SQLT_DAT)
return kFALSE;
1060 Date tm =
fResult->getDate(npar+1);
1062 unsigned int o_month, o_day, o_hour, o_minute, o_second;
1063 tm.getDate(o_year, o_month, o_day, o_hour, o_minute, o_second);
1064 year = (
Int_t) o_year;
1065 month = (
Int_t) o_month;
1066 day = (
Int_t) o_day;
1067 hour = (
Int_t) o_hour;
1068 min = (
Int_t) o_minute;
1069 sec = (
Int_t) o_second;
1072 }
catch (SQLException &oraex) {
1073 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetDatime");
1087 if (!
fResult->isNull(npar+1)) {
1088 int datatype = (*fFieldInfo)[npar].getInt(MetaData::ATTR_DATA_TYPE);
1090 if ((datatype!=SQLT_TIMESTAMP) &&
1091 (datatype!=SQLT_TIMESTAMP_TZ) &&
1092 (datatype!=SQLT_TIMESTAMP_LTZ))
return kFALSE;
1094 Timestamp tm =
fResult->getTimestamp(npar+1);
1096 unsigned int o_month, o_day, o_hour, o_minute, o_second, o_frac;
1097 tm.getDate(o_year, o_month, o_day);
1098 tm.getTime(o_hour, o_minute, o_second, o_frac);
1099 year = (
Int_t) o_year;
1100 month = (
Int_t) o_month;
1101 day = (
Int_t) o_day;
1102 hour = (
Int_t) o_hour;
1103 min = (
Int_t) o_minute;
1104 sec = (
Int_t) o_second;
1105 frac = (
Int_t) o_frac;
1108 }
catch (SQLException &oraex) {
1109 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetTimestamp");
1123 getVector(
fResult, npar+1, value);
1125 }
catch (SQLException &oraex) {
1126 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVInt");
1139 getVector(
fResult, npar+1, value);
1141 }
catch (SQLException &oraex) {
1142 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVUInt");
1155 std::vector<Number> res;
1157 getVector(
fResult, npar+1, res);
1158 for (std::vector<Number>::const_iterator it = res.begin();
1161 value.push_back((
Long_t)*it);
1164 }
catch (SQLException &oraex) {
1165 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVLong");
1177 std::vector<Number> res;
1179 getVector(
fResult, npar+1, res);
1180 for (std::vector<Number>::const_iterator it = res.begin();
1183 value.push_back((
Long_t)*it);
1186 }
catch (SQLException &oraex) {
1187 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVLong64");
1199 std::vector<Number> res;
1201 getVector(
fResult, npar+1, res);
1202 for (std::vector<Number>::const_iterator it = res.begin();
1208 }
catch (SQLException &oraex) {
1209 SetError(oraex.getErrorCode(), oraex.getMessage().c_str(),
"GetVULong64");
1222 getVector(
fResult, npar+1, value);
1224 }
catch (SQLException &oraex) {
1225 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
#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