15#include <QtSql/private/qsqldriver_p.h>
16#include <QtSql/private/qsqlresult_p.h>
17#include "private/qtools_p.h"
23#define SQL_BIGINT_TYPE qint64
24#define SQL_BIGUINT_TYPE quint64
40static const SQLSMALLINT
qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT };
72 bool fetch(
int i)
override;
131 SQLINTEGER nativeCode;
133 SQLRETURN
r = SQL_ERROR;
134 SQLTCHAR
state[SQL_SQLSTATE_SIZE + 1];
135 SQLTCHAR description[SQL_MAX_MESSAGE_LENGTH];
141 (SQLTCHAR*) description,
142 SQL_MAX_MESSAGE_LENGTH - 1,
144 if (
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) {
146 *errorCode = nativeCode;
156 if (errorCodes && errorCode != 0) {
160 if (!
error.isEmpty())
163 if (errorCodes && errorCode != 0)
172 if (errorCodes && errorCode != 0) {
176 if (!
error.isEmpty())
179 if (errorCodes && errorCode != 0) {
183 if (!
error.isEmpty())
186 if (errorCodes && errorCode != 0)
209 errorCodes.join(u
';'));
218 errorCodes.join(u
';'));
230 type = QMetaType::Double;
236 type = QMetaType::Int;
239 type = QMetaType::LongLong;
244 case SQL_LONGVARBINARY:
247 type = QMetaType::QByteArray;
251 type = QMetaType::QDate;
255 type = QMetaType::QTime;
258 case SQL_TYPE_TIMESTAMP:
259 type = QMetaType::QDateTime;
263 case SQL_WLONGVARCHAR:
266 case SQL_LONGVARCHAR:
267 type = QMetaType::QString;
270 type = QMetaType::QByteArray;
278 SQLSMALLINT colNameLen;
281 SQLSMALLINT colScale;
282 SQLSMALLINT nullable;
283 SQLRETURN
r = SQL_ERROR;
285 r = SQLDescribeCol(
d->hStmt,
295 if (
r != SQL_SUCCESS) {
301 if (nullable == SQL_NO_NULLS)
303 else if (nullable == SQL_NULLABLE)
304 f.setRequired(
false);
306 f.setLength(colSize == 0 ? -1 : int(colSize));
307 f.setPrecision(colScale == 0 ? -1 : int(colScale));
308 f.setSqlType(
int(colType));
310 SQLSMALLINT tableNameLen;
311 r = SQLColAttribute(
d->hStmt,
i + 1, SQL_DESC_BASE_TABLE_NAME, tableName,
313 if (
r == SQL_SUCCESS)
322 SQLLEN lengthIndicator = 0;
323 SQLRETURN
r = SQLGetData(hStmt,
326 (SQLPOINTER) &intbuf,
329 if ((
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) || lengthIndicator == SQL_NULL_DATA) {
340 SQLLEN lengthIndicator = 0;
341 SQLRETURN
r = SQLGetData(hStmt,
344 (SQLPOINTER) &dblbuf,
347 if ((
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) || lengthIndicator == SQL_NULL_DATA) {
352 return (
double) dblbuf;
359 SQLLEN lengthIndicator = 0;
360 SQLRETURN
r = SQLGetData(hStmt,
363 (SQLPOINTER) &lngbuf,
366 if ((
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) || lengthIndicator == SQL_NULL_DATA)
375 SQLRETURN
r = SQL_ERROR;
376 SQLLEN lengthIndicator = 0;
380 else if (colSize > 65536)
384 SQLTCHAR*
buf =
new SQLTCHAR[colSize];
387 r = SQLGetData(hStmt,
391 colSize *
sizeof(SQLTCHAR),
393 if (
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) {
394 if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) {
400 }
else if (
r == SQL_NO_DATA) {
403 qWarning(
"qGetStringData: Error while fetching data (%d)",
r);
415 SQLSMALLINT colNameLen;
418 SQLSMALLINT colScale;
419 SQLSMALLINT nullable;
420 SQLRETURN
r = SQL_ERROR;
423 r = SQLDescribeCol(hStmt,
432 if (
r != SQL_SUCCESS)
437 else if (colSize > 65536)
439 char *
buf =
new char[colSize];
441 r = SQLGetData(hStmt,
443 colType == SQL_DBCLOB ? SQL_C_CHAR : SQL_C_BINARY,
447 if (
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) {
448 if (lengthIndicator == SQL_NULL_DATA) {
453 r == SQL_SUCCESS ? rSize = lengthIndicator : rSize = colSize;
454 if (lengthIndicator == SQL_NO_TOTAL)
457 if (
r == SQL_SUCCESS)
477 schema = l.
at(0).toString();
481 catalog = l.
at(0).toString();
482 schema = l.
at(1).toString();
487 .
arg(qualifier),
this);
501 if (required == SQL_NO_NULLS)
503 else if (required == SQL_NULLABLE)
504 f.setRequired(
false);
516 r = SQLAllocHandle(SQL_HANDLE_STMT,
517 d->drv_d_func()->hDbc,
519 if (
r != SQL_SUCCESS) {
520 qSqlWarning(
"QDB2Result::reset: Unable to allocate statement handle"_L1,
d);
524 r = SQLFreeStmt(
d->hStmt, SQL_CLOSE);
525 if (
r != SQL_SUCCESS) {
526 qSqlWarning(
"QDB2Result::reset: Unable to close statement handle"_L1,
d);
535 r = SQLSetStmtAttr(
d->hStmt,
536 SQL_ATTR_CURSOR_TYPE,
537 (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY,
540 r = SQLSetStmtAttr(
d->hStmt,
541 SQL_ATTR_CURSOR_TYPE,
542 (SQLPOINTER) SQL_CURSOR_STATIC,
545 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
547 forwardOnly ?
"SQL_CURSOR_FORWARD_ONLY"_L1
548 :
"SQL_CURSOR_STATIC"_L1),
d);
557 return QVariant(QMetaType::fromType<SQLHANDLE>(), &
d->hStmt);
571 SQLRETURN
r = SQLFreeHandle(SQL_HANDLE_STMT,
d->hStmt);
572 if (
r != SQL_SUCCESS)
585 d->emptyValueCache();
590 r = SQLExecDirect(
d->hStmt,
592 (SQLINTEGER)
query.length());
593 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
598 SQLSMALLINT
count = 0;
599 r = SQLNumResultCols(
d->hStmt, &
count);
608 d->valueCache.resize(
count);
609 d->valueCache.fill(NULL);
622 d->emptyValueCache();
627 r = SQLPrepare(
d->hStmt,
629 (SQLINTEGER)
query.length());
631 if (
r != SQL_SUCCESS) {
645 memset(indicators.
data(), 0, indicators.
size() *
sizeof(SQLLEN));
651 d->emptyValueCache();
661 SQLLEN *ind = &indicators[
i];
663 *ind = SQL_NULL_DATA;
667 switch (
values.at(
i).metaType().id()) {
668 case QMetaType::QDate: {
674 dt->month = qdt.
month();
676 r = SQLBindParameter(
d->hStmt,
685 *ind == SQL_NULL_DATA ? ind : NULL);
688 case QMetaType::QTime: {
694 dt->minute = qdt.
minute();
695 dt->second = qdt.
second();
696 r = SQLBindParameter(
d->hStmt,
705 *ind == SQL_NULL_DATA ? ind : NULL);
708 case QMetaType::QDateTime: {
710 ba.
resize(
sizeof(TIMESTAMP_STRUCT));
711 TIMESTAMP_STRUCT * dt = (TIMESTAMP_STRUCT *)
ba.
constData();
719 dt->fraction = qdt.
time().
msec() * 1000000;
720 r = SQLBindParameter(
d->hStmt,
729 *ind == SQL_NULL_DATA ? ind : NULL);
733 r = SQLBindParameter(
d->hStmt,
740 (
void *)
values.at(
i).constData(),
742 *ind == SQL_NULL_DATA ? ind : NULL);
744 case QMetaType::Double:
745 r = SQLBindParameter(
d->hStmt,
752 (
void *)
values.at(
i).constData(),
754 *ind == SQL_NULL_DATA ? ind : NULL);
756 case QMetaType::QByteArray: {
758 if (*ind != SQL_NULL_DATA)
760 r = SQLBindParameter(
d->hStmt,
767 (
void *)
values.at(
i).toByteArray().constData(),
771 case QMetaType::QString:
774 if (*ind != SQL_NULL_DATA)
778 r = SQLBindParameter(
d->hStmt,
792 r = SQLBindParameter(
d->hStmt,
808 if (*ind != SQL_NULL_DATA)
810 r = SQLBindParameter(
d->hStmt,
823 if (
r != SQL_SUCCESS) {
824 qWarning(
"QDB2Result::exec: unable to bind variable: %s",
832 r = SQLExecute(
d->hStmt);
833 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
834 qWarning(
"QDB2Result::exec: Unable to execute statement: %s",
840 SQLSMALLINT
count = 0;
841 r = SQLNumResultCols(
d->hStmt, &
count);
851 d->valueCache.resize(
count);
852 d->valueCache.fill(NULL);
859 switch (
values[
i].metaType().
id()) {
860 case QMetaType::QDate: {
861 DATE_STRUCT ds = *((DATE_STRUCT *)tmpStorage.
takeFirst().constData());
864 case QMetaType::QTime: {
865 TIME_STRUCT dt = *((TIME_STRUCT *)tmpStorage.
takeFirst().constData());
868 case QMetaType::QDateTime: {
869 TIMESTAMP_STRUCT dt = *((TIMESTAMP_STRUCT *)tmpStorage.
takeFirst().constData());
871 QTime(dt.hour, dt.minute, dt.second, dt.fraction / 1000000)));
874 case QMetaType::Double:
875 case QMetaType::QByteArray:
877 case QMetaType::QString:
885 if (indicators[
i] == SQL_NULL_DATA)
898 d->clearValueCache();
899 int actualIdx =
i + 1;
900 if (actualIdx <= 0) {
907 while (
ok &&
i >
at())
911 r = SQLFetchScroll(
d->hStmt,
915 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO &&
r != SQL_NO_DATA) {
920 else if (
r == SQL_NO_DATA)
930 d->clearValueCache();
931 r = SQLFetchScroll(
d->hStmt,
934 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
935 if (
r != SQL_NO_DATA)
951 d->clearValueCache();
953 r = SQLFetchScroll(
d->hStmt,
956 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
969 d->clearValueCache();
1001 if (field >=
d->recInf.count()) {
1002 qWarning(
"QDB2Result::data: column %d out of range", field);
1006 SQLLEN lengthIndicator = 0;
1010 if (!
info.isValid() || field >=
d->valueCache.size())
1013 if (
d->valueCache[field])
1014 return *
d->valueCache[field];
1018 switch (
info.metaType().id()) {
1019 case QMetaType::LongLong:
1022 case QMetaType::Int:
1025 case QMetaType::QDate: {
1027 r = SQLGetData(
d->hStmt,
1033 if ((
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA)) {
1040 case QMetaType::QTime: {
1042 r = SQLGetData(
d->hStmt,
1048 if ((
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA)) {
1055 case QMetaType::QDateTime: {
1056 TIMESTAMP_STRUCT dtbuf;
1057 r = SQLGetData(
d->hStmt,
1060 (SQLPOINTER) &dtbuf,
1063 if ((
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA)) {
1065 QTime(dtbuf.hour, dtbuf.minute, dtbuf.second, dtbuf.fraction / 1000000)));
1071 case QMetaType::QByteArray:
1074 case QMetaType::Double:
1094 case QMetaType::QString:
1101 d->valueCache[field] =
v;
1108 if (
i >=
d->valueCache.size())
1111 if (
d->valueCache[
i])
1112 return d->valueCache[
i]->isNull();
1113 return data(
i).isNull();
1119 SQLLEN affectedRowCount = 0;
1120 SQLRETURN
r = SQLRowCount(
d->hStmt, &affectedRowCount);
1121 if (
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO)
1122 return affectedRowCount;
1124 qSqlWarning(
"QDB2Result::numRowsAffected: Unable to count affected rows"_L1,
d);
1147 d->emptyValueCache();
1150 SQLRETURN
r = SQLMoreResults(
d->hStmt);
1151 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1152 if (
r != SQL_NO_DATA) {
1159 SQLSMALLINT fieldCount = 0;
1160 r = SQLNumResultCols(
d->hStmt, &fieldCount);
1162 for (
int i = 0;
i < fieldCount; ++
i)
1165 d->valueCache.resize(fieldCount);
1166 d->valueCache.fill(NULL);
1181 SQLCloseCursor(
d->hStmt);
1195 d->hEnv =
reinterpret_cast<SQLHANDLE
>(env);
1196 d->hDbc =
reinterpret_cast<SQLHANDLE
>(
con);
1215 r = SQLAllocHandle(SQL_HANDLE_ENV,
1218 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1219 qSqlWarning(
"QDB2Driver::open: Unable to allocate environment"_L1,
d);
1224 r = SQLAllocHandle(SQL_HANDLE_DBC,
1227 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1228 qSqlWarning(
"QDB2Driver::open: Unable to allocate connection"_L1,
d);
1236 for (
int i = 0;
i < opts.count(); ++
i) {
1239 if ((idx = tmp.
indexOf(u
'=')) == -1) {
1240 qWarning(
"QDB2Driver::open: Illegal connect option value '%s'",
1250 if (
opt ==
"SQL_ATTR_ACCESS_MODE"_L1) {
1251 if (
val ==
"SQL_MODE_READ_ONLY"_L1) {
1252 v = SQL_MODE_READ_ONLY;
1253 }
else if (
val ==
"SQL_MODE_READ_WRITE"_L1) {
1254 v = SQL_MODE_READ_WRITE;
1256 qWarning(
"QDB2Driver::open: Unknown option value '%s'",
1260 r = SQLSetConnectAttr(
d->hDbc, SQL_ATTR_ACCESS_MODE,
reinterpret_cast<SQLPOINTER
>(
v), 0);
1261 }
else if (
opt ==
"SQL_ATTR_LOGIN_TIMEOUT"_L1) {
1263 r = SQLSetConnectAttr(
d->hDbc, SQL_ATTR_LOGIN_TIMEOUT,
reinterpret_cast<SQLPOINTER
>(
v), 0);
1268 qWarning(
"QDB2Driver::open: Unknown connection attribute '%s'",
1271 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO)
1273 "Unable to set connection attribute '%1'").
arg(
opt),
d);
1277 protocol =
"PROTOCOL=TCPIP"_L1;
1283 connQStr = protocol +
";DATABASE="_L1 +
db +
";HOSTNAME="_L1 + host
1285 +
";PWD="_L1 + password;
1288 SQLTCHAR connOut[SQL_MAX_OPTION_STRING_LENGTH];
1291 r = SQLDriverConnect(
d->hDbc,
1294 (SQLSMALLINT) connQStr.
length(),
1296 SQL_MAX_OPTION_STRING_LENGTH,
1298 SQL_DRIVER_NOPROMPT);
1299 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1319 r = SQLDisconnect(
d->hDbc);
1320 if (
r != SQL_SUCCESS)
1321 qSqlWarning(
"QDB2Driver::close: Unable to disconnect datasource"_L1,
d);
1323 r = SQLFreeHandle(SQL_HANDLE_DBC,
d->hDbc);
1324 if (
r != SQL_SUCCESS)
1325 qSqlWarning(
"QDB2Driver::close: Unable to free connection handle"_L1,
d);
1330 r = SQLFreeHandle(SQL_HANDLE_ENV,
d->hEnv);
1331 if (
r != SQL_SUCCESS)
1332 qSqlWarning(
"QDB2Driver::close: Unable to free environment handle"_L1,
d);
1353 d->qSplitTableQualifier(tableName, catalog, schema,
table);
1372 SQLRETURN
r = SQLAllocHandle(SQL_HANDLE_STMT,
1375 if (
r != SQL_SUCCESS) {
1376 qSqlWarning(
"QDB2Driver::record: Unable to allocate handle"_L1,
d);
1380 r = SQLSetStmtAttr(hStmt,
1381 SQL_ATTR_CURSOR_TYPE,
1382 (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY,
1388 r = SQLColumns(hStmt,
1398 if (
r != SQL_SUCCESS)
1399 qSqlWarning(
"QDB2Driver::record: Unable to execute column list"_L1,
d);
1400 r = SQLFetchScroll(hStmt,
1403 while (
r == SQL_SUCCESS) {
1407 r = SQLFetchScroll(hStmt,
1412 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
1413 if (
r != SQL_SUCCESS)
1414 qSqlWarning(
"QDB2Driver: Unable to free statement handle "_L1
1429 SQLRETURN
r = SQLAllocHandle(SQL_HANDLE_STMT,
1432 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1433 qSqlWarning(
"QDB2Driver::tables: Unable to allocate handle"_L1,
d);
1436 r = SQLSetStmtAttr(hStmt,
1437 SQL_ATTR_CURSOR_TYPE,
1438 (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
1443 tableType +=
"TABLE,"_L1;
1445 tableType +=
"VIEW,"_L1;
1447 tableType +=
"SYSTEM TABLE,"_L1;
1452 r = SQLTables(hStmt,
1462 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO)
1463 qSqlWarning(
"QDB2Driver::tables: Unable to execute table list"_L1,
d);
1464 r = SQLFetchScroll(hStmt,
1467 while (
r == SQL_SUCCESS) {
1477 if (userVal != user)
1478 fieldVal = userVal + u
'.' + fieldVal;
1479 tl.append(fieldVal);
1480 r = SQLFetchScroll(hStmt,
1485 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
1486 if (
r != SQL_SUCCESS)
1487 qSqlWarning(
"QDB2Driver::tables: Unable to free statement handle "_L1
1501 SQLRETURN
r = SQLAllocHandle(SQL_HANDLE_STMT,
1504 if (
r != SQL_SUCCESS) {
1505 qSqlWarning(
"QDB2Driver::primaryIndex: Unable to list primary key"_L1,
d);
1509 d->qSplitTableQualifier(tablename, catalog, schema,
table);
1526 r = SQLSetStmtAttr(hStmt,
1527 SQL_ATTR_CURSOR_TYPE,
1528 (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
1531 r = SQLPrimaryKeys(hStmt,
1538 r = SQLFetchScroll(hStmt,
1545 while (
r == SQL_SUCCESS) {
1549 index.setName(idxName);
1550 r = SQLFetchScroll(hStmt,
1554 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
1555 if (
r!= SQL_SUCCESS)
1556 qSqlWarning(
"QDB2Driver: Unable to free statement handle "_L1
1589 qWarning(
"QDB2Driver::beginTransaction: Database not open");
1592 return setAutoCommit(
false);
1599 qWarning(
"QDB2Driver::commitTransaction: Database not open");
1602 SQLRETURN
r = SQLEndTran(SQL_HANDLE_DBC,
1605 if (
r != SQL_SUCCESS) {
1610 return setAutoCommit(
true);
1617 qWarning(
"QDB2Driver::rollbackTransaction: Database not open");
1620 SQLRETURN
r = SQLEndTran(SQL_HANDLE_DBC,
1623 if (
r != SQL_SUCCESS) {
1628 return setAutoCommit(
true);
1631bool QDB2Driver::setAutoCommit(
bool autoCommit)
1634 SQLULEN ac = autoCommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF;
1635 SQLRETURN
r = SQLSetConnectAttr(
d->hDbc,
1636 SQL_ATTR_AUTOCOMMIT,
1637 reinterpret_cast<SQLPOINTER
>(ac),
1639 if (
r != SQL_SUCCESS) {
1653 case QMetaType::QDateTime: {
1673 case QMetaType::QByteArray: {
1678 for (
const char c :
ba) {
1694 return QVariant(QMetaType::fromType<SQLHANDLE>(), &
d->hDbc);
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
qsizetype length() const noexcept
Same as size().
char at(qsizetype i) const
Returns the byte at index position i in the byte array.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
void qSplitTableQualifier(const QString &qualifier, QString &catalog, QString &schema, QString &table) const
QStringList tables(QSql::TableType type) const override
Returns a list of the names of the tables in the database.
bool beginTransaction() override
This function is called to begin a transaction.
QVariant handle() const override
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
QSqlIndex primaryIndex(const QString &tablename) const override
Returns the primary index for table tableName.
QString escapeIdentifier(const QString &identifier, IdentifierType type) const override
Returns the identifier escaped according to the database rules.
QSqlResult * createResult() const override
Creates an empty SQL result on the database.
bool rollbackTransaction() override
This function is called to rollback a transaction.
void close() override
Derived classes must reimplement this pure virtual function in order to close the database connection...
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...
QSqlRecord record(const QString &tableName) const override
Returns a QSqlRecord populated with the names of the fields in table tableName.
bool hasFeature(DriverFeature) const override
Returns true if the driver supports feature feature; otherwise returns false.
bool commitTransaction() override
This function is called to commit a transaction.
QString formatValue(const QSqlField &field, bool trimStrings) const override
Returns a string representation of the field value for the database.
QDB2Driver(QObject *parent=nullptr)
QList< QVariant * > valueCache
bool fetchLast() override
Positions the result to the last record (last row) in the result.
QVariant handle() const override
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
void detachFromResultSet() override
void virtual_hook(int id, void *data) override
int numRowsAffected() override
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
QDB2Result(const QDB2Driver *drv)
bool fetch(int i) override
Positions the result to an arbitrary (zero-based) row index.
bool isNull(int i) override
Returns true if the field at position index in the current row is null; otherwise returns false.
bool exec() override
Executes the query, returning true if successful; otherwise returns false.
bool fetchFirst() override
Positions the result to the first record (row 0) in the result.
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...
bool prepare(const QString &query) override
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
QSqlRecord record() const override
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
bool fetchNext() override
Positions the result to the next available record (row) in the result.
bool reset(const QString &query) override
Sets the result to use the SQL statement query for subsequent data retrieval.
bool nextResult() override
QVariant data(int field) override
Returns the data for field index in the current row as a QVariant.
\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
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...
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
void append(parameter_type t)
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
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.
QMetaType metaType() const
Returns the field's type as stored in the database.
QVariant value() const
Returns the value of the field as a QVariant.
bool isNull() const
Returns true if the field's value is NULL; otherwise returns false.
void setTableName(const QString &tableName)
Sets the tableName of the field to table.
The QSqlIndex class provides functions to manipulate and describe database indexes.
The QSqlRecord class encapsulates a database record.
QSqlField field(int i) const
Returns the field at position index.
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.
QSql::ParamType bindValueType(const QString &placeholder) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual void virtual_hook(int id, void *data)
int at() const
Returns the current (zero-based) row position of the result.
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...
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)
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
\macro QT_RESTRICTED_CAST_FROM_ASCII
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)
QString rightJustified(qsizetype width, QChar fill=u' ', bool trunc=false) const
Returns a string of size() width that contains the fill character followed by the string.
void chop(qsizetype n)
Removes n characters from the end of the string.
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.
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
void clear()
Clears the contents of the string and makes it null.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
qsizetype capacity() const
Returns the maximum number of characters that can be stored in the string without forcing a reallocat...
QString simplified() const &
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QByteArray toLocal8Bit() const &
QChar * data()
Returns a pointer to the data stored in the QString.
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.
\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.
constexpr size_type size() const noexcept
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has userType() \l QMetaType::QDateTime,...
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
query setForwardOnly(true)
Combined button and popup list for selecting options.
constexpr char toHexLower(char32_t value) noexcept
DBusConnection const char DBusError * error
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLenum GLenum GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint64 GLenum handleType
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * table
static const SQLSMALLINT qParamType[4]
static const int COLNAMESIZE
static QSqlField qMakeFieldInfo(const QDB2ResultPrivate *d, int i)
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
static const SQLSMALLINT TABLENAMESIZE
static bool qMakeStatement(QDB2ResultPrivate *d, bool forwardOnly, bool setForwardOnly=true)
static QByteArray qGetBinaryData(SQLHANDLE hStmt, int column, SQLLEN &lengthIndicator, bool &isNull)
static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool &isNull)
static SQLBIGINT qGetBigIntData(SQLHANDLE hStmt, int column, bool &isNull)
static int qGetIntData(SQLHANDLE hStmt, int column, bool &isNull)
static SQLTCHAR * qToTChar(const QString &str)
static QString qFromTChar(SQLTCHAR *str)
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
static QMetaType qDecodeDB2Type(SQLSMALLINT sqltype)
static QString qDB2Warn(const QDB2DriverPrivate *d, QStringList *errorCodes=nullptr)
static QString qWarnDB2Handle(int handleType, SQLHANDLE handle, int *errorCode)
static double qGetDoubleData(SQLHANDLE hStmt, int column, bool &isNull)
#define Q_DECLARE_SQLDRIVER_PRIVATE(Class)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
static char * toLocal8Bit(char *out, QStringView in, QStringConverter::State *state)
#define QStringLiteral(str)
QFileInfo info(fileName)
[8]
\inmodule QtCore \reentrant
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent