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));
309 SQLSMALLINT tableNameLen;
310 r = SQLColAttribute(
d->hStmt,
i + 1, SQL_DESC_BASE_TABLE_NAME, tableName,
312 if (
r == SQL_SUCCESS)
321 SQLLEN lengthIndicator = 0;
322 SQLRETURN
r = SQLGetData(hStmt,
325 (SQLPOINTER) &intbuf,
328 if ((
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) || lengthIndicator == SQL_NULL_DATA) {
339 SQLLEN lengthIndicator = 0;
340 SQLRETURN
r = SQLGetData(hStmt,
343 (SQLPOINTER) &dblbuf,
346 if ((
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) || lengthIndicator == SQL_NULL_DATA) {
351 return (
double) dblbuf;
358 SQLLEN lengthIndicator = 0;
359 SQLRETURN
r = SQLGetData(hStmt,
362 (SQLPOINTER) &lngbuf,
365 if ((
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) || lengthIndicator == SQL_NULL_DATA)
374 SQLRETURN
r = SQL_ERROR;
375 SQLLEN lengthIndicator = 0;
379 else if (colSize > 65536)
383 SQLTCHAR*
buf =
new SQLTCHAR[colSize];
386 r = SQLGetData(hStmt,
390 colSize *
sizeof(SQLTCHAR),
392 if (
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) {
393 if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) {
399 }
else if (
r == SQL_NO_DATA) {
402 qWarning(
"qGetStringData: Error while fetching data (%d)",
r);
414 SQLSMALLINT colNameLen;
417 SQLSMALLINT colScale;
418 SQLSMALLINT nullable;
419 SQLRETURN
r = SQL_ERROR;
422 r = SQLDescribeCol(hStmt,
431 if (
r != SQL_SUCCESS)
436 else if (colSize > 65536)
438 char *
buf =
new char[colSize];
440 r = SQLGetData(hStmt,
442 colType == SQL_DBCLOB ? SQL_C_CHAR : SQL_C_BINARY,
446 if (
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) {
447 if (lengthIndicator == SQL_NULL_DATA) {
452 r == SQL_SUCCESS ? rSize = lengthIndicator : rSize = colSize;
453 if (lengthIndicator == SQL_NO_TOTAL)
456 if (
r == SQL_SUCCESS)
476 schema = l.at(0).toString();
477 table = l.at(1).toString();
480 catalog = l.at(0).toString();
481 schema = l.at(1).toString();
482 table = l.at(2).toString();
486 .
arg(qualifier),
this);
500 if (required == SQL_NO_NULLS)
502 else if (required == SQL_NULLABLE)
503 f.setRequired(
false);
514 r = SQLAllocHandle(SQL_HANDLE_STMT,
515 d->drv_d_func()->hDbc,
517 if (
r != SQL_SUCCESS) {
518 qSqlWarning(
"QDB2Result::reset: Unable to allocate statement handle"_L1,
d);
522 r = SQLFreeStmt(
d->hStmt, SQL_CLOSE);
523 if (
r != SQL_SUCCESS) {
524 qSqlWarning(
"QDB2Result::reset: Unable to close statement handle"_L1,
d);
533 r = SQLSetStmtAttr(
d->hStmt,
534 SQL_ATTR_CURSOR_TYPE,
535 (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY,
538 r = SQLSetStmtAttr(
d->hStmt,
539 SQL_ATTR_CURSOR_TYPE,
540 (SQLPOINTER) SQL_CURSOR_STATIC,
543 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
545 forwardOnly ?
"SQL_CURSOR_FORWARD_ONLY"_L1
546 :
"SQL_CURSOR_STATIC"_L1),
d);
555 return QVariant(QMetaType::fromType<SQLHANDLE>(), &
d->hStmt);
569 SQLRETURN
r = SQLFreeHandle(SQL_HANDLE_STMT,
d->hStmt);
570 if (
r != SQL_SUCCESS)
583 d->emptyValueCache();
588 r = SQLExecDirect(
d->hStmt,
590 (SQLINTEGER)
query.length());
591 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
596 SQLSMALLINT
count = 0;
597 r = SQLNumResultCols(
d->hStmt, &
count);
606 d->valueCache.resize(
count);
607 d->valueCache.fill(NULL);
620 d->emptyValueCache();
625 r = SQLPrepare(
d->hStmt,
627 (SQLINTEGER)
query.length());
629 if (
r != SQL_SUCCESS) {
640 QList<QByteArray> tmpStorage;
643 memset(indicators.data(), 0, indicators.size() *
sizeof(SQLLEN));
649 d->emptyValueCache();
659 SQLLEN *ind = &indicators[
i];
661 *ind = SQL_NULL_DATA;
665 switch (
values.at(
i).metaType().id()) {
666 case QMetaType::QDate: {
671 dt->
year = qdt.year();
672 dt->month = qdt.month();
674 r = SQLBindParameter(
d->hStmt,
683 *ind == SQL_NULL_DATA ? ind : NULL);
684 tmpStorage.append(
ba);
686 case QMetaType::QTime: {
691 dt->
hour = qdt.hour();
692 dt->minute = qdt.minute();
693 dt->second = qdt.second();
694 r = SQLBindParameter(
d->hStmt,
703 *ind == SQL_NULL_DATA ? ind : NULL);
704 tmpStorage.append(
ba);
706 case QMetaType::QDateTime: {
708 ba.
resize(
sizeof(TIMESTAMP_STRUCT));
709 TIMESTAMP_STRUCT * dt = (TIMESTAMP_STRUCT *)
ba.
constData();
712 dt->month = qdt.date().month();
713 dt->day = qdt.date().day();
714 dt->hour = qdt.time().hour();
715 dt->minute = qdt.time().minute();
716 dt->second = qdt.time().second();
717 dt->fraction = qdt.time().msec() * 1000000;
718 r = SQLBindParameter(
d->hStmt,
727 *ind == SQL_NULL_DATA ? ind : NULL);
728 tmpStorage.append(
ba);
731 r = SQLBindParameter(
d->hStmt,
738 (
void *)
values.at(
i).constData(),
740 *ind == SQL_NULL_DATA ? ind : NULL);
742 case QMetaType::Double:
743 r = SQLBindParameter(
d->hStmt,
750 (
void *)
values.at(
i).constData(),
752 *ind == SQL_NULL_DATA ? ind : NULL);
754 case QMetaType::QByteArray: {
756 if (*ind != SQL_NULL_DATA)
758 r = SQLBindParameter(
d->hStmt,
765 (
void *)
values.at(
i).toByteArray().constData(),
769 case QMetaType::QString:
772 if (*ind != SQL_NULL_DATA)
776 r = SQLBindParameter(
d->hStmt,
786 tmpStorage.append(
ba);
790 r = SQLBindParameter(
d->hStmt,
806 if (*ind != SQL_NULL_DATA)
808 r = SQLBindParameter(
d->hStmt,
818 tmpStorage.append(
ba);
821 if (
r != SQL_SUCCESS) {
822 qWarning(
"QDB2Result::exec: unable to bind variable: %s",
830 r = SQLExecute(
d->hStmt);
831 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
832 qWarning(
"QDB2Result::exec: Unable to execute statement: %s",
838 SQLSMALLINT
count = 0;
839 r = SQLNumResultCols(
d->hStmt, &
count);
849 d->valueCache.resize(
count);
850 d->valueCache.fill(NULL);
857 switch (
values[
i].metaType().
id()) {
858 case QMetaType::QDate: {
859 DATE_STRUCT ds = *((DATE_STRUCT *)tmpStorage.takeFirst().constData());
862 case QMetaType::QTime: {
863 TIME_STRUCT dt = *((TIME_STRUCT *)tmpStorage.takeFirst().constData());
866 case QMetaType::QDateTime: {
867 TIMESTAMP_STRUCT dt = *((TIMESTAMP_STRUCT *)tmpStorage.takeFirst().constData());
869 QTime(dt.hour, dt.minute, dt.second, dt.fraction / 1000000)));
872 case QMetaType::Double:
873 case QMetaType::QByteArray:
875 case QMetaType::QString:
883 if (indicators[
i] == SQL_NULL_DATA)
896 d->clearValueCache();
897 int actualIdx =
i + 1;
898 if (actualIdx <= 0) {
905 while (
ok &&
i >
at())
909 r = SQLFetchScroll(
d->hStmt,
913 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO &&
r != SQL_NO_DATA) {
918 else if (
r == SQL_NO_DATA)
928 d->clearValueCache();
929 r = SQLFetchScroll(
d->hStmt,
932 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
933 if (
r != SQL_NO_DATA)
949 d->clearValueCache();
951 r = SQLFetchScroll(
d->hStmt,
954 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
967 d->clearValueCache();
999 if (field >=
d->recInf.count()) {
1000 qWarning(
"QDB2Result::data: column %d out of range", field);
1004 SQLLEN lengthIndicator = 0;
1008 if (!
info.isValid() || field >=
d->valueCache.size())
1011 if (
d->valueCache[field])
1012 return *
d->valueCache[field];
1016 switch (
info.metaType().id()) {
1017 case QMetaType::LongLong:
1020 case QMetaType::Int:
1023 case QMetaType::QDate: {
1025 r = SQLGetData(
d->hStmt,
1031 if ((
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA)) {
1038 case QMetaType::QTime: {
1040 r = SQLGetData(
d->hStmt,
1046 if ((
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA)) {
1053 case QMetaType::QDateTime: {
1054 TIMESTAMP_STRUCT dtbuf;
1055 r = SQLGetData(
d->hStmt,
1058 (SQLPOINTER) &dtbuf,
1061 if ((
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA)) {
1063 QTime(dtbuf.hour, dtbuf.minute, dtbuf.second, dtbuf.fraction / 1000000)));
1069 case QMetaType::QByteArray:
1072 case QMetaType::Double:
1092 case QMetaType::QString:
1099 d->valueCache[field] =
v;
1106 if (
i >=
d->valueCache.size())
1109 if (
d->valueCache[
i])
1110 return d->valueCache[
i]->isNull();
1111 return data(
i).isNull();
1117 SQLLEN affectedRowCount = 0;
1118 SQLRETURN
r = SQLRowCount(
d->hStmt, &affectedRowCount);
1119 if (
r == SQL_SUCCESS ||
r == SQL_SUCCESS_WITH_INFO)
1120 return affectedRowCount;
1122 qSqlWarning(
"QDB2Result::numRowsAffected: Unable to count affected rows"_L1,
d);
1145 d->emptyValueCache();
1148 SQLRETURN
r = SQLMoreResults(
d->hStmt);
1149 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1150 if (
r != SQL_NO_DATA) {
1157 SQLSMALLINT fieldCount = 0;
1158 r = SQLNumResultCols(
d->hStmt, &fieldCount);
1160 for (
int i = 0;
i < fieldCount; ++
i)
1163 d->valueCache.resize(fieldCount);
1164 d->valueCache.fill(NULL);
1179 SQLCloseCursor(
d->hStmt);
1193 d->hEnv =
reinterpret_cast<SQLHANDLE
>(env);
1194 d->hDbc =
reinterpret_cast<SQLHANDLE
>(
con);
1213 r = SQLAllocHandle(SQL_HANDLE_ENV,
1216 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1217 qSqlWarning(
"QDB2Driver::open: Unable to allocate environment"_L1,
d);
1222 r = SQLAllocHandle(SQL_HANDLE_DBC,
1225 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1226 qSqlWarning(
"QDB2Driver::open: Unable to allocate connection"_L1,
d);
1234 for (
int i = 0;
i < opts.count(); ++
i) {
1237 if ((idx = tmp.
indexOf(u
'=')) == -1) {
1238 qWarning(
"QDB2Driver::open: Illegal connect option value '%s'",
1248 if (
opt ==
"SQL_ATTR_ACCESS_MODE"_L1) {
1249 if (val ==
"SQL_MODE_READ_ONLY"_L1) {
1250 v = SQL_MODE_READ_ONLY;
1251 }
else if (val ==
"SQL_MODE_READ_WRITE"_L1) {
1252 v = SQL_MODE_READ_WRITE;
1254 qWarning(
"QDB2Driver::open: Unknown option value '%s'",
1258 r = SQLSetConnectAttr(
d->hDbc, SQL_ATTR_ACCESS_MODE,
reinterpret_cast<SQLPOINTER
>(
v), 0);
1259 }
else if (
opt ==
"SQL_ATTR_LOGIN_TIMEOUT"_L1) {
1261 r = SQLSetConnectAttr(
d->hDbc, SQL_ATTR_LOGIN_TIMEOUT,
reinterpret_cast<SQLPOINTER
>(
v), 0);
1266 qWarning(
"QDB2Driver::open: Unknown connection attribute '%s'",
1269 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO)
1271 "Unable to set connection attribute '%1'").
arg(
opt),
d);
1275 protocol =
"PROTOCOL=TCPIP"_L1;
1281 connQStr = protocol +
";DATABASE="_L1 +
db +
";HOSTNAME="_L1 + host
1283 +
";PWD="_L1 + password;
1286 SQLTCHAR connOut[SQL_MAX_OPTION_STRING_LENGTH];
1289 r = SQLDriverConnect(
d->hDbc,
1292 (SQLSMALLINT) connQStr.length(),
1294 SQL_MAX_OPTION_STRING_LENGTH,
1296 SQL_DRIVER_NOPROMPT);
1297 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1317 r = SQLDisconnect(
d->hDbc);
1318 if (
r != SQL_SUCCESS)
1319 qSqlWarning(
"QDB2Driver::close: Unable to disconnect datasource"_L1,
d);
1321 r = SQLFreeHandle(SQL_HANDLE_DBC,
d->hDbc);
1322 if (
r != SQL_SUCCESS)
1323 qSqlWarning(
"QDB2Driver::close: Unable to free connection handle"_L1,
d);
1328 r = SQLFreeHandle(SQL_HANDLE_ENV,
d->hEnv);
1329 if (
r != SQL_SUCCESS)
1330 qSqlWarning(
"QDB2Driver::close: Unable to free environment handle"_L1,
d);
1351 d->qSplitTableQualifier(tableName, catalog, schema,
table);
1352 if (schema.isEmpty())
1363 schema = schema.toUpper();
1370 SQLRETURN
r = SQLAllocHandle(SQL_HANDLE_STMT,
1373 if (
r != SQL_SUCCESS) {
1374 qSqlWarning(
"QDB2Driver::record: Unable to allocate handle"_L1,
d);
1378 r = SQLSetStmtAttr(hStmt,
1379 SQL_ATTR_CURSOR_TYPE,
1380 (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY,
1386 r = SQLColumns(hStmt,
1396 if (
r != SQL_SUCCESS)
1397 qSqlWarning(
"QDB2Driver::record: Unable to execute column list"_L1,
d);
1398 r = SQLFetchScroll(hStmt,
1401 while (
r == SQL_SUCCESS) {
1403 fld.setTableName(tableName);
1405 r = SQLFetchScroll(hStmt,
1410 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
1411 if (
r != SQL_SUCCESS)
1412 qSqlWarning(
"QDB2Driver: Unable to free statement handle "_L1
1427 SQLRETURN
r = SQLAllocHandle(SQL_HANDLE_STMT,
1430 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO) {
1431 qSqlWarning(
"QDB2Driver::tables: Unable to allocate handle"_L1,
d);
1434 r = SQLSetStmtAttr(hStmt,
1435 SQL_ATTR_CURSOR_TYPE,
1436 (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
1441 tableType +=
"TABLE,"_L1;
1443 tableType +=
"VIEW,"_L1;
1445 tableType +=
"SYSTEM TABLE,"_L1;
1446 if (tableType.isEmpty())
1450 r = SQLTables(hStmt,
1458 tableType.length());
1460 if (
r != SQL_SUCCESS &&
r != SQL_SUCCESS_WITH_INFO)
1461 qSqlWarning(
"QDB2Driver::tables: Unable to execute table list"_L1,
d);
1462 r = SQLFetchScroll(hStmt,
1465 while (
r == SQL_SUCCESS) {
1475 if (userVal != user)
1476 fieldVal = userVal + u
'.' + fieldVal;
1477 tl.append(fieldVal);
1478 r = SQLFetchScroll(hStmt,
1483 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
1484 if (
r != SQL_SUCCESS)
1485 qSqlWarning(
"QDB2Driver::tables: Unable to free statement handle "_L1
1499 SQLRETURN
r = SQLAllocHandle(SQL_HANDLE_STMT,
1502 if (
r != SQL_SUCCESS) {
1503 qSqlWarning(
"QDB2Driver::primaryIndex: Unable to list primary key"_L1,
d);
1507 d->qSplitTableQualifier(tablename, catalog, schema,
table);
1517 schema = schema.toUpper();
1524 r = SQLSetStmtAttr(hStmt,
1525 SQL_ATTR_CURSOR_TYPE,
1526 (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
1529 r = SQLPrimaryKeys(hStmt,
1536 r = SQLFetchScroll(hStmt,
1543 while (
r == SQL_SUCCESS) {
1547 index.setName(idxName);
1548 r = SQLFetchScroll(hStmt,
1552 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
1553 if (
r!= SQL_SUCCESS)
1554 qSqlWarning(
"QDB2Driver: Unable to free statement handle "_L1
1587 qWarning(
"QDB2Driver::beginTransaction: Database not open");
1590 return setAutoCommit(
false);
1597 qWarning(
"QDB2Driver::commitTransaction: Database not open");
1600 SQLRETURN
r = SQLEndTran(SQL_HANDLE_DBC,
1603 if (
r != SQL_SUCCESS) {
1608 return setAutoCommit(
true);
1615 qWarning(
"QDB2Driver::rollbackTransaction: Database not open");
1618 SQLRETURN
r = SQLEndTran(SQL_HANDLE_DBC,
1621 if (
r != SQL_SUCCESS) {
1626 return setAutoCommit(
true);
1629bool QDB2Driver::setAutoCommit(
bool autoCommit)
1632 SQLULEN ac = autoCommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF;
1633 SQLRETURN
r = SQLSetConnectAttr(
d->hDbc,
1634 SQL_ATTR_AUTOCOMMIT,
1635 reinterpret_cast<SQLPOINTER
>(ac),
1637 if (
r != SQL_SUCCESS) {
1651 case QMetaType::QDateTime: {
1671 case QMetaType::QByteArray: {
1676 for (
const char c :
ba) {
1692 return QVariant(QMetaType::fromType<SQLHANDLE>(), &
d->hDbc);
1708#include "moc_qsql_db2_p.cpp"
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.
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 year() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype count() const noexcept
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.
bool isNull() const
Returns true if the field's value is NULL; otherwise returns false.
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.
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
QString left(qsizetype n) const &
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
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)
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
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 mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
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.
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 toUpper() const &
qsizetype length() const noexcept
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.
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
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint64 GLenum handleType
GLuint GLsizei const GLchar * message
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)
\inmodule QtCore \reentrant