45 #if defined (Q_OS_WIN32) 64 #define ODBC_CHECK_DRIVER 68 static const SQLSMALLINT
qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT };
74 int realsize =
qMin(size, input.
size());
75 if(realsize > 0 && input[realsize-1] == 0)
77 switch(
sizeof(SQLTCHAR)) {
88 qCritical() <<
"sizeof(SQLTCHAR) is " <<
sizeof(SQLTCHAR) <<
"Don't know how to handle this";
97 switch(
sizeof(SQLTCHAR)) {
108 qCritical() <<
"sizeof(SQLTCHAR) is " <<
sizeof(SQLTCHAR) <<
"Don't know how to handle this";
119 : hEnv(0), hDbc(0), unicode(
false), useSchema(
false), disconnectCount(0), datetime_precision(19), isMySqlServer(
false),
120 isMSSqlServer(
false), isFreeTDSDriver(
false), hasSQLFetchScroll(
true),
121 hasMultiResultSets(
false), isQuoteInitialized(
false), quote(
QLatin1Char(
'"'))
131 int datetime_precision;
134 bool isFreeTDSDriver;
135 bool hasSQLFetchScroll;
136 bool hasMultiResultSets;
138 bool checkDriver()
const;
140 void checkSqlServer();
141 void checkHasSQLFetchScroll();
142 void checkHasMultiResults();
143 void checkSchemaUsage();
144 void checkDateTimePrecision();
145 bool setConnectionOptions(
const QString& connOpts);
146 void splitTableQualifier(
const QString &qualifier,
QString &catalog,
152 bool isQuoteInitialized;
160 : hStmt(0), useSchema(false), hasSQLFetchScroll(true), driverPrivate(dpp), userForwardOnly(false)
162 unicode = dpp->unicode;
163 useSchema = dpp->useSchema;
164 disconnectCount = dpp->disconnectCount;
165 hasSQLFetchScroll = dpp->hasSQLFetchScroll;
169 { fieldCache.fill(
QVariant()); fieldCacheIdx = 0; }
171 SQLHANDLE
dpEnv()
const {
return driverPrivate ? driverPrivate->hEnv : 0;}
172 SQLHANDLE
dpDbc()
const {
return driverPrivate ? driverPrivate->hDbc : 0;}
186 bool isStmtHandleValid(
const QSqlDriver *driver);
187 void updateStmtHandleState(
const QSqlDriver *driver);
193 return disconnectCount == odbcdriver->
d->disconnectCount;
199 disconnectCount = odbcdriver->
d->disconnectCount;
204 SQLINTEGER nativeCode_ = 0;
205 SQLSMALLINT msgLen = 0;
206 SQLRETURN r = SQL_NO_DATA;
207 SQLTCHAR state_[SQL_SQLSTATE_SIZE+1];
214 r = SQLGetDiagRec(handleType,
222 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && msgLen > 0)
223 description_.
resize(msgLen+1);
224 r = SQLGetDiagRec(handleType,
232 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
234 *nativeCode = nativeCode_;
241 if(result != tmpstore) {
246 }
else if (r == SQL_ERROR || r == SQL_INVALID_HANDLE) {
250 }
while (r != SQL_NO_DATA);
318 case SQL_LONGVARBINARY:
330 case SQL_TYPE_TIMESTAMP:
335 case SQL_WLONGVARCHAR:
340 #if (ODBCVER >= 0x0350) 343 case SQL_LONGVARCHAR:
356 SQLRETURN r = SQL_ERROR;
357 SQLLEN lengthIndicator = 0;
362 }
else if (colSize > 65536) {
368 r = SQLGetData(hStmt,
374 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && lengthIndicator > 0)
375 colSize = lengthIndicator/
sizeof(SQLTCHAR) + 1;
377 memset(buf.
data(), 0, colSize*
sizeof(SQLTCHAR));
379 r = SQLGetData(hStmt,
382 (SQLPOINTER)buf.
data(),
383 colSize*
sizeof(SQLTCHAR),
385 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
386 if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) {
395 int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator/
sizeof(SQLTCHAR);
397 if (lengthIndicator < SQLLEN(colSize*
sizeof(SQLTCHAR))) {
401 }
else if (r == SQL_NO_DATA) {
410 r = SQLGetData(hStmt,
416 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && lengthIndicator > 0)
417 colSize = lengthIndicator + 1;
420 r = SQLGetData(hStmt,
423 (SQLPOINTER)buf.
data(),
426 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
427 if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) {
436 int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator;
438 if (lengthIndicator < SQLLEN(colSize)) {
442 }
else if (r == SQL_NO_DATA) {
457 SQLSMALLINT colNameLen;
460 SQLSMALLINT colScale;
461 SQLSMALLINT nullable;
462 SQLLEN lengthIndicator = 0;
463 SQLRETURN r = SQL_ERROR;
467 r = SQLDescribeCol(hStmt,
476 if (r != SQL_SUCCESS)
477 qWarning() <<
"qGetBinaryData: Unable to describe column" << column;
481 else if (colSize > 65536)
486 r = SQLGetData(hStmt,
489 (SQLPOINTER)(fieldVal.
constData() + read),
492 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO)
494 if (lengthIndicator == SQL_NULL_DATA)
496 if (lengthIndicator > SQLLEN(colSize) || lengthIndicator == SQL_NO_TOTAL) {
500 read += lengthIndicator;
502 if (r == SQL_SUCCESS) {
513 SQLINTEGER intbuf = 0;
514 SQLLEN lengthIndicator = 0;
515 SQLRETURN r = SQLGetData(hStmt,
517 isSigned ? SQL_C_SLONG : SQL_C_ULONG,
521 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO)
523 if (lengthIndicator == SQL_NULL_DATA)
534 SQLLEN lengthIndicator = 0;
535 SQLRETURN r = SQLGetData(hStmt,
538 (SQLPOINTER) &dblbuf,
541 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
544 if(lengthIndicator == SQL_NULL_DATA)
547 return (
double) dblbuf;
553 SQLBIGINT lngbuf = 0;
554 SQLLEN lengthIndicator = 0;
555 SQLRETURN r = SQLGetData(hStmt,
557 isSigned ? SQL_C_SBIGINT : SQL_C_UBIGINT,
558 (SQLPOINTER) &lngbuf,
561 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO)
563 if (lengthIndicator == SQL_NULL_DATA)
581 if (required == SQL_NO_NULLS)
583 else if (required == SQL_NULLABLE)
596 SQLSMALLINT colNameLen;
599 SQLSMALLINT colScale;
600 SQLSMALLINT nullable;
601 SQLRETURN r = SQL_ERROR;
603 r = SQLDescribeCol(p->
hStmt,
613 if (r != SQL_SUCCESS) {
618 SQLLEN unsignedFlag = SQL_FALSE;
619 r = SQLColAttribute (p->
hStmt,
626 if (r != SQL_SUCCESS) {
637 if (nullable == SQL_NO_NULLS) {
639 }
else if (nullable == SQL_NULLABLE) {
645 f.
setLength(colSize == 0 ? -1 :
int(colSize));
647 if (nullable == SQL_NO_NULLS)
649 else if (nullable == SQL_NULLABLE)
662 QChar QODBCDriverPrivate::quoteChar()
664 if (!isQuoteInitialized) {
665 SQLTCHAR driverResponse[4];
667 int r = SQLGetInfo(hDbc,
668 SQL_IDENTIFIER_QUOTE_CHAR,
670 sizeof(driverResponse),
672 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
674 quote =
QChar(driverResponse[0]);
680 isQuoteInitialized =
true;
686 bool QODBCDriverPrivate::setConnectionOptions(
const QString& connOpts)
690 SQLRETURN r = SQL_SUCCESS;
691 for (
int i = 0; i < opts.count(); ++i) {
695 qWarning() <<
"QODBCDriver::open: Illegal connect option value '" << tmp <<
'\'';
698 const QString opt(tmp.left(idx));
699 const QString val(tmp.mid(idx + 1).simplified());
703 if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_ACCESS_MODE")) {
705 v = SQL_MODE_READ_ONLY;
706 }
else if (val.toUpper() ==
QLatin1String(
"SQL_MODE_READ_WRITE")) {
707 v = SQL_MODE_READ_WRITE;
709 qWarning() <<
"QODBCDriver::open: Unknown option value '" << val <<
'\'';
712 r = SQLSetConnectAttr(hDbc, SQL_ATTR_ACCESS_MODE, (SQLPOINTER) v, 0);
713 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_CONNECTION_TIMEOUT")) {
715 r = SQLSetConnectAttr(hDbc, SQL_ATTR_CONNECTION_TIMEOUT, (SQLPOINTER) v, 0);
716 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_LOGIN_TIMEOUT")) {
718 r = SQLSetConnectAttr(hDbc, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) v, 0);
719 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_CURRENT_CATALOG")) {
721 r = SQLSetConnectAttr(hDbc, SQL_ATTR_CURRENT_CATALOG,
725 (SQLCHAR*) val.toUtf8().data(),
727 val.length()*
sizeof(SQLTCHAR));
728 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_METADATA_ID")) {
734 qWarning() <<
"QODBCDriver::open: Unknown option value '" << val <<
'\'';
737 r = SQLSetConnectAttr(hDbc, SQL_ATTR_METADATA_ID, (SQLPOINTER) v, 0);
738 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_PACKET_SIZE")) {
740 r = SQLSetConnectAttr(hDbc, SQL_ATTR_PACKET_SIZE, (SQLPOINTER) v, 0);
741 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_TRACEFILE")) {
743 r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACEFILE,
747 (SQLCHAR*) val.toUtf8().data(),
749 val.length()*
sizeof(SQLTCHAR));
750 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_TRACE")) {
752 v = SQL_OPT_TRACE_OFF;
753 }
else if (val.toUpper() ==
QLatin1String(
"SQL_OPT_TRACE_ON")) {
754 v = SQL_OPT_TRACE_ON;
756 qWarning() <<
"QODBCDriver::open: Unknown option value '" << val <<
'\'';
759 r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACE, (SQLPOINTER) v, 0);
760 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_CONNECTION_POOLING")) {
763 else if (val.toUpper() ==
QLatin1String(
"SQL_CP_ONE_PER_DRIVER"))
764 v = SQL_CP_ONE_PER_DRIVER;
765 else if (val.toUpper() ==
QLatin1String(
"SQL_CP_ONE_PER_HENV"))
766 v = SQL_CP_ONE_PER_HENV;
770 qWarning() <<
"QODBCDriver::open: Unknown option value '" << val <<
'\'';
773 r = SQLSetConnectAttr(hDbc, SQL_ATTR_CONNECTION_POOLING, (SQLPOINTER)v, 0);
774 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_CP_MATCH")) {
776 v = SQL_CP_STRICT_MATCH;
777 else if (val.toUpper() ==
QLatin1String(
"SQL_CP_RELAXED_MATCH"))
778 v = SQL_CP_RELAXED_MATCH;
779 else if (val.toUpper() ==
QLatin1String(
"SQL_CP_MATCH_DEFAULT"))
780 v = SQL_CP_MATCH_DEFAULT;
782 qWarning() <<
"QODBCDriver::open: Unknown option value '" << val <<
'\'';
785 r = SQLSetConnectAttr(hDbc, SQL_ATTR_CP_MATCH, (SQLPOINTER)v, 0);
786 }
else if (opt.toUpper() ==
QLatin1String(
"SQL_ATTR_ODBC_VERSION")) {
790 qWarning() <<
"QODBCDriver::open: Unknown connection attribute '" << opt <<
'\'';
792 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO)
799 void QODBCDriverPrivate::splitTableQualifier(
const QString & qualifier,
QString &catalog,
809 int i = 0, n = l.
count();
838 int r = SQLGetInfo(hDbc,
843 if ( r != SQL_SUCCESS)
853 case (SQL_IC_SENSITIVE):
869 QString QODBCDriverPrivate::adjustCase(
const QString &identifier)
const 872 switch(defaultCase()) {
898 SQLRETURN r = SQLFreeHandle(SQL_HANDLE_STMT,
d->
hStmt);
899 if (r != SQL_SUCCESS)
919 r = SQLFreeHandle(SQL_HANDLE_STMT,
d->
hStmt);
920 if (r != SQL_SUCCESS) {
925 r = SQLAllocHandle(SQL_HANDLE_STMT,
928 if (r != SQL_SUCCESS) {
936 r = SQLSetStmtAttr(
d->
hStmt,
937 SQL_ATTR_CURSOR_TYPE,
938 (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
941 r = SQLSetStmtAttr(
d->
hStmt,
942 SQL_ATTR_CURSOR_TYPE,
943 (SQLPOINTER)SQL_CURSOR_STATIC,
946 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
948 "QODBCResult::reset: Unable to set 'SQL_CURSOR_STATIC' as statement attribute. " 954 r = SQLExecDirect(
d->
hStmt,
956 (SQLINTEGER) query.
length());
959 r = SQLExecDirect(
d->
hStmt,
960 (SQLCHAR*) query8.data(),
961 (SQLINTEGER) query8.length());
963 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r!= SQL_NO_DATA) {
969 SQLULEN isScrollable = 0;
970 r = SQLGetStmtAttr(
d->
hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, 0);
971 if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
975 SQLNumResultCols(
d->
hStmt, &count);
978 for (
int i = 0; i < count; ++i) {
1000 int actualIdx = i + 1;
1001 if (actualIdx <= 0) {
1008 while (ok && i >
at())
1012 r = SQLFetchScroll(
d->
hStmt,
1016 if (r != SQL_SUCCESS) {
1017 if (r != SQL_NO_DATA)
1032 r = SQLFetchScroll(
d->
hStmt,
1038 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1039 if (r != SQL_NO_DATA)
1057 r = SQLFetchScroll(
d->
hStmt,
1060 if (r != SQL_SUCCESS) {
1061 if (r != SQL_NO_DATA)
1076 r = SQLFetchScroll(
d->
hStmt,
1079 if (r != SQL_SUCCESS) {
1080 if (r != SQL_NO_DATA)
1107 r = SQLFetchScroll(
d->
hStmt,
1110 if (r != SQL_SUCCESS) {
1111 if (r != SQL_NO_DATA)
1116 SQLULEN currRow = 0;
1117 r = SQLGetStmtAttr(
d->
hStmt,
1122 if (r != SQL_SUCCESS)
1131 qWarning() <<
"QODBCResult::data: column" << field <<
"out of range";
1134 if (field < d->fieldCacheIdx)
1138 SQLLEN lengthIndicator = 0;
1144 switch (info.
type()) {
1165 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA))
1178 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA))
1184 TIMESTAMP_STRUCT dtbuf;
1191 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA))
1193 QTime(dtbuf.hour, dtbuf.minute, dtbuf.second, dtbuf.fraction / 1000000)));
1232 if (field <= d->fieldCacheIdx) {
1248 SQLLEN affectedRowCount = 0;
1249 SQLRETURN r = SQLRowCount(
d->
hStmt, &affectedRowCount);
1250 if (r == SQL_SUCCESS)
1251 return affectedRowCount;
1265 r = SQLFreeHandle(SQL_HANDLE_STMT,
d->
hStmt);
1266 if (r != SQL_SUCCESS) {
1271 r = SQLAllocHandle(SQL_HANDLE_STMT,
1274 if (r != SQL_SUCCESS) {
1282 r = SQLSetStmtAttr(
d->
hStmt,
1283 SQL_ATTR_CURSOR_TYPE,
1284 (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
1287 r = SQLSetStmtAttr(
d->
hStmt,
1288 SQL_ATTR_CURSOR_TYPE,
1289 (SQLPOINTER)SQL_CURSOR_STATIC,
1292 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1294 "QODBCResult::reset: Unable to set 'SQL_CURSOR_STATIC' as statement attribute. " 1302 (SQLINTEGER) query.
length());
1306 (SQLCHAR*) query8.data(),
1307 (SQLINTEGER) query8.length());
1310 if (r != SQL_SUCCESS) {
1332 SQLCloseCursor(
d->
hStmt);
1337 memset(indicators.data(), 0, indicators.size() *
sizeof(SQLLEN));
1342 for (i = 0; i < values.
count(); ++i) {
1346 SQLLEN *ind = &indicators[i];
1348 *ind = SQL_NULL_DATA;
1349 switch (val.
type()) {
1352 ba.
resize(
sizeof(DATE_STRUCT));
1353 DATE_STRUCT *dt = (DATE_STRUCT *)ba.
constData();
1356 dt->month = qdt.
month();
1357 dt->day = qdt.
day();
1358 r = SQLBindParameter(
d->
hStmt,
1367 *ind == SQL_NULL_DATA ? ind : NULL);
1371 ba.
resize(
sizeof(TIME_STRUCT));
1372 TIME_STRUCT *dt = (TIME_STRUCT *)ba.
constData();
1375 dt->minute = qdt.
minute();
1376 dt->second = qdt.
second();
1377 r = SQLBindParameter(
d->
hStmt,
1386 *ind == SQL_NULL_DATA ? ind : NULL);
1390 ba.
resize(
sizeof(TIMESTAMP_STRUCT));
1391 TIMESTAMP_STRUCT * dt = (TIMESTAMP_STRUCT *)ba.
constData();
1401 if (precision <= 0) {
1404 dt->fraction = qdt.
time().
msec() * 1000000;
1407 int keep = (int)
qPow(10.0, 9 -
qMin(9, precision));
1408 dt->fraction = (dt->fraction / keep) * keep;
1411 r = SQLBindParameter(
d->
hStmt,
1420 *ind == SQL_NULL_DATA ? ind : NULL);
1423 r = SQLBindParameter(
d->
hStmt,
1432 *ind == SQL_NULL_DATA ? ind : NULL);
1435 r = SQLBindParameter(
d->
hStmt,
1444 *ind == SQL_NULL_DATA ? ind : NULL);
1447 r = SQLBindParameter(
d->
hStmt,
1456 *ind == SQL_NULL_DATA ? ind : NULL);
1459 r = SQLBindParameter(
d->
hStmt,
1468 *ind == SQL_NULL_DATA ? ind : NULL);
1471 r = SQLBindParameter(
d->
hStmt,
1480 *ind == SQL_NULL_DATA ? ind : NULL);
1483 if (*ind != SQL_NULL_DATA) {
1486 r = SQLBindParameter(
d->
hStmt,
1498 r = SQLBindParameter(
d->
hStmt,
1507 *ind == SQL_NULL_DATA ? ind : NULL);
1513 if (*ind != SQL_NULL_DATA)
1514 *ind = str.
length() *
sizeof(SQLTCHAR);
1515 int strSize = str.
length() *
sizeof(SQLTCHAR);
1520 r = SQLBindParameter(
d->
hStmt,
1524 strSize > 254 ? SQL_WLONGVARCHAR : SQL_WVARCHAR,
1533 r = SQLBindParameter(
d->
hStmt,
1537 strSize > 254 ? SQL_WLONGVARCHAR : SQL_WVARCHAR,
1549 if (*ind != SQL_NULL_DATA)
1551 int strSize = str.
length();
1553 r = SQLBindParameter(
d->
hStmt,
1557 strSize > 254 ? SQL_LONGVARCHAR : SQL_VARCHAR,
1568 if (*ind != SQL_NULL_DATA)
1570 r = SQLBindParameter(
d->
hStmt,
1582 if (r != SQL_SUCCESS) {
1589 r = SQLExecute(
d->
hStmt);
1590 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r != SQL_NO_DATA) {
1597 SQLULEN isScrollable = 0;
1598 r = SQLGetStmtAttr(
d->
hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, 0);
1599 if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
1603 SQLNumResultCols(
d->
hStmt, &count);
1606 for (
int i = 0; i < count; ++i) {
1620 for (i = 0; i < values.
count(); ++i) {
1621 switch (values.
at(i).
type()) {
1623 DATE_STRUCT ds = *((DATE_STRUCT *)tmpStorage.at(i).constData());
1627 TIME_STRUCT dt = *((TIME_STRUCT *)tmpStorage.at(i).constData());
1631 TIMESTAMP_STRUCT dt = *((TIMESTAMP_STRUCT*)
1632 tmpStorage.at(i).constData());
1634 QTime(dt.hour, dt.minute, dt.second, dt.fraction / 1000000)));
1658 values[i] = tmpStorage.
at(i);
1661 if (indicators[i] == SQL_NULL_DATA)
1676 return QVariant(qRegisterMetaType<SQLHANDLE>(
"SQLHANDLE"), &
d->
hStmt);
1688 SQLRETURN r = SQLMoreResults(
d->
hStmt);
1689 if (r != SQL_SUCCESS) {
1690 if (r == SQL_SUCCESS_WITH_INFO) {
1691 int nativeCode = -1;
1693 qWarning() <<
"QODBCResult::nextResult():" << message;
1695 if (r != SQL_NO_DATA)
1703 SQLNumResultCols(
d->
hStmt, &count);
1706 for (
int i = 0; i < count; ++i) {
1723 SQLCloseCursor(
d->
hStmt);
1780 int r = SQLGetInfo(
d->hDbc,
1781 (SQLUSMALLINT)SQL_TXN_CAPABLE,
1785 if (r != SQL_SUCCESS || txn == SQL_TC_NONE)
1805 return d->hasMultiResultSets;
1807 if(
d->isMySqlServer)
1826 r = SQLAllocHandle(SQL_HANDLE_ENV,
1829 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1834 r = SQLSetEnvAttr(
d->hEnv,
1835 SQL_ATTR_ODBC_VERSION,
1838 r = SQLAllocHandle(SQL_HANDLE_DBC,
1841 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1847 if (!
d->setConnectionOptions(connOpts))
1868 memset(connOut.
data(), 0, connOut.
size() *
sizeof(SQLTCHAR));
1869 r = SQLDriverConnect(
d->hDbc,
1876 (SQLSMALLINT)connQStr.
length(),
1882 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1888 if (!
d->checkDriver()) {
1896 d->checkSchemaUsage();
1897 d->checkSqlServer();
1898 d->checkHasSQLFetchScroll();
1899 d->checkHasMultiResults();
1900 d->checkDateTimePrecision();
1903 if(
d->isMSSqlServer) {
1926 r = SQLDisconnect(
d->hDbc);
1927 if (r != SQL_SUCCESS)
1930 d->disconnectCount++;
1933 r = SQLFreeHandle(SQL_HANDLE_DBC,
d->hDbc);
1934 if (r != SQL_SUCCESS)
1940 r = SQLFreeHandle(SQL_HANDLE_ENV,
d->hEnv);
1941 if (r != SQL_SUCCESS)
1949 void QODBCDriverPrivate::checkUnicode()
1955 r = SQLGetInfo(hDbc,
1960 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WCHAR)) {
1965 r = SQLGetInfo(hDbc,
1966 SQL_CONVERT_VARCHAR,
1970 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WVARCHAR)) {
1975 r = SQLGetInfo(hDbc,
1976 SQL_CONVERT_LONGVARCHAR,
1980 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WLONGVARCHAR)) {
1985 r = SQLAllocHandle(SQL_HANDLE_STMT,
1990 if(r == SQL_SUCCESS) {
1991 r = SQLFetch(hStmt);
1992 if(r == SQL_SUCCESS) {
1994 r = SQLGetData(hStmt, 1, SQL_C_WCHAR, buffer.
data(), buffer.
size() *
sizeof(SQLWCHAR), NULL);
2000 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
2003 bool QODBCDriverPrivate::checkDriver()
const 2005 #ifdef ODBC_CHECK_DRIVER 2006 static const SQLUSMALLINT reqFunc[] = {
2007 SQL_API_SQLDESCRIBECOL, SQL_API_SQLGETDATA, SQL_API_SQLCOLUMNS,
2008 SQL_API_SQLGETSTMTATTR, SQL_API_SQLGETDIAGREC, SQL_API_SQLEXECDIRECT,
2009 SQL_API_SQLGETINFO, SQL_API_SQLTABLES, 0
2013 static const SQLUSMALLINT optFunc[] = {
2014 SQL_API_SQLNUMRESULTCOLS, SQL_API_SQLROWCOUNT, 0
2022 for (i = 0; reqFunc[i] != 0; ++i) {
2024 r = SQLGetFunctions(hDbc, reqFunc[i], &sup);
2026 if (r != SQL_SUCCESS) {
2030 if (sup == SQL_FALSE) {
2031 qWarning () <<
"QODBCDriver::open: Warning - Driver doesn't support all needed functionality (" << reqFunc[i] <<
2032 ").\nPlease look at the Qt SQL Module Driver documentation for more information.";
2038 for (i = 0; optFunc[i] != 0; ++i) {
2040 r = SQLGetFunctions(hDbc, optFunc[i], &sup);
2042 if (r != SQL_SUCCESS) {
2046 if (sup == SQL_FALSE) {
2047 qWarning() <<
"QODBCDriver::checkDriver: Warning - Driver doesn't support some non-critical functions (" << optFunc[i] <<
')';
2051 #endif //ODBC_CHECK_DRIVER 2056 void QODBCDriverPrivate::checkSchemaUsage()
2061 r = SQLGetInfo(hDbc,
2066 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
2067 useSchema = (val != 0);
2070 void QODBCDriverPrivate::checkSqlServer()
2075 memset(serverString.
data(), 0, serverString.
size() *
sizeof(SQLTCHAR));
2077 r = SQLGetInfo(hDbc,
2079 serverString.
data(),
2080 serverString.
size() *
sizeof(SQLTCHAR),
2082 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
2085 serverType =
fromSQLTCHAR(serverString, t/
sizeof(SQLTCHAR));
2092 r = SQLGetInfo(hDbc,
2094 serverString.
data(),
2095 serverString.
size() *
sizeof(SQLTCHAR),
2097 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
2100 serverType =
fromSQLTCHAR(serverString, t/
sizeof(SQLTCHAR));
2105 unicode = unicode && !isFreeTDSDriver;
2109 void QODBCDriverPrivate::checkHasSQLFetchScroll()
2112 SQLRETURN r = SQLGetFunctions(hDbc, SQL_API_SQLFETCHSCROLL, &sup);
2113 if ((r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) || sup != SQL_TRUE) {
2114 hasSQLFetchScroll =
false;
2115 qWarning() <<
"QODBCDriver::checkHasSQLFetchScroll: Warning - Driver doesn't support scrollable result sets, use forward only mode for queries";
2119 void QODBCDriverPrivate::checkHasMultiResults()
2123 SQLRETURN r = SQLGetInfo(hDbc,
2124 SQL_MULT_RESULT_SETS,
2125 driverResponse.
data(),
2126 driverResponse.
size() *
sizeof(SQLTCHAR),
2128 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
2136 void QODBCDriverPrivate::checkDateTimePrecision()
2138 SQLINTEGER columnSize;
2141 SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT, hDbc, &hStmt);
2142 if (r != SQL_SUCCESS) {
2146 r = SQLGetTypeInfo(hStmt, SQL_TIMESTAMP);
2147 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
2148 r = SQLFetch(hStmt);
2149 if ( r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO )
2151 if (SQLGetData(hStmt, 3, SQL_INTEGER, &columnSize,
sizeof(columnSize), 0) == SQL_SUCCESS) {
2152 datetime_precision = (int)columnSize;
2156 SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
2167 qWarning() <<
"QODBCDriver::beginTransaction: Database not open";
2170 SQLUINTEGER ac(SQL_AUTOCOMMIT_OFF);
2171 SQLRETURN r = SQLSetConnectAttr(
d->hDbc,
2172 SQL_ATTR_AUTOCOMMIT,
2175 if (r != SQL_SUCCESS) {
2186 qWarning() <<
"QODBCDriver::commitTransaction: Database not open";
2189 SQLRETURN r = SQLEndTran(SQL_HANDLE_DBC,
2192 if (r != SQL_SUCCESS) {
2203 qWarning() <<
"QODBCDriver::rollbackTransaction: Database not open";
2206 SQLRETURN r = SQLEndTran(SQL_HANDLE_DBC,
2209 if (r != SQL_SUCCESS) {
2219 SQLUINTEGER ac(SQL_AUTOCOMMIT_ON);
2220 SQLRETURN r = SQLSetConnectAttr(
d->hDbc,
2221 SQL_ATTR_AUTOCOMMIT,
2224 if (r != SQL_SUCCESS) {
2238 SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT,
2241 if (r != SQL_SUCCESS) {
2245 r = SQLSetStmtAttr(hStmt,
2246 SQL_ATTR_CURSOR_TYPE,
2247 (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
2261 r = SQLTables(hStmt,
2271 (SQLCHAR*)joinedTableTypeString.
toUtf8().
data(),
2273 joinedTableTypeString.
length() );
2275 if (r != SQL_SUCCESS)
2278 if (
d->hasSQLFetchScroll)
2279 r = SQLFetchScroll(hStmt,
2283 r = SQLFetch(hStmt);
2285 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r != SQL_NO_DATA) {
2286 qWarning() <<
"QODBCDriver::tables failed to retrieve table/view list: (" << r <<
"," <<
qWarnODBCHandle(SQL_HANDLE_STMT, hStmt) <<
")";
2290 while (r == SQL_SUCCESS) {
2294 if (
d->hasSQLFetchScroll)
2295 r = SQLFetchScroll(hStmt,
2299 r = SQLFetch(hStmt);
2302 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
2303 if (r!= SQL_SUCCESS)
2313 bool usingSpecialColumns =
false;
2317 SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT,
2320 if (r != SQL_SUCCESS) {
2324 QString catalog, schema, table;
2325 d->splitTableQualifier(tablename, catalog, schema, table);
2330 catalog =
d->adjustCase(catalog);
2335 schema =
d->adjustCase(schema);
2340 table =
d->adjustCase(table);
2342 r = SQLSetStmtAttr(hStmt,
2343 SQL_ATTR_CURSOR_TYPE,
2344 (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
2346 r = SQLPrimaryKeys(hStmt,
2369 if (r != SQL_SUCCESS) {
2370 r = SQLSpecialColumns(hStmt,
2393 if (r != SQL_SUCCESS) {
2396 usingSpecialColumns =
true;
2400 if (
d->hasSQLFetchScroll)
2401 r = SQLFetchScroll(hStmt,
2405 r = SQLFetch(hStmt);
2410 while (r == SQL_SUCCESS) {
2411 if (usingSpecialColumns) {
2421 if (
d->hasSQLFetchScroll)
2422 r = SQLFetchScroll(hStmt,
2426 r = SQLFetch(hStmt);
2429 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
2430 if (r!= SQL_SUCCESS)
2442 QString catalog, schema, table;
2443 d->splitTableQualifier(tablename, catalog, schema, table);
2448 catalog =
d->adjustCase(catalog);
2453 schema =
d->adjustCase(schema);
2458 table =
d->adjustCase(table);
2460 SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT,
2463 if (r != SQL_SUCCESS) {
2467 r = SQLSetStmtAttr(hStmt,
2468 SQL_ATTR_CURSOR_TYPE,
2469 (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
2471 r = SQLColumns(hStmt,
2492 if (r != SQL_SUCCESS)
2495 if (
d->hasSQLFetchScroll)
2496 r = SQLFetchScroll(hStmt,
2500 r = SQLFetch(hStmt);
2503 while (r == SQL_SUCCESS) {
2507 if (
d->hasSQLFetchScroll)
2508 r = SQLFetchScroll(hStmt,
2512 r = SQLFetch(hStmt);
2515 r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
2516 if (r!= SQL_SUCCESS)
2523 bool trimStrings)
const 2547 static const char hexchars[] =
"0123456789abcdef";
2548 for (
int i = 0; i < ba.
size(); ++i) {
2562 return QVariant(qRegisterMetaType<SQLHANDLE>(
"SQLHANDLE"), &
d->hDbc);
2567 QChar quote =
d->quoteChar();
2579 QChar quote =
d->quoteChar();
2580 return identifier.
size() > 2
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QVariant class acts like a union for the most common Qt data types.
The QSqlError class provides SQL database error information.
static QString qODBCWarn(const QODBCPrivate *odbc, int *nativeCode=0)
The QSqlIndex class provides functions to manipulate and describe database indexes.
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int size()
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
const T * constData() const
const QSqlDriver * driver() const
Returns the driver associated with the result.
QVariant handle() const
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
bool fetchPrevious()
Positions the result to the previous record (row) in the result.
bool fetchNext()
Positions the result to the next available record (row) in the result.
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
static mach_timebase_info_data_t info
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const
virtual void setOpen(bool o)
This function sets the open state of the database to open.
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false...
char * data()
Returns a pointer to the data stored in the byte array.
DriverFeature
This enum contains a list of features a driver might support.
QString formatValue(const QSqlField &field, bool trimStrings) const
Returns a string representation of the field value for the database.
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
static int qGetODBCVersion(const QString &connOpts)
#define it(className, varName)
The QFlag class is a helper data type for QFlags.
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
int numRowsAffected()
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
void append(const QSqlField &field)
Appends the field field to the list of indexed fields.
QVariant value() const
Returns the value of the field as a QVariant.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
QString & replace(int i, int len, QChar after)
static QVariant::Type qDecodeODBCType(SQLSMALLINT sqltype, const T *p, bool isSigned=true)
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
QString & prepend(QChar c)
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
static QVarLengthArray< SQLTCHAR > toSQLTCHAR(const QString &input)
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
The QSqlQuery class provides a means of executing and manipulating SQL statements.
QODBCDriverPrivate * driverPrivate
static QVariant qGetDoubleData(SQLHANDLE hStmt, int column)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
bool fetchLast()
Positions the result to the last record (last row) in the result.
void setPrecision(int precision)
Sets the field's precision.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
int day() const
Returns the day of the month (1 to 31) of this date.
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QDate class provides date functions.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString escapeIdentifier(const QString &identifier, IdentifierType type) const
Returns the identifier escaped according to the database rules.
int msec() const
Returns the millisecond part (0 to 999) of the time.
QVariant data(int field)
Returns the data for field index in the current row as a QVariant.
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
The QSqlRecord class encapsulates a database record.
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
The QString class provides a Unicode character string.
int at() const
Returns the current (zero-based) row position of the result.
bool rollbackTransaction()
This function is called to rollback a transaction.
The QObject class is the base class of all Qt objects.
void close()
Derived classes must reimplement this pure virtual function in order to close the database connection...
QODBCPrivate(QODBCDriverPrivate *dpp)
The QChar class provides a 16-bit Unicode character.
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
iterator Iterator
Qt-style synonym for QList::iterator.
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void resize(int size)
Sets the size of the vector to size.
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
static QVariant qGetIntData(SQLHANDLE hStmt, int column, bool isSigned=true)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
ErrorType
This enum type describes the context in which the error occurred, e.
bool fetchFirst()
Positions the result to the first record (row 0) in the result.
virtual void setForwardOnly(bool forward)
Sets forward only mode to forward.
void append(const T &t)
Inserts value at the end of the list.
The QTime class provides clock time functions.
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool commitTransaction()
This function is called to commit a transaction.
bool fetch(int i)
Positions the result to an arbitrary (zero-based) row index.
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
static const SQLSMALLINT qParamType[4]
int size() const
Returns the number of characters in this string.
const QChar * unicode() const
Returns a '\0'-terminated Unicode representation of the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString qWarnODBCHandle(int handleType, SQLHANDLE handle, int *nativeCode=0)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
void virtual_hook(int id, void *data)
bool isNull(int field)
Returns true if the field at position index in the current row is null; otherwise returns false...
static const int COLNAMESIZE
The QStringList class provides a list of strings.
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...
void setLength(int fieldLength)
Sets the field's length to fieldLength.
QSql::ParamType bindValueType(const QString &placeholder) const
Returns the parameter type for the value bound with the given placeholder name.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Q_CORE_EXPORT void qWarning(const char *,...)
int second() const
Returns the second part (0 to 59) of the time.
static const char * data(const QByteArray &arr)
void setName(const QString &name)
Sets the name of the index to name.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Type
This enum type defines the types of variable that a QVariant can contain.
QSqlRecord record(const QString &tablename) const
Returns a QSqlRecord populated with the names of the fields in table tableName.
bool hasFeature(DriverFeature f) const
Returns true if the driver supports feature feature; otherwise returns false.
bool beginTransaction()
This function is called to begin a transaction.
static void qSqlWarning(const QString &message, const QODBCPrivate *odbc)
static QVariant qGetBigIntData(SQLHANDLE hStmt, int column, bool isSigned=true)
int minute() const
Returns the minute part (0 to 59) of the time.
QVariant::Type type() const
Returns the field's type as stored in the database.
virtual void setForwardOnly(bool forward)
Sets forward only mode to forward.
qreal qPow(qreal x, qreal y)
QSqlField field(int i) const
Returns the field at position index.
virtual void virtual_hook(int id, void *data)
bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
QStringList tables(QSql::TableType) const
Returns a list of the names of the tables in the database.
const T & at(int i) const
Returns the item at index position i in the vector.
static QVariant qGetBinaryData(SQLHANDLE hStmt, int column)
int length() const
Same as size().
const char * constData() const
Returns a pointer to the data stored in the byte array.
QDate date() const
Returns the date part of the datetime.
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the time as a string.
int length() const
Returns the field's length.
QString join(const QString &sep) const
Joins all the string list's strings into a single string with each element separated by the given sep...
QVector< QVariant > fieldCache
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
int count() const
Returns the number of fields in the record.
void setRequired(bool required)
Sets the required status of this field to Required if required is true; otherwise sets it to Optional...
QString & append(QChar c)
The QDateTime class provides date and time functions.
QSqlResult * createResult() const
Creates an empty SQL result on the database.
int capacity() const
Returns the maximum number of characters that can be stored in the string without forcing a reallocat...
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
bool isStmtHandleValid(const QSqlDriver *driver)
void clear()
Clears the contents of the string and makes it empty.
QODBCDriver(QObject *parent=0)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool unicode=false)
Type type() const
Returns the storage type of the value stored in the variant.
QSqlIndex primaryIndex(const QString &tablename) const
Returns the primary index for table tableName.
QObject * parent() const
Returns a pointer to the parent object.
bool isNull() const
Returns true if the field's value is NULL; otherwise returns false.
const void * constData() const
virtual QString formatValue(const QSqlField &field, bool trimStrings=false) const
Returns a string representation of the field value for the database.
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
void resize(int size)
Sets the size of the byte array to size bytes.
QODBCResult(const QODBCDriver *db, QODBCDriverPrivate *p)
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
static QSqlField qMakeFieldInfo(const SQLHANDLE hStmt, const QODBCDriverPrivate *p)
bool open(const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts)
Derived classes must reimplement this pure virtual function to open a database connection on database...
bool exec()
Executes the query, returning true if successful; otherwise returns false.
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
int size() const
Returns the number of bytes in this byte array.
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
void clear()
Removes all the record's fields.
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QODBCPrivate *p)
int year() const
Returns the year of this date.
T * data()
Returns a pointer to the data stored in the vector.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
QTime time() const
Returns the time part of the datetime.
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
The QSqlField class manipulates the fields in SQL database tables and views.
bool exec(const QString &query)
Executes the SQL in query.
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
QVector< QVariant > & boundValues() const
Returns a vector of the result's bound values for the current record (row).
char at(int i) const
Returns the character at index position i in the byte array.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
static QString fromSQLTCHAR(const QVarLengthArray< SQLTCHAR > &input, int size=-1)
QVector< uint > toUcs4() const Q_REQUIRED_RESULT
Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases...
int size() const
Returns the number of items in the vector.
QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
IdentifierType
This enum contains a list of SQL identifier types.
bool reset(const QString &query)
Sets the result to use the SQL statement query for subsequent data retrieval.
Q_CORE_EXPORT void qCritical(const char *,...)
static QString fromUtf16(const ushort *, int size=-1)
Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646...
int hour() const
Returns the hour part (0 to 23) of the time.
void setSqlType(int type)
void updateStmtHandleState(const QSqlDriver *driver)
static QString fromUcs4(const uint *, int size=-1)
Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646...