11#if QT_CONFIG(regularexpression)
19#include <QtSql/private/qsqlcachedresult_p.h>
20#include <QtSql/private/qsqldriver_p.h>
22#if QT_CONFIG(timezone)
29#if defined(__MINGW64_VERSION_MAJOR) && defined(_WIN64)
37#define QOCI_DYNAMIC_CHUNK_SIZE 65535
38#define QOCI_PREFETCH_MEM 10240
54using namespace
Qt::StringLiterals;
56#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
62#ifdef OCI_ATTR_CHARSET_FORM
67static const ub1 qOraCharsetForm = SQLCS_NCHAR;
70#if defined (OCI_UTF16ID)
110 OCIDescriptorAlloc (env,
reinterpret_cast<dvoid **
>(&
id),
111 OCI_DTYPE_ROWID, 0, 0);
117 OCIDescriptorFree(
id, OCI_DTYPE_ROWID);
132 OCIDescriptorAlloc(env,
reinterpret_cast<void**
>(&
dateTime), OCI_DTYPE_TIMESTAMP_TZ, 0, 0);
137 const QString timeZone = dt.toString(
"ttt"_L1);
138 const OraText *
tz =
reinterpret_cast<const OraText *
>(timeZone.
utf16());
141 const_cast<OraText *
>(
tz), timeZone.
length() *
sizeof(
QChar));
148 OCIDescriptorFree(
dateTime, OCI_DTYPE_TIMESTAMP_TZ);
154 ub1 month, day, hour, minute, second;
156 sb1 tzHour, tzMinute;
158 OCIDateTimeGetDate(env, err,
dateTime, &year, &month, &day);
159 OCIDateTimeGetTime(env, err,
dateTime, &hour, &minute, &second, &nsec);
160 OCIDateTimeGetTimeZoneOffset(env, err,
dateTime, &tzHour, &tzMinute);
161 int secondsOffset = (
qAbs(tzHour) * 60 + tzMinute) * 60;
163 secondsOffset = -secondsOffset;
214 bool exec() override;
239 OCIError *err =
nullptr;
241 OCIStmt *sql =
nullptr;
246 void setStatementAttributes();
247 int bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err,
int pos,
263#ifdef OCI_ATTR_CHARSET_FORM
268 const_cast<void *
>(
static_cast<const void *
>(&qOraCharsetForm)),
270 OCI_ATTR_CHARSET_FORM,
276 qWarning(
"QOCIResultPrivate::setCharset: Couldn't set OCI_ATTR_CHARSET_FORM.");
284 const_cast<void *
>(
static_cast<const void *
>(&
qOraCharset)),
289 qOraWarning(
"QOCIResultPrivate::setCharsetI Couldn't set OCI_ATTR_CHARSET_ID: ", err);
300 if (prefetchRows >= 0) {
305 OCI_ATTR_PREFETCH_ROWS,
308 qOraWarning(
"QOCIResultPrivate::setStatementAttributes:"
309 " Couldn't set OCI_ATTR_PREFETCH_ROWS: ", err);
311 if (prefetchMem >= 0) {
316 OCI_ATTR_PREFETCH_MEMORY,
319 qOraWarning(
"QOCIResultPrivate::setStatementAttributes:"
320 " Couldn't set OCI_ATTR_PREFETCH_MEMORY: ", err);
328 void *
data =
const_cast<void *
>(
val.constData());
330 switch (
val.typeId()) {
331 case QMetaType::QByteArray:
332 r = OCIBindByPos(sql, hbnd, err,
335 ?
const_cast<char *
>(
reinterpret_cast<QByteArray *
>(
data)->constData())
338 SQLT_BIN, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
340 case QMetaType::QTime:
341 case QMetaType::QDate:
342 case QMetaType::QDateTime: {
344 r = OCIBindByPos(sql, hbnd, err,
347 sizeof(OCIDateTime *),
348 SQLT_TIMESTAMP_TZ, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
353 r = OCIBindByPos(sql, hbnd, err,
357 const_cast<void *
>(
data),
359 SQLT_INT, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
361 case QMetaType::UInt:
362 r = OCIBindByPos(sql, hbnd, err,
366 const_cast<void *
>(
data),
368 SQLT_UIN, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
370 case QMetaType::LongLong:
373 r = OCIBindByPos(sql, hbnd, err,
377 SQLT_VNU, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
381 case QMetaType::ULongLong:
384 r = OCIBindByPos(sql, hbnd, err,
388 SQLT_VNU, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
392 case QMetaType::Double:
393 r = OCIBindByPos(sql, hbnd, err,
397 const_cast<void *
>(
data),
399 SQLT_FLT, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
401 case QMetaType::QString: {
403 if (isBinaryValue(
pos)) {
404 r = OCIBindByPos(sql, hbnd, err,
406 const_cast<ushort *
>(
s.utf16()),
407 s.length() *
sizeof(
QChar),
408 SQLT_LNG, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
410 }
else if (!isOutValue(
pos)) {
412 r = OCIBindByPos(sql, hbnd, err,
415 const_cast<ushort *
>(
s.utf16()),
416 (
s.length() + 1) *
sizeof(
QChar),
417 SQLT_STR, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
418 if (
r == OCI_SUCCESS)
419 setCharset(*hbnd, OCI_HTYPE_BIND);
429 r = OCIBindByPos(sql, hbnd, err,
432 const_cast<OCIRowid **
>(&rptr->id),
434 SQLT_RDD, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
442 QByteArray ba(
reinterpret_cast<const char *
>(
s.utf16()), (
s.length() + 1) *
sizeof(
QChar));
443 if (isOutValue(
pos)) {
446 r = OCIBindByPos(sql, hbnd, err,
450 SQLT_STR, indPtr, tmpSize, 0, 0, 0, OCI_DEFAULT);
452 r = OCIBindByPos(sql, hbnd, err,
456 SQLT_STR, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
458 if (
r == OCI_SUCCESS)
459 setCharset(*hbnd, OCI_HTYPE_BIND);
465 if (
r != OCI_SUCCESS)
474 for (
int i = 0;
i <
values.count(); ++
i) {
479 OCIBind * hbnd =
nullptr;
480 sb2 *indPtr = &indicators[
i];
483 bindValue(sql, &hbnd, err,
i,
val, indPtr, &tmpSizes[
i], tmpStorage);
491 switch (
value.typeId()) {
492 case QMetaType::QTime:
496 case QMetaType::QDate:
500 case QMetaType::QDateTime:
504 case QMetaType::LongLong:
507 case QMetaType::ULongLong:
510 case QMetaType::QString:
522 for (
int i = 0;
i <
values.count(); ++
i) {
529 auto typ =
values.at(
i).metaType();
530 if (indicators[
i] == -1)
547 int r = OCIHandleAlloc(
env,
548 reinterpret_cast<void **
>(&
err),
551 if (
r != OCI_SUCCESS)
552 qWarning(
"QOCIDriver: unable to allocate error handle");
582 *errorCode = errcode;
583 return QString(
reinterpret_cast<const QChar *
>(errbuf));
620 if (ocitype ==
"VARCHAR2"_L1 || ocitype ==
"VARCHAR"_L1
622 || ocitype ==
"CHAR"_L1 || ocitype ==
"NVARCHAR2"_L1
623 || ocitype ==
"NCHAR"_L1)
624 type = QMetaType::QString;
625 else if (ocitype ==
"NUMBER"_L1
626 || ocitype ==
"FLOAT"_L1
627 || ocitype ==
"BINARY_FLOAT"_L1
628 || ocitype ==
"BINARY_DOUBLE"_L1) {
629 switch(precisionPolicy) {
631 type = QMetaType::Int;
634 type = QMetaType::LongLong;
637 type = QMetaType::Double;
641 type = QMetaType::QString;
645 else if (ocitype ==
"LONG"_L1 || ocitype ==
"NCLOB"_L1 || ocitype ==
"CLOB"_L1)
646 type = QMetaType::QByteArray;
647 else if (ocitype ==
"RAW"_L1 || ocitype ==
"LONG RAW"_L1
648 || ocitype ==
"ROWID"_L1 || ocitype ==
"BLOB"_L1
649 || ocitype ==
"CFILE"_L1 || ocitype ==
"BFILE"_L1)
650 type = QMetaType::QByteArray;
651 else if (ocitype ==
"DATE"_L1 || ocitype.
startsWith(
"TIME"_L1))
652 type = QMetaType::QDateTime;
653 else if (ocitype ==
"UNDEFINED"_L1)
672#ifdef SQLT_INTERVAL_YM
673 case SQLT_INTERVAL_YM:
675#ifdef SQLT_INTERVAL_DS
676 case SQLT_INTERVAL_DS:
678 type = QMetaType::QString;
681 type = QMetaType::Int;
687 switch(precisionPolicy) {
689 type = QMetaType::Int;
692 type = QMetaType::LongLong;
695 type = QMetaType::Double;
699 type = QMetaType::QString;
714 type = QMetaType::QByteArray;
719 case SQLT_TIMESTAMP_TZ:
720 case SQLT_TIMESTAMP_LTZ:
721 type = QMetaType::QDateTime;
724 qWarning(
"qDecodeOCIType: unknown OCI datatype: %d", ocitype);
754 OCINumberFromInt(err,
758 reinterpret_cast<OCINumber*
>(
ba.
data()));
771 OCINumberFromInt(err,
775 reinterpret_cast<OCINumber*
>(
ba.
data()));
782 OCINumberToInt(err,
reinterpret_cast<const OCINumber *
>(ociNumber),
sizeof(
qlonglong),
783 OCI_NUMBER_SIGNED, &qll);
790 OCINumberToInt(err,
reinterpret_cast<const OCINumber *
>(ociNumber),
sizeof(
qulonglong),
791 OCI_NUMBER_UNSIGNED, &qull);
817 OraFieldInf() :
data(0),
len(0), ind(0), oraType(0), def(0), lob(0), dataPtr(
nullptr)
834QOCICols::OraFieldInf::~OraFieldInf()
838 int r = OCIDescriptorFree(lob, OCI_DTYPE_LOB);
840 qWarning(
"QOCICols: Cannot free LOB descriptor");
844 case QMetaType::QDate:
845 case QMetaType::QTime:
846 case QMetaType::QDateTime: {
847 int r = OCIDescriptorFree(dataPtr, OCI_DTYPE_TIMESTAMP_TZ);
848 if (
r != OCI_SUCCESS)
849 qWarning(
"QOCICols: Cannot free OCIDateTime descriptor");
859 : fieldInf(
size),
d(dp)
862 OCIDefine *dfn =
nullptr;
865 OCIParam *
param =
nullptr;
869 parmStatus = OCIParamGet(d->
sql,
872 reinterpret_cast<void **
>(&
param),
875 while (parmStatus == OCI_SUCCESS) {
879#ifdef SQLT_INTERVAL_YM
880#ifdef SQLT_INTERVAL_DS
881 else if (ofi.
oraType == SQLT_INTERVAL_YM || ofi.
oraType == SQLT_INTERVAL_DS)
891 dataSize = (38 + 1) *
sizeof(utext);
896 fieldInf[idx].typ = ofi.
type;
897 fieldInf[idx].oraType = ofi.
oraType;
901 case QMetaType::QDateTime:
902 r = OCIDescriptorAlloc(d->
env, (
void **)&fieldInf[idx].dataPtr, OCI_DTYPE_TIMESTAMP_TZ, 0, 0);
903 if (
r != OCI_SUCCESS) {
904 qWarning(
"QOCICols: Unable to allocate the OCIDateTime descriptor");
907 r = OCIDefineByPos(d->
sql,
911 &fieldInf[idx].dataPtr,
912 sizeof(OCIDateTime *),
914 &(fieldInf[idx].ind),
917 case QMetaType::Double:
918 r = OCIDefineByPos(d->
sql,
922 create(idx,
sizeof(
double) - 1),
925 &(fieldInf[idx].ind),
929 r = OCIDefineByPos(d->
sql,
936 &(fieldInf[idx].ind),
939 case QMetaType::LongLong:
940 r = OCIDefineByPos(d->
sql,
944 create(idx,
sizeof(OCINumber)),
947 &(fieldInf[idx].ind),
950 case QMetaType::QByteArray:
954 r = OCIDefineByPos(d->
sql,
961 &(fieldInf[idx].ind),
962 0, 0, OCI_DYNAMIC_FETCH);
963 }
else if (ofi.
oraType == SQLT_LBI) {
965 r = OCIDefineByPos(d->
sql,
972 &(fieldInf[idx].ind),
973 0, 0, OCI_DYNAMIC_FETCH);
974 }
else if (ofi.
oraType == SQLT_CLOB) {
975 r = OCIDefineByPos(d->
sql,
979 createLobLocator(idx, d->
env),
982 &(fieldInf[idx].ind),
986 r = OCIDefineByPos(d->
sql,
990 createLobLocator(idx, d->
env),
993 &(fieldInf[idx].ind),
997 case QMetaType::QString:
999 r = OCIDefineByPos(d->
sql,
1006 &(fieldInf[idx].ind),
1007 0, 0, OCI_DYNAMIC_FETCH);
1011 r = OCIDefineByPos(d->
sql,
1018 &(fieldInf[idx].ind),
1028 r = OCIDefineByPos(d->
sql,
1035 &(fieldInf[idx].ind),
1041 fieldInf[idx].def = dfn;
1044 parmStatus = OCIParamGet(d->
sql,
1047 reinterpret_cast<void **
>(&
param),
1058 char*
c =
new char[
size+1];
1060 memset(
c, 0,
size+1);
1066OCILobLocator **QOCICols::createLobLocator(
int position,
OCIEnv* env)
1068 OCILobLocator *& lob = fieldInf[
position].lob;
1069 int r = OCIDescriptorAlloc(env,
1070 reinterpret_cast<void **
>(&lob),
1075 qWarning(
"QOCICols: Cannot create LOB locator");
1096 r = OCIStmtGetPieceInfo(d->
sql, d->
err,
reinterpret_cast<void **
>(&dfn), &typep,
1097 &in_outp, &iterp, &idxp, &piecep);
1098 if (
r != OCI_SUCCESS)
1099 qOraWarning(
"OCIResultPrivate::readPiecewise: unable to get piece info:", d->
err);
1101 bool isStringField = fieldInf.
at(fieldNum).oraType == SQLT_LNG;
1104 r = OCIStmtSetPieceInfo(dfn, OCI_HTYPE_DEFINE,
1106 &chunkSize, piecep, NULL, NULL);
1107 if (
r != OCI_SUCCESS)
1108 qOraWarning(
"OCIResultPrivate::readPiecewise: unable to set piece info:", d->
err);
1109 status = OCIStmtFetch (d->
sql, d->
err, 1, OCI_FETCH_NEXT, OCI_DEFAULT);
1112 OCIErrorGet(d->
err, 1, 0, &errcode, 0, 0,OCI_HTYPE_ERROR);
1118 qOraWarning(
"OCIResultPrivate::readPiecewise: unable to fetch next:", d->
err);
1122 if (status == OCI_NO_DATA)
1124 if (nullField || !chunkSize) {
1125 fieldInf[fieldNum].ind = -1;
1127 if (isStringField) {
1131 fieldInf[fieldNum].ind = 0;
1136 memcpy(
ba.
data() + sz,
reinterpret_cast<char *
>(col), chunkSize);
1138 fieldInf[fieldNum].ind = 0;
1141 }
while (status == OCI_SUCCESS_WITH_INFO || status == OCI_NEED_DATA);
1149 text *colName =
nullptr;
1153 ub2 colFieldLength(0);
1154 sb2 colPrecision(0);
1185#ifdef OCI_ATTR_CHAR_SIZE
1196 colFieldLength = colLength;
1235 if (
type.id() == QMetaType::Int) {
1236 if ((colLength == 22 && colPrecision == 0 && colScale == 0) || colScale > 0)
1241 if (((colType == SQLT_FLT) || (colType == SQLT_NUM))
1247 if ((colType == SQLT_NUM) || (colType == SQLT_VNU) || (colType == SQLT_UIN)
1248 || (colType == SQLT_INT)) {
1255 if (colType == SQLT_BLOB)
1259 ofi.
name =
QString(
reinterpret_cast<const QChar*
>(colName), colNameLen / 2);
1297 delete[]
col[
j].lengths;
1298 delete[]
col[
j].indicators;
1308 int columnCount = boundValues.
count();
1309 if (boundValues.
isEmpty() || columnCount == 0)
1313 qDebug() <<
"columnCount:" << columnCount << boundValues;
1320 for (
i = 0;
i < columnCount; ++
i) {
1330 for (
i = 0;
i < columnCount; ++
i) {
1332 if (boundValues.
at(
i).
typeId() != QMetaType::QVariantList) {
1339 r =
d->bindValue(
d->sql, &singleCol.
bindh,
d->err,
i,
1340 boundValues.
at(
i), singleCol.
indicators, &tmpSizes[
i], tmpStorage);
1342 if (
r != OCI_SUCCESS &&
r != OCI_SUCCESS_WITH_INFO) {
1343 qOraWarning(
"QOCIPrivate::execBatch: unable to bind column:",
d->err);
1345 "Unable to bind column for batch execute"),
1360 switch (fieldTypes[
i].
id()) {
1361 case QMetaType::QTime:
1362 case QMetaType::QDate:
1363 case QMetaType::QDateTime:
1364 col.
bindAs = SQLT_TIMESTAMP_TZ;
1365 col.
maxLen =
sizeof(OCIDateTime *);
1368 case QMetaType::Int:
1370 col.
maxLen =
sizeof(int);
1373 case QMetaType::UInt:
1378 case QMetaType::LongLong:
1380 col.
maxLen =
sizeof(OCINumber);
1383 case QMetaType::ULongLong:
1385 col.
maxLen =
sizeof(OCINumber);
1388 case QMetaType::Double:
1390 col.
maxLen =
sizeof(double);
1393 case QMetaType::QString: {
1397 if (
d->isOutValue(
i))
1407 case QMetaType::QByteArray:
1411 col.
maxLen =
sizeof(OCIRowid*);
1415 if (
d->isOutValue(
i))
1435 columns[
i].indicators[
row] = -1;
1436 columns[
i].lengths[
row] = 0;
1438 columns[
i].indicators[
row] = 0;
1439 char *dataPtr = columns[
i].
data + (columns[
i].maxLen *
row);
1440 switch (fieldTypes[
i].
id()) {
1441 case QMetaType::QTime:
1442 case QMetaType::QDate:
1443 case QMetaType::QDateTime:{
1444 columns[
i].lengths[
row] = columns[
i].maxLen;
1446 *
reinterpret_cast<OCIDateTime**
>(dataPtr) =
date->dateTime;
1450 case QMetaType::Int:
1451 columns[
i].lengths[
row] = columns[
i].maxLen;
1452 *
reinterpret_cast<int*
>(dataPtr) =
val.toInt();
1455 case QMetaType::UInt:
1456 columns[
i].lengths[
row] = columns[
i].maxLen;
1457 *
reinterpret_cast<uint*
>(dataPtr) =
val.toUInt();
1460 case QMetaType::LongLong:
1462 columns[
i].lengths[
row] = columns[
i].maxLen;
1468 case QMetaType::ULongLong:
1470 columns[
i].lengths[
row] = columns[
i].maxLen;
1476 case QMetaType::Double:
1477 columns[
i].lengths[
row] = columns[
i].maxLen;
1478 *
reinterpret_cast<double*
>(dataPtr) =
val.toDouble();
1481 case QMetaType::QString: {
1483 columns[
i].lengths[
row] = (
s.length() + 1) *
sizeof(
QChar);
1484 memcpy(dataPtr,
s.utf16(), columns[
i].lengths[
row]);
1487 case QMetaType::QByteArray:
1492 *
reinterpret_cast<OCIRowid**
>(dataPtr) = rptr->id;
1493 columns[
i].lengths[
row] = 0;
1510 qDebug(
"OCIBindByPos(%p, %p, %p, %d, %p, %d, %d, %p, %p, 0, %d, %p, OCI_DEFAULT)",
1511 d->sql, &bindColumn.
bindh,
d->err,
i + 1, bindColumn.
data,
1515 for (
int ii = 0; ii < (int)bindColumn.
recordCount; ++ii) {
1516 qDebug(
" record %d: indicator %d, length %d", ii, bindColumn.
indicators[ii],
1524 d->sql, &bindColumn.
bindh,
d->err,
i + 1,
1532 arrayBind ? &bindColumn.
curelep : 0,
1536 qDebug(
"After OCIBindByPos: r = %d, bindh = %p",
r, bindColumn.
bindh);
1539 if (
r != OCI_SUCCESS &&
r != OCI_SUCCESS_WITH_INFO) {
1540 qOraWarning(
"QOCIPrivate::execBatch: unable to bind column:",
d->err);
1542 "Unable to bind column for batch execute"),
1547 r = OCIBindArrayOfStruct (
1548 columns[
i].bindh,
d->err,
1550 sizeof(columns[
i].indicators[0]),
1551 sizeof(columns[
i].lengths[0]),
1554 if (
r != OCI_SUCCESS &&
r != OCI_SUCCESS_WITH_INFO) {
1555 qOraWarning(
"QOCIPrivate::execBatch: unable to bind column:",
d->err);
1557 "Unable to bind column for batch execute"),
1564 r = OCIStmtExecute(
d->svc,
d->sql,
d->err,
1565 arrayBind ? 1 : columns[0].recordCount,
1567 d->transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS);
1569 if (
r != OCI_SUCCESS &&
r != OCI_SUCCESS_WITH_INFO) {
1570 qOraWarning(
"QOCIPrivate::execBatch: unable to execute batch statement:",
d->err);
1572 "Unable to execute batch statement"),
1578 for (
i = 0;
i < columnCount; ++
i) {
1580 if (!
d->isOutValue(
i))
1583 if (
auto tp = boundValues.
at(
i).
metaType(); tp.id() != QMetaType::QVariantList) {
1585 if (*columns[
i].indicators == -1)
1593 for (
uint r = 0;
r < columns[
i].recordCount; ++
r){
1595 if (columns[
i].indicators[
r] == -1) {
1600 switch(columns[
i].bindAs) {
1602 case SQLT_TIMESTAMP_TZ:
1604 *
reinterpret_cast<OCIDateTime **
>(
data +
r * columns[
i].maxLen));
1607 (*list)[
r] = *
reinterpret_cast<int*
>(
data +
r * columns[
i].maxLen);
1611 (*list)[
r] = *
reinterpret_cast<uint*
>(
data +
r * columns[
i].maxLen);
1617 case QMetaType::LongLong:
1620 case QMetaType::ULongLong:
1630 (*list)[
r] = *
reinterpret_cast<double*
>(
data +
r * columns[
i].maxLen);
1635 +
r * columns[
i].maxLen));
1645 d->q_func()->setSelect(
false);
1647 d->q_func()->setActive(
true);
1653template<
class T,
int sz>
1661 r = OCILobCharSetForm(
d->env,
d->err, lob, &csfrm);
1662 if (
r != OCI_SUCCESS) {
1663 qOraWarning(
"OCIResultPrivate::readLobs: Couldn't get LOB char set form: ",
d->err);
1668 r = OCILobGetLength(
d->svc,
d->err, lob, &amount);
1669 if (
r == OCI_SUCCESS) {
1676 qOraWarning(
"OCIResultPrivate::readLobs: Couldn't get LOB length: ",
d->err);
1684 r = OCILobRead(
d->svc,
1697 if (
r != OCI_SUCCESS)
1698 qOraWarning(
"OCIResultPrivate::readLOBs: Cannot read LOB: ",
d->err);
1706 int r = OCI_SUCCESS;
1708 for (
int i = 0;
i <
size(); ++
i) {
1709 const OraFieldInf &
fi = fieldInf.
at(
i);
1710 if (
fi.ind == -1 || !(lob =
fi.lob))
1713 bool isClob =
fi.oraType == SQLT_CLOB;
1718 r = qReadLob<QString, sizeof(QChar)>(
str, d, lob);
1722 r = qReadLob<QByteArray, sizeof(char)>(
buf, d, lob);
1725 if (
r == OCI_SUCCESS)
1735 for (
int i = 0;
i < fieldInf.
count(); ++
i) {
1736 if (fieldInf.
at(
i).def ==
d)
1744 for (
int i = 0;
i < fieldInf.
size(); ++
i) {
1745 const OraFieldInf &fld = fieldInf.
at(
i);
1747 if (fld.ind == -1) {
1753 if (fld.oraType == SQLT_BIN || fld.oraType == SQLT_LBI || fld.oraType == SQLT_LNG)
1756 switch (fld.typ.id()) {
1757 case QMetaType::QDateTime:
1759 reinterpret_cast<OCIDateTime *
>(fld.dataPtr)));
1761 case QMetaType::Double:
1762 case QMetaType::Int:
1763 case QMetaType::LongLong:
1766 && (fld.typ.id() == QMetaType::Double)) {
1767 v[
index +
i] = *
reinterpret_cast<double *
>(fld.data);
1770 && (fld.typ.id() == QMetaType::LongLong)) {
1772 int r = OCINumberToInt(d->
err,
reinterpret_cast<OCINumber *
>(fld.data),
sizeof(
qint64),
1773 OCI_NUMBER_SIGNED, &qll);
1774 if (
r == OCI_SUCCESS)
1780 && (fld.typ.id() == QMetaType::Int)) {
1781 v[
index +
i] = *
reinterpret_cast<int *
>(fld.data);
1786 case QMetaType::QString:
1789 case QMetaType::QByteArray:
1796 qWarning(
"QOCICols::value: unknown data type");
1804 env(drv_d_func()->env),
1805 svc(const_cast<
OCISvcCtx*&>(drv_d_func()->svc)),
1806 transaction(drv_d_func()->transaction),
1807 serverVersion(drv_d_func()->serverVersion),
1808 prefetchRows(drv_d_func()->prefetchRows),
1809 prefetchMem(drv_d_func()->prefetchMem)
1812 int r = OCIHandleAlloc(
env,
1813 reinterpret_cast<void **
>(&
err),
1816 if (
r != OCI_SUCCESS)
1817 qWarning(
"QOCIResult: unable to alloc error handle");
1824 if (
sql && OCIHandleFree(
sql, OCI_HTYPE_STMT) != OCI_SUCCESS)
1825 qWarning(
"~QOCIResult: unable to free statement handle");
1827 if (OCIHandleFree(
err, OCI_HTYPE_ERROR) != OCI_SUCCESS)
1828 qWarning(
"~QOCIResult: unable to free error report handle");
1862 bool piecewise =
false;
1863 int r = OCI_SUCCESS;
1864 r = OCIStmtFetch(
d->sql,
d->err, 1, OCI_FETCH_NEXT, OCI_DEFAULT);
1867 return r == OCI_SUCCESS ||
r == OCI_SUCCESS_WITH_INFO;
1872 case OCI_SUCCESS_WITH_INFO:
1873 qOraWarning(
"QOCIResult::gotoNext: SuccessWithInfo: ",
d->err);
1893 "Unable to goto next"),
1899 if (
r == OCI_SUCCESS && piecewise)
1902 if (
r == OCI_SUCCESS)
1904 if (
r == OCI_SUCCESS)
1906 if (
r != OCI_SUCCESS)
1908 return r == OCI_SUCCESS ||
r == OCI_SUCCESS_WITH_INFO;
1940 r = OCIHandleFree(
d->sql, OCI_HTYPE_STMT);
1941 if (
r == OCI_SUCCESS)
1944 qOraWarning(
"QOCIResult::prepare: unable to free statement handle:",
d->err);
1946 if (
query.isEmpty())
1948 r = OCIHandleAlloc(
d->env,
1949 reinterpret_cast<void **
>(&
d->sql),
1952 if (
r != OCI_SUCCESS) {
1953 qOraWarning(
"QOCIResult::prepare: unable to alloc statement:",
d->err);
1958 d->setStatementAttributes();
1959 const OraText *
txt =
reinterpret_cast<const OraText *
>(
query.utf16());
1961 r = OCIStmtPrepare(
d->sql,
1967 if (
r != OCI_SUCCESS) {
1968 qOraWarning(
"QOCIResult::prepare: unable to prepare statement:",
d->err);
1987 r = OCIAttrGet(
d->sql,
1994 if (
r != OCI_SUCCESS &&
r != OCI_SUCCESS_WITH_INFO) {
1995 qOraWarning(
"QOCIResult::exec: Unable to get statement type:",
d->err);
2004 iters = stmtType == OCI_STMT_SELECT ? 0 : 1;
2005 mode =
d->transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS;
2009 &&
d->bindValues(
boundValues(), indicators, tmpSizes, tmpStorage) != OCI_SUCCESS) {
2010 qOraWarning(
"QOCIResult::exec: unable to bind value: ",
d->err);
2020 r = OCIStmtExecute(
d->svc,
2028 if (
r != OCI_SUCCESS &&
r != OCI_SUCCESS_WITH_INFO) {
2029 qOraWarning(
"QOCIResult::exec: unable to execute statement:",
d->err);
2038 if (stmtType == OCI_STMT_SELECT) {
2040 int r = OCIAttrGet(
d->sql, OCI_HTYPE_STMT,
reinterpret_cast<void **
>(&parmCount),
2041 0, OCI_ATTR_PARAM_COUNT,
d->err);
2042 if (
r == 0 && !
d->cols)
2064 return d->cols->rec;
2073 int r = OCIAttrGet(
d->sql, OCI_HTYPE_STMT,
ptr.constData()->id,
2074 0, OCI_ATTR_ROWID,
d->err);
2075 if (
r == OCI_SUCCESS)
2112 const ub4
mode = OCI_UTF16 | OCI_OBJECT | OCI_THREADED;
2114 const ub4
mode = OCI_UTF16 | OCI_OBJECT;
2116 int r = OCIEnvCreate(&
d->env,
2125 qWarning(
"QOCIDriver: unable to create environment");
2131 d->allocErrorHandle();
2141 d->allocErrorHandle();
2154 int r = OCIHandleFree(
d->err, OCI_HTYPE_ERROR);
2155 if (
r != OCI_SUCCESS)
2156 qWarning(
"Unable to free Error handle: %d",
r);
2157 r = OCIHandleFree(
d->env, OCI_HTYPE_ENV);
2158 if (
r != OCI_SUCCESS)
2159 qWarning(
"Unable to free Environment handle: %d",
r);
2183 return d->serverVersion >= 9;
2191 for (
const auto tmp : opts) {
2193 if ((idx = tmp.indexOf(u
'=')) == -1) {
2194 qWarning(
"QOCIDriver::parseArgs: Invalid parameter: '%s'",
2195 tmp.toLocal8Bit().constData());
2201 if (
opt ==
"OCI_ATTR_PREFETCH_ROWS"_L1) {
2202 d->prefetchRows =
val.toInt(&
ok);
2204 d->prefetchRows = -1;
2205 }
else if (
opt ==
"OCI_ATTR_PREFETCH_MEMORY"_L1) {
2206 d->prefetchMem =
val.toInt(&
ok);
2208 d->prefetchMem = -1;
2209 }
else if (
opt ==
"OCI_AUTH_MODE"_L1) {
2210 if (
val ==
"OCI_SYSDBA"_L1) {
2211 d->authMode = OCI_SYSDBA;
2212 }
else if (
val ==
"OCI_SYSOPER"_L1) {
2213 d->authMode = OCI_SYSOPER;
2214 }
else if (
val !=
"OCI_DEFAULT"_L1) {
2215 qWarning(
"QOCIDriver::parseArgs: Unsupported value for OCI_AUTH_MODE: '%s'",
2216 val.toLocal8Bit().constData());
2219 qWarning(
"QOCIDriver::parseArgs: Invalid parameter: '%s'",
2220 opt.toLocal8Bit().constData());
2248 r = OCIHandleAlloc(
d->env,
reinterpret_cast<void **
>(&
d->srvhp), OCI_HTYPE_SERVER, 0,
nullptr);
2249 if (
r == OCI_SUCCESS) {
2250 r = OCIServerAttach(
d->srvhp,
d->err,
2251 reinterpret_cast<const OraText *
>(connectionString.
utf16()),
2252 connectionString.
length() *
sizeof(
QChar), OCI_DEFAULT);
2255 if (
r == OCI_SUCCESS ||
r == OCI_SUCCESS_WITH_INFO) {
2256 r = OCIHandleAlloc(
d->env,
reinterpret_cast<void **
>(&
d->svc), OCI_HTYPE_SVCCTX,
2259 if (
r == OCI_SUCCESS)
2260 r = OCIAttrSet(
d->svc, OCI_HTYPE_SVCCTX,
d->srvhp, 0, OCI_ATTR_SERVER,
d->err);
2262 if (
r == OCI_SUCCESS) {
2263 r = OCIHandleAlloc(
d->env,
reinterpret_cast<void **
>(&
d->authp), OCI_HTYPE_SESSION,
2266 if (
r == OCI_SUCCESS) {
2267 r = OCIAttrSet(
d->authp, OCI_HTYPE_SESSION,
const_cast<ushort *
>(user.
utf16()),
2268 user.
length() *
sizeof(
QChar), OCI_ATTR_USERNAME,
d->err);
2270 if (
r == OCI_SUCCESS) {
2271 r = OCIAttrSet(
d->authp, OCI_HTYPE_SESSION,
const_cast<ushort *
>(password.
utf16()),
2272 password.
length() *
sizeof(
QChar), OCI_ATTR_PASSWORD,
d->err);
2275 if (
r == OCI_SUCCESS) {
2276 r = OCIHandleAlloc(
d->env,
reinterpret_cast<void **
>(&
d->trans), OCI_HTYPE_TRANS,
2279 if (
r == OCI_SUCCESS)
2280 r = OCIAttrSet(
d->svc, OCI_HTYPE_SVCCTX,
d->trans, 0, OCI_ATTR_TRANS,
d->err);
2282 if (
r == OCI_SUCCESS) {
2284 r = OCISessionBegin(
d->svc,
d->err,
d->authp, OCI_CRED_EXT,
d->authMode);
2286 r = OCISessionBegin(
d->svc,
d->err,
d->authp, OCI_CRED_RDBMS,
d->authMode);
2288 if (
r == OCI_SUCCESS ||
r == OCI_SUCCESS_WITH_INFO)
2289 r = OCIAttrSet(
d->svc, OCI_HTYPE_SVCCTX,
d->authp, 0, OCI_ATTR_SESSION,
d->err);
2291 if (
r != OCI_SUCCESS) {
2295 OCIHandleFree(
d->trans, OCI_HTYPE_TRANS);
2298 OCIHandleFree(
d->authp, OCI_HTYPE_SESSION);
2301 OCIHandleFree(
d->svc, OCI_HTYPE_SVCCTX);
2304 OCIHandleFree(
d->srvhp, OCI_HTYPE_SERVER);
2311 r = OCIServerVersion(
d->svc,
2313 reinterpret_cast<OraText *
>(vertxt),
2317 qWarning(
"QOCIDriver::open: could not get Oracle server version.");
2320 versionStr =
QString(
reinterpret_cast<const QChar *
>(vertxt));
2321#if QT_CONFIG(regularexpression)
2323 if (
match.hasMatch())
2324 d->serverVersion =
match.captured(1).toInt();
2326 if (
d->serverVersion == 0)
2327 d->serverVersion = -1;
2343 OCISessionEnd(
d->svc,
d->err,
d->authp, OCI_DEFAULT);
2344 OCIServerDetach(
d->srvhp,
d->err, OCI_DEFAULT);
2345 OCIHandleFree(
d->trans, OCI_HTYPE_TRANS);
2347 OCIHandleFree(
d->authp, OCI_HTYPE_SESSION);
2349 OCIHandleFree(
d->svc, OCI_HTYPE_SVCCTX);
2351 OCIHandleFree(
d->srvhp, OCI_HTYPE_SERVER);
2366 qWarning(
"QOCIDriver::beginTransaction: Database not open");
2369 int r = OCITransStart(
d->svc,
2372 OCI_TRANS_READWRITE);
2373 if (
r == OCI_ERROR) {
2379 d->transaction =
true;
2387 qWarning(
"QOCIDriver::commitTransaction: Database not open");
2390 int r = OCITransCommit(
d->svc,
2393 if (
r == OCI_ERROR) {
2399 d->transaction =
false;
2407 qWarning(
"QOCIDriver::rollbackTransaction: Database not open");
2410 int r = OCITransRollback(
d->svc,
2413 if (
r == OCI_ERROR) {
2414 qOraWarning(
"QOCIDriver::rollbackTransaction:",
d->err);
2419 d->transaction =
false;
2430 static const char sysUsers[][8] = {
2439 static const char joinC[][4] = {
"or" ,
"and" };
2440 static constexpr char16_t bang[] = { u
' ', u
'!' };
2445 result.reserve(
sizeof sysUsers /
sizeof *sysUsers *
2447 (9 +
sizeof *sysUsers + 5));
2448 for (
const auto &sysUser : sysUsers) {
2451 result +=
"owner "_L1 + bang[
e] +
"= '"_L1 + l1 +
"' "_L1 + join + u
' ';
2474 t.setForwardOnly(
true);
2476 const auto tableQuery =
"select owner, table_name from all_tables where "_L1;
2478 t.exec(tableQuery + where);
2480 if (
t.value(0).toString().toUpper() != user.
toUpper())
2481 tl.append(
t.value(0).toString() + u
'.' +
t.value(1).toString());
2483 tl.append(
t.value(1).toString());
2487 const auto synonymQuery =
"select owner, synonym_name from all_synonyms where "_L1;
2488 t.exec(synonymQuery + where);
2490 if (
t.value(0).toString() !=
d->user)
2491 tl.append(
t.value(0).toString() + u
'.' +
t.value(1).toString());
2493 tl.append(
t.value(1).toString());
2497 const auto query =
"select owner, view_name from all_views where "_L1;
2501 if (
t.value(0).toString().toUpper() !=
d->user.toUpper())
2502 tl.append(
t.value(0).toString() + u
'.' +
t.value(1).toString());
2504 tl.append(
t.value(1).toString());
2508 t.exec(
"select table_name from dictionary"_L1);
2510 tl.append(
t.value(0).toString());
2512 const auto tableQuery =
"select owner, table_name from all_tables where "_L1;
2514 t.exec(tableQuery + where);
2516 if (
t.value(0).toString().toUpper() != user.
toUpper())
2517 tl.append(
t.value(0).toString() + u
'.' +
t.value(1).toString());
2519 tl.append(
t.value(1).toString());
2523 const auto synonymQuery =
"select owner, synonym_name from all_synonyms where "_L1;
2524 t.exec(synonymQuery + where);
2526 if (
t.value(0).toString() !=
d->user)
2527 tl.append(
t.value(0).toString() + u
'.' +
t.value(1).toString());
2529 tl.append(
t.value(1).toString());
2541 *owner = tname.
left(
i);
2557 QString stmt(
"select column_name, data_type, data_length, "
2558 "data_precision, data_scale, nullable, data_default%1"
2559 "from all_tab_columns a "_L1);
2560 if (
d->serverVersion >= 9)
2561 stmt = stmt.
arg(
", char_length "_L1);
2563 stmt = stmt.
arg(
" "_L1);
2564 bool buildRecordInfo =
false;
2573 tmpStmt = stmt +
"where a.table_name='"_L1 +
table + u
'\'';
2583 tmpStmt +=
" and a.owner='"_L1 + owner + u
'\'';
2584 t.setForwardOnly(
true);
2587 stmt = stmt +
" join all_synonyms b on a.owner=b.table_owner and a.table_name=b.table_name "
2588 "where b.owner='"_L1 + owner +
"' and b.synonym_name='"_L1 +
table + u
'\'';
2589 t.setForwardOnly(
true);
2592 buildRecordInfo =
true;
2594 buildRecordInfo =
true;
2597 <<
"BINARY_DOUBLE"_L1;
2598 if (buildRecordInfo) {
2602 f.setRequired(
t.value(5).toString() ==
"N"_L1);
2603 f.setPrecision(
t.value(4).toInt());
2604 if (
d->serverVersion >= 9 && (
ty.id() == QMetaType::QString) && !
t.isNull(3) && !
keywords.contains(
t.value(1).toString())) {
2606 f.setLength(
t.value(7).toInt());
2608 f.setLength(
t.value(
t.isNull(3) ? 2 : 3).
toInt());
2610 f.setDefaultValue(
t.value(6));
2624 QString stmt(
"select b.column_name, b.index_name, a.table_name, a.owner "
2625 "from all_constraints a, all_ind_columns b "
2626 "where a.constraint_type='P' "
2627 "and b.index_name = a.index_name "
2628 "and b.index_owner = a.owner"_L1);
2630 bool buildIndex =
false;
2639 tmpStmt = stmt +
" and a.table_name='"_L1 +
table + u
'\'';
2649 tmpStmt +=
" and a.owner='"_L1 + owner + u
'\'';
2650 t.setForwardOnly(
true);
2654 stmt +=
" and a.table_name=(select tname from sys.synonyms where sname='"_L1
2655 +
table +
"' and creator=a.owner)"_L1;
2656 t.setForwardOnly(
true);
2659 owner =
t.value(3).toString();
2668 idx.
setName(
t.value(1).toString());
2670 tt.
exec(
"select data_type from all_tab_columns where table_name='"_L1 +
2671 t.value(2).toString() +
"' and column_name='"_L1 +
2672 t.value(0).toString() +
"' and owner='"_L1 +
2687 switch (field.
typeID()) {
2688 case QMetaType::QDateTime: {
2699 +
"','YYYY-MM-DD HH24:MI:SS')"_L1;
2701 datestring =
"NULL"_L1;
2705 case QMetaType::QTime: {
2709 datestring =
"TO_DATE('"_L1
2713 +
"','HH24:MI:SS')"_L1;
2715 datestring =
"NULL"_L1;
2719 case QMetaType::QDate: {
2728 datestring =
"NULL"_L1;
2759 return d->serverVersion > 12 ? 128 : 30;
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
void reserve(qsizetype size)
Attempts to allocate memory for at least size bytes.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
char at(qsizetype i) const
Returns the byte at index position i in the byte array.
qsizetype capacity() const
Returns the maximum number of bytes that can be stored in the byte array without forcing a reallocati...
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
\inmodule QtCore\reentrant
QTime time() const
Returns the time part of the datetime.
bool isValid() const
Returns true if this datetime represents a definite moment, otherwise false.
QDate date() const
Returns the date part of the datetime.
\inmodule QtCore \reentrant
constexpr bool isValid() const
Returns true if this date is valid; otherwise returns false.
int month() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int day() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int year() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr void chop(qsizetype n)
constexpr qsizetype size() const noexcept
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
T value(qsizetype i) const
qsizetype count() const noexcept
void append(parameter_type t)
int readPiecewise(QVariantList &values, int index=0)
int fieldFromDefine(OCIDefine *d)
void getValues(QVariantList &v, int index)
int readLOBs(QVariantList &values, int index=0)
static bool execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool arrayBind)
QOCICols(int size, QOCIResultPrivate *dp)
static QDateTime fromOCIDateTime(OCIEnv *env, OCIError *err, OCIDateTime *dt)
QOCIDateTime(OCIEnv *env, OCIError *err, const QDateTime &dt=QDateTime())
QString formatValue(const QSqlField &field, bool trimStrings) const override
Returns a string representation of the field value for the database.
bool rollbackTransaction() override
This function is called to rollback a transaction.
int maximumIdentifierLength(IdentifierType type) const override
QStringList tables(QSql::TableType) const override
Returns a list of the names of the tables in the database.
QSqlIndex primaryIndex(const QString &tablename) const override
Returns the primary index for table tableName.
bool open(const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts) override
Derived classes must reimplement this pure virtual function to open a database connection on database...
bool hasFeature(DriverFeature f) const override
Returns true if the driver supports feature feature; otherwise returns false.
bool commitTransaction() override
This function is called to commit a transaction.
bool beginTransaction() override
This function is called to begin a transaction.
QSqlRecord record(const QString &tablename) const override
Returns a QSqlRecord populated with the names of the fields in table tableName.
QSqlResult * createResult() const override
Creates an empty SQL result on the database.
QVariant handle() const override
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
void close() override
Derived classes must reimplement this pure virtual function in order to close the database connection...
QOCIDriver(QObject *parent=nullptr)
QString escapeIdentifier(const QString &identifier, IdentifierType) const override
Returns the identifier escaped according to the database rules.
void setCharset(dvoid *handle, ub4 type) const
void setStatementAttributes()
QOCIResultPrivate(QOCIResult *q, const QOCIDriver *drv)
bool isOutValue(int i) const
int bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, int pos, const QVariant &val, dvoid *indPtr, ub2 *tmpSize, TempStorage &tmpStorage)
int bindValues(QVariantList &values, IndicatorArray &indicators, SizeArray &tmpSizes, TempStorage &tmpStorage)
bool isBinaryValue(int i) const
void outValues(QVariantList &values, IndicatorArray &indicators, TempStorage &tmpStorage)
bool execBatch(bool arrayBind=false) override
QOCIResult(const QOCIDriver *db)
int numRowsAffected() override
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
QSqlRecord record() const override
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
bool exec() override
Executes the query, returning true if successful; otherwise returns false.
bool reset(const QString &query) override
Sets the result to use the SQL statement query for subsequent data retrieval.
bool prepare(const QString &query) override
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
int size() override
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
QVariant handle() const override
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
bool gotoNext(ValueCache &values, int index) override
void virtual_hook(int id, void *data) override
bool fetchNext() override
Positions the result to the next available record (row) in the result.
QVariant lastInsertId() const override
Returns the object ID of the most recent inserted row if the database supports it.
\inmodule QtCore \reentrant
QRegularExpressionMatch match(const QString &subject, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
Attempts to match the regular expression against the given subject string, starting at the position o...
void virtual_hook(int id, void *data) override
bool fetchNext() override
Positions the result to the next available record (row) in the result.
QSqlDriver::DbmsType dbmsType
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
virtual QString formatValue(const QSqlField &field, bool trimStrings=false) const
Returns a string representation of the field value for the database.
IdentifierType
This enum contains a list of SQL identifier types.
virtual QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
DriverFeature
This enum contains a list of features a driver might support.
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database.
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
virtual bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
virtual void setOpen(bool o)
This function sets the open state of the database to open.
The QSqlError class provides SQL database error information.
ErrorType type() const
Returns the error type, or -1 if the type cannot be determined.
ErrorType
This enum type describes the context in which the error occurred, e.g., a connection error,...
The QSqlField class manipulates the fields in SQL database tables and views.
QVariant value() const
Returns the value of the field as a QVariant.
The QSqlIndex class provides functions to manipulate and describe database indexes.
void setName(const QString &name)
Sets the name of the index to name.
void append(const QSqlField &field)
Appends the field field to the list of indexed fields.
The QSqlQuery class provides a means of executing and manipulating SQL statements.
bool next()
Retrieves the next record in the result, if available, and positions the query on the retrieved recor...
QVariant value(int i) const
Returns the value of field index in the current record.
void setForwardOnly(bool forward)
Sets forward only mode to forward.
bool exec(const QString &query)
Executes the SQL in query.
The QSqlRecord class encapsulates a database record.
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
static bool isVariantNull(const QVariant &variant)
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases.
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false.
int at() const
Returns the current (zero-based) row position of the result.
virtual bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index.
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
QString lastQuery() const
Returns the current SQL query text, or an empty string if there isn't one.
bool hasOutValues() const
Returns true if at least one of the query's bound values is a QSql::Out or a QSql::InOut; otherwise r...
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active.
QVariantList & boundValues(QT6_DECL_NEW_OVERLOAD)
void resetBindCount()
Resets the number of bind parameters.
QSqlError lastError() const
Returns the last error associated with the result.
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
int boundValueCount() const
Returns the number of bound values in the result.
virtual void bindValue(int pos, const QVariant &val, QSql::ParamType type)
Binds the value val of parameter type paramType to position index in the current record (row).
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
QStringView trimmed() const noexcept
Strips leading and trailing whitespace and returns the result.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString right(qsizetype n) const
Returns a substring that contains the n rightmost characters of the string.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString & replace(qsizetype i, qsizetype len, QChar after)
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
qsizetype capacity() const
Returns the maximum number of characters that can be stored in the string without forcing a reallocat...
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QByteArray toLocal8Bit() const &
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString toUpper() const &
qsizetype length() const
Returns the number of characters in this string.
static QTimeZone fromSecondsAheadOfUtc(int offset)
\inmodule QtCore \reentrant
int hour() const
Returns the hour part (0 to 23) of the time.
int minute() const
Returns the minute part (0 to 59) of the time.
int msec() const
Returns the millisecond part (0 to 999) of the time.
int second() const
Returns the second part (0 to 59) of the time.
void * data()
Returns a pointer to the contained object as a generic void* that can be written to.
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has userType() \l QMetaType::QDateTime,...
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has userType() \l QMetaType::QVariantList.
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
int typeId() const
Returns the storage type of the value stored in the variant.
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
QDate toDate() const
Returns the variant as a QDate if the variant has userType() \l QMetaType::QDate, \l QMetaType::QDate...
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
QMetaType metaType() const
qDeleteAll(list.begin(), list.end())
static const struct @480 keywords[]
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static ControlElement< T > * ptr(QWidget *widget)
constexpr T qAbs(const T &t)
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLsizei GLenum GLenum GLuint GLenum GLsizei * lengths
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum const GLint * param
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void * table
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static void split(QT_FT_Vector *b)
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
static QString make_where_clause(const QString &user, Expression e)
int qReadLob(T &buf, const QOCIResultPrivate *d, OCILobLocator *lob)
QSharedDataPointer< QOCIRowId > QOCIRowIdPointer
#define QOCI_PREFETCH_MEM
static void qOraOutValue(QVariant &value, TempStorage &tmpStorage, OCIEnv *env, OCIError *err)
static qlonglong qMakeLongLong(const char *ociNumber, OCIError *err)
static QString qOraWarn(OCIError *err, int *errorCode=0)
static qulonglong qMakeULongLong(const char *ociNumber, OCIError *err)
static void qOraWarning(const char *msg, OCIError *err)
#define QOCI_DYNAMIC_CHUNK_SIZE
static void qParseOpts(const QString &options, QOCIDriverPrivate *d)
static QSqlField qFromOraInf(const OraFieldInfo &ofi)
static QSqlError qMakeError(const QString &errString, QSqlError::ErrorType type, OCIError *err)
static int qOraErrorNumber(OCIError *err)
static const ub2 qOraCharset
QVarLengthArray< ub2, 32 > SizeArray
QMetaType qDecodeOCIType(const QString &ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
static QByteArray qMakeOCINumber(const qlonglong &ll, OCIError *err)
void qSplitTableAndOwner(const QString &tname, QString *tbl, QString *owner)
QVarLengthArray< sb2, 32 > IndicatorArray
struct OCISvcCtx OCISvcCtx
#define Q_DECLARE_SQLDRIVER_PRIVATE(Class)
#define qPrintable(string)
static char * toLocal8Bit(char *out, QStringView in, QStringConverter::State *state)
#define QT_BEGIN_INCLUDE_NAMESPACE
#define QT_END_INCLUDE_NAMESPACE
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
static int toInt(const QChar &qc, int R)
QFileInfo fi("c:/temp/foo")
[newstuff]
QOCIBatchCleanupHandler(QList< QOCIBatchColumn > &columns)
QList< QOCIBatchColumn > & col
~QOCIBatchCleanupHandler()
QList< QOCIDateTime * > dateTimes
QList< QByteArray > rawData
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent