Qt 4.8
Public Functions | Protected Functions | Properties | List of all members
QDB2Result Class Reference

#include <qsql_db2.h>

Inheritance diagram for QDB2Result:
QSqlResult

Public Functions

bool exec ()
 Executes the query, returning true if successful; otherwise returns false. More...
 
QVariant handle () const
 Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVariant if there is no handle. More...
 
bool prepare (const QString &query)
 Prepares the given query for execution; the query will normally use placeholders so that it can be executed repeatedly. More...
 
 QDB2Result (const QDB2Driver *dr, const QDB2DriverPrivate *dp)
 
 ~QDB2Result ()
 
- Public Functions inherited from QSqlResult
virtual ~QSqlResult ()
 Destroys the object and frees any allocated resources. More...
 

Protected Functions

QVariant data (int field)
 Returns the data for field index in the current row as a QVariant. More...
 
bool fetch (int i)
 Positions the result to an arbitrary (zero-based) row index. More...
 
bool fetchFirst ()
 Positions the result to the first record (row 0) in the result. More...
 
bool fetchLast ()
 Positions the result to the last record (last row) in the result. More...
 
bool fetchNext ()
 Positions the result to the next available record (row) in the result. More...
 
bool isNull (int i)
 Returns true if the field at position index in the current row is null; otherwise returns false. More...
 
bool nextResult ()
 
int numRowsAffected ()
 Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or if the query is a SELECT statement. More...
 
QSqlRecord record () const
 Returns the current record if the query is active; otherwise returns an empty QSqlRecord. More...
 
bool reset (const QString &query)
 Sets the result to use the SQL statement query for subsequent data retrieval. More...
 
int size ()
 Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELECT statement. More...
 
void virtual_hook (int id, void *data)
 
- Protected Functions inherited from QSqlResult
void addBindValue (const QVariant &val, QSql::ParamType type)
 Binds the value val of parameter type paramType to the next available position in the current record (row). More...
 
int at () const
 Returns the current (zero-based) row position of the result. More...
 
BindingSyntax bindingSyntax () const
 Returns the binding syntax used by prepared queries. More...
 
virtual void bindValue (int pos, const QVariant &val, QSql::ParamType type)
 Binds the value val of parameter type paramType to position index in the current record (row). More...
 
virtual void bindValue (const QString &placeholder, const QVariant &val, QSql::ParamType type)
 Binds the value val of parameter type paramType to the placeholder name in the current record (row). More...
 
QSql::ParamType bindValueType (const QString &placeholder) const
 Returns the parameter type for the value bound with the given placeholder name. More...
 
QSql::ParamType bindValueType (int pos) const
 Returns the parameter type for the value bound at position index. More...
 
QVariant boundValue (const QString &placeholder) const
 Returns the value bound by the given placeholder name in the current record (row). More...
 
QVariant boundValue (int pos) const
 Returns the value bound at position index in the current record (row). More...
 
int boundValueCount () const
 Returns the number of bound values in the result. More...
 
QString boundValueName (int pos) const
 Returns the name of the bound value at position index in the current record (row). More...
 
QVector< QVariant > & boundValues () const
 Returns a vector of the result's bound values for the current record (row). More...
 
void clear ()
 Clears the entire result set and releases any associated resources. More...
 
void detachFromResultSet ()
 
const QSqlDriverdriver () const
 Returns the driver associated with the result. More...
 
bool execBatch (bool arrayBind=false)
 Executes a prepared query in batch mode if the driver supports it, otherwise emulates a batch execution using bindValue() and exec(). More...
 
QString executedQuery () const
 Returns the query that was actually executed. More...
 
virtual bool fetchPrevious ()
 Positions the result to the previous record (row) in the result. More...
 
bool hasOutValues () const
 Returns true if at least one of the query's bound values is a QSql::Out or a QSql::InOut; otherwise returns false. More...
 
bool isActive () const
 Returns true if the result has records to be retrieved; otherwise returns false. More...
 
bool isForwardOnly () const
 Returns true if you can only scroll forward through the result set; otherwise returns false. More...
 
bool isSelect () const
 Returns true if the current result is from a SELECT statement; otherwise returns false. More...
 
bool isValid () const
 Returns true if the result is positioned on a valid record (that is, the result is not positioned before the first or after the last record); otherwise returns false. More...
 
QSqlError lastError () const
 Returns the last error associated with the result. More...
 
virtual QVariant lastInsertId () const
 Returns the object ID of the most recent inserted row if the database supports it. More...
 
QString lastQuery () const
 Returns the current SQL query text, or an empty string if there isn't one. More...
 
bool nextResult ()
 
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy () const
 
 QSqlResult (const QSqlDriver *db)
 Creates a QSqlResult using database driver db. More...
 
virtual bool savePrepare (const QString &sqlquery)
 Prepares the given query, using the underlying database functionality where possible. More...
 
virtual void setActive (bool a)
 This function is provided for derived classes to set the internal active state to active. More...
 
virtual void setAt (int at)
 This function is provided for derived classes to set the internal (zero-based) row position to index. More...
 
virtual void setForwardOnly (bool forward)
 Sets forward only mode to forward. More...
 
virtual void setLastError (const QSqlError &e)
 This function is provided for derived classes to set the last error to error. More...
 
void setNumericalPrecisionPolicy (QSql::NumericalPrecisionPolicy policy)
 
virtual void setQuery (const QString &query)
 Sets the current query for the result to query. More...
 
virtual void setSelect (bool s)
 This function is provided for derived classes to indicate whether or not the current statement is a SQL SELECT statement. More...
 

Properties

QDB2ResultPrivated
 

Additional Inherited Members

- Protected Types inherited from QSqlResult
enum  BindingSyntax { PositionalBinding, NamedBinding }
 This enum type specifies the different syntaxes for specifying placeholders in prepared queries. More...
 
enum  VirtualHookOperation { BatchOperation, DetachFromResultSet, SetNumericalPrecision, NextResult }
 

Detailed Description

Definition at line 62 of file qsql_db2.h.

Constructors and Destructors

◆ QDB2Result()

QDB2Result::QDB2Result ( const QDB2Driver dr,
const QDB2DriverPrivate dp 
)

Definition at line 520 of file qsql_db2.cpp.

521  : QSqlResult(dr)
522 {
523  d = new QDB2ResultPrivate(dp);
524 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
QSqlResult(const QSqlDriver *db)
Creates a QSqlResult using database driver db.
Definition: qsqlresult.cpp:257

◆ ~QDB2Result()

QDB2Result::~QDB2Result ( )

Definition at line 526 of file qsql_db2.cpp.

527 {
528  if (d->hStmt) {
529  SQLRETURN r = SQLFreeHandle(SQL_HANDLE_STMT, d->hStmt);
530  if (r != SQL_SUCCESS)
531  qSqlWarning(QLatin1String("QDB2Driver: Unable to free statement handle ")
532  + QString::number(r), d);
533  }
534  delete d;
535 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
Definition: qsql_db2.cpp:155
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105

Functions

◆ data()

QVariant QDB2Result::data ( int  index)
protectedvirtual

Returns the data for field index in the current row as a QVariant.

This function is only called if the result is in an active state and is positioned on a valid record and index is non-negative. Derived classes must reimplement this function and return the value of field index, or QVariant() if it cannot be determined.

Implements QSqlResult.

Definition at line 951 of file qsql_db2.cpp.

Referenced by exec(), isNull(), and virtual_hook().

952 {
953  if (field >= d->recInf.count()) {
954  qWarning("QDB2Result::data: column %d out of range", field);
955  return QVariant();
956  }
957  SQLRETURN r = 0;
958  SQLINTEGER lengthIndicator = 0;
959  bool isNull = false;
960  const QSqlField info = d->recInf.field(field);
961 
962  if (!info.isValid() || field >= d->valueCache.size())
963  return QVariant();
964 
965  if (d->valueCache[field])
966  return *d->valueCache[field];
967 
968 
969  QVariant* v = 0;
970  switch (info.type()) {
971  case QVariant::LongLong:
972  v = new QVariant((qint64) qGetBigIntData(d->hStmt, field, isNull));
973  break;
974  case QVariant::Int:
975  v = new QVariant(qGetIntData(d->hStmt, field, isNull));
976  break;
977  case QVariant::Date: {
978  DATE_STRUCT dbuf;
979  r = SQLGetData(d->hStmt,
980  field + 1,
981  SQL_C_DATE,
982  (SQLPOINTER) &dbuf,
983  0,
984  &lengthIndicator);
985  if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA)) {
986  v = new QVariant(QDate(dbuf.year, dbuf.month, dbuf.day));
987  } else {
988  v = new QVariant(QDate());
989  isNull = true;
990  }
991  break; }
992  case QVariant::Time: {
993  TIME_STRUCT tbuf;
994  r = SQLGetData(d->hStmt,
995  field + 1,
996  SQL_C_TIME,
997  (SQLPOINTER) &tbuf,
998  0,
999  &lengthIndicator);
1000  if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA)) {
1001  v = new QVariant(QTime(tbuf.hour, tbuf.minute, tbuf.second));
1002  } else {
1003  v = new QVariant(QTime());
1004  isNull = true;
1005  }
1006  break; }
1007  case QVariant::DateTime: {
1008  TIMESTAMP_STRUCT dtbuf;
1009  r = SQLGetData(d->hStmt,
1010  field + 1,
1011  SQL_C_TIMESTAMP,
1012  (SQLPOINTER) &dtbuf,
1013  0,
1014  &lengthIndicator);
1015  if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (lengthIndicator != SQL_NULL_DATA)) {
1016  v = new QVariant(QDateTime(QDate(dtbuf.year, dtbuf.month, dtbuf.day),
1017  QTime(dtbuf.hour, dtbuf.minute, dtbuf.second, dtbuf.fraction / 1000000)));
1018  } else {
1019  v = new QVariant(QDateTime());
1020  isNull = true;
1021  }
1022  break; }
1023  case QVariant::ByteArray:
1024  v = new QVariant(qGetBinaryData(d->hStmt, field, lengthIndicator, isNull));
1025  break;
1026  case QVariant::Double:
1027  {
1028  switch(numericalPrecisionPolicy()) {
1030  v = new QVariant(qGetIntData(d->hStmt, field, isNull));
1031  break;
1033  v = new QVariant((qint64) qGetBigIntData(d->hStmt, field, isNull));
1034  break;
1036  v = new QVariant(qGetDoubleData(d->hStmt, field, isNull));
1037  break;
1038  case QSql::HighPrecision:
1039  default:
1040  // length + 1 for the comma
1041  v = new QVariant(qGetStringData(d->hStmt, field, info.length() + 1, isNull));
1042  break;
1043  }
1044  break;
1045  }
1046  case QVariant::String:
1047  default:
1048  v = new QVariant(qGetStringData(d->hStmt, field, info.length(), isNull));
1049  break;
1050  }
1051  if (isNull)
1052  *v = QVariant(info.type());
1053  d->valueCache[field] = v;
1054  return *v;
1055 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
bool isValid() const
Returns true if the field&#39;s variant type is valid; otherwise returns false.
Definition: qsqlfield.cpp:517
static mach_timebase_info_data_t info
The QDate class provides date functions.
Definition: qdatetime.h:55
bool isNull(int i)
Returns true if the field at position index in the current row is null; otherwise returns false...
Definition: qsql_db2.cpp:1057
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
static QByteArray qGetBinaryData(SQLHANDLE hStmt, int column, SQLINTEGER &lengthIndicator, bool &isNull)
Definition: qsql_db2.cpp:364
static SQLBIGINT qGetBigIntData(SQLHANDLE hStmt, int column, bool &isNull)
Definition: qsql_db2.cpp:307
The QTime class provides clock time functions.
Definition: qdatetime.h:148
Q_CORE_EXPORT void qWarning(const char *,...)
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105
__int64 qint64
Definition: qglobal.h:942
QVariant::Type type() const
Returns the field&#39;s type as stored in the database.
Definition: qsqlfield.cpp:394
QSqlField field(int i) const
Returns the field at position index.
Definition: qsqlrecord.cpp:289
int length() const
Returns the field&#39;s length.
Definition: qsqlfield.cpp:457
int count() const
Returns the number of fields in the record.
Definition: qsqlrecord.cpp:573
static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool &isNull)
Definition: qsql_db2.cpp:324
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
QVector< QVariant * > valueCache
Definition: qsql_db2.cpp:107
The QSqlField class manipulates the fields in SQL database tables and views.
Definition: qsqlfield.h:56
static double qGetDoubleData(SQLHANDLE hStmt, int column, bool &isNull)
Definition: qsql_db2.cpp:288
QSqlRecord recInf
Definition: qsql_db2.cpp:106
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
static int qGetIntData(SQLHANDLE hStmt, int column, bool &isNull)
Definition: qsql_db2.cpp:270

◆ exec()

bool QDB2Result::exec ( )
virtual

Executes the query, returning true if successful; otherwise returns false.

See also
prepare()

Reimplemented from QSqlResult.

Definition at line 597 of file qsql_db2.cpp.

598 {
599  QList<QByteArray> tmpStorage; // holds temporary ptrs
600  QVarLengthArray<SQLINTEGER, 32> indicators(boundValues().count());
601 
602  memset(indicators.data(), 0, indicators.size() * sizeof(SQLINTEGER));
603  setActive(false);
605  SQLRETURN r;
606 
607  d->recInf.clear();
608  d->emptyValueCache();
609 
610  if (!qMakeStatement(d, isForwardOnly(), false))
611  return false;
612 
613 
615  int i;
616  for (i = 0; i < values.count(); ++i) {
617  // bind parameters - only positional binding allowed
618  SQLINTEGER *ind = &indicators[i];
619  if (values.at(i).isNull())
620  *ind = SQL_NULL_DATA;
621  if (bindValueType(i) & QSql::Out)
622  values[i].detach();
623 
624  switch (values.at(i).type()) {
625  case QVariant::Date: {
626  QByteArray ba;
627  ba.resize(sizeof(DATE_STRUCT));
628  DATE_STRUCT *dt = (DATE_STRUCT *)ba.constData();
629  QDate qdt = values.at(i).toDate();
630  dt->year = qdt.year();
631  dt->month = qdt.month();
632  dt->day = qdt.day();
633  r = SQLBindParameter(d->hStmt,
634  i + 1,
635  qParamType[(QFlag)(bindValueType(i)) & 3],
636  SQL_C_DATE,
637  SQL_DATE,
638  0,
639  0,
640  (void *) dt,
641  0,
642  *ind == SQL_NULL_DATA ? ind : NULL);
643  tmpStorage.append(ba);
644  break; }
645  case QVariant::Time: {
646  QByteArray ba;
647  ba.resize(sizeof(TIME_STRUCT));
648  TIME_STRUCT *dt = (TIME_STRUCT *)ba.constData();
649  QTime qdt = values.at(i).toTime();
650  dt->hour = qdt.hour();
651  dt->minute = qdt.minute();
652  dt->second = qdt.second();
653  r = SQLBindParameter(d->hStmt,
654  i + 1,
655  qParamType[(QFlag)(bindValueType(i)) & 3],
656  SQL_C_TIME,
657  SQL_TIME,
658  0,
659  0,
660  (void *) dt,
661  0,
662  *ind == SQL_NULL_DATA ? ind : NULL);
663  tmpStorage.append(ba);
664  break; }
665  case QVariant::DateTime: {
666  QByteArray ba;
667  ba.resize(sizeof(TIMESTAMP_STRUCT));
668  TIMESTAMP_STRUCT * dt = (TIMESTAMP_STRUCT *)ba.constData();
669  QDateTime qdt = values.at(i).toDateTime();
670  dt->year = qdt.date().year();
671  dt->month = qdt.date().month();
672  dt->day = qdt.date().day();
673  dt->hour = qdt.time().hour();
674  dt->minute = qdt.time().minute();
675  dt->second = qdt.time().second();
676  dt->fraction = qdt.time().msec() * 1000000;
677  r = SQLBindParameter(d->hStmt,
678  i + 1,
679  qParamType[(QFlag)(bindValueType(i)) & 3],
680  SQL_C_TIMESTAMP,
681  SQL_TIMESTAMP,
682  0,
683  0,
684  (void *) dt,
685  0,
686  *ind == SQL_NULL_DATA ? ind : NULL);
687  tmpStorage.append(ba);
688  break; }
689  case QVariant::Int:
690  r = SQLBindParameter(d->hStmt,
691  i + 1,
692  qParamType[(QFlag)(bindValueType(i)) & 3],
693  SQL_C_SLONG,
694  SQL_INTEGER,
695  0,
696  0,
697  (void *)values.at(i).constData(),
698  0,
699  *ind == SQL_NULL_DATA ? ind : NULL);
700  break;
701  case QVariant::Double:
702  r = SQLBindParameter(d->hStmt,
703  i + 1,
704  qParamType[(QFlag)(bindValueType(i)) & 3],
705  SQL_C_DOUBLE,
706  SQL_DOUBLE,
707  0,
708  0,
709  (void *)values.at(i).constData(),
710  0,
711  *ind == SQL_NULL_DATA ? ind : NULL);
712  break;
713  case QVariant::ByteArray: {
714  int len = values.at(i).toByteArray().size();
715  if (*ind != SQL_NULL_DATA)
716  *ind = len;
717  r = SQLBindParameter(d->hStmt,
718  i + 1,
719  qParamType[(QFlag)(bindValueType(i)) & 3],
720  SQL_C_BINARY,
721  SQL_LONGVARBINARY,
722  len,
723  0,
724  (void *)values.at(i).toByteArray().constData(),
725  len,
726  ind);
727  break; }
728  case QVariant::String:
729  {
730  QString str(values.at(i).toString());
731  if (*ind != SQL_NULL_DATA)
732  *ind = str.length() * sizeof(QChar);
733  if (bindValueType(i) & QSql::Out) {
734  QByteArray ba((char*)str.utf16(), str.capacity() * sizeof(QChar));
735  r = SQLBindParameter(d->hStmt,
736  i + 1,
737  qParamType[(QFlag)(bindValueType(i)) & 3],
738  SQL_C_WCHAR,
739  SQL_WVARCHAR,
740  str.length(),
741  0,
742  (void *)ba.constData(),
743  ba.size(),
744  ind);
745  tmpStorage.append(ba);
746  } else {
747  void *data = (void*)str.utf16();
748  int len = str.length();
749  r = SQLBindParameter(d->hStmt,
750  i + 1,
751  qParamType[(QFlag)(bindValueType(i)) & 3],
752  SQL_C_WCHAR,
753  SQL_WVARCHAR,
754  len,
755  0,
756  data,
757  len * sizeof(QChar),
758  ind);
759  }
760  break;
761  }
762  default: {
763  QByteArray ba = values.at(i).toString().toAscii();
764  int len = ba.length() + 1;
765  if (*ind != SQL_NULL_DATA)
766  *ind = ba.length();
767  r = SQLBindParameter(d->hStmt,
768  i + 1,
769  qParamType[(QFlag)(bindValueType(i)) & 3],
770  SQL_C_CHAR,
771  SQL_VARCHAR,
772  len,
773  0,
774  (void *) ba.constData(),
775  len,
776  ind);
777  tmpStorage.append(ba);
778  break; }
779  }
780  if (r != SQL_SUCCESS) {
781  qWarning("QDB2Result::exec: unable to bind variable: %s",
782  qDB2Warn(d).toLocal8Bit().constData());
784  "Unable to bind variable"), QSqlError::StatementError, d));
785  return false;
786  }
787  }
788 
789  r = SQLExecute(d->hStmt);
790  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
791  qWarning("QDB2Result::exec: Unable to execute statement: %s",
792  qDB2Warn(d).toLocal8Bit().constData());
794  "Unable to execute statement"), QSqlError::StatementError, d));
795  return false;
796  }
797  SQLSMALLINT count;
798  r = SQLNumResultCols(d->hStmt, &count);
799  if (count) {
800  setSelect(true);
801  for (int i = 0; i < count; ++i) {
803  }
804  } else {
805  setSelect(false);
806  }
807  setActive(true);
808  d->valueCache.resize(count);
809  d->valueCache.fill(NULL);
810 
811  //get out parameters
812  if (!hasOutValues())
813  return true;
814 
815  for (i = 0; i < values.count(); ++i) {
816  switch (values[i].type()) {
817  case QVariant::Date: {
818  DATE_STRUCT ds = *((DATE_STRUCT *)tmpStorage.takeFirst().constData());
819  values[i] = QVariant(QDate(ds.year, ds.month, ds.day));
820  break; }
821  case QVariant::Time: {
822  TIME_STRUCT dt = *((TIME_STRUCT *)tmpStorage.takeFirst().constData());
823  values[i] = QVariant(QTime(dt.hour, dt.minute, dt.second));
824  break; }
825  case QVariant::DateTime: {
826  TIMESTAMP_STRUCT dt = *((TIMESTAMP_STRUCT *)tmpStorage.takeFirst().constData());
827  values[i] = QVariant(QDateTime(QDate(dt.year, dt.month, dt.day),
828  QTime(dt.hour, dt.minute, dt.second, dt.fraction / 1000000)));
829  break; }
830  case QVariant::Int:
831  case QVariant::Double:
832  case QVariant::ByteArray:
833  break;
834  case QVariant::String:
835  if (bindValueType(i) & QSql::Out)
836  values[i] = QString((const QChar *)tmpStorage.takeFirst().constData());
837  break;
838  default: {
839  values[i] = QString::fromAscii(tmpStorage.takeFirst().constData());
840  break; }
841  }
842  if (indicators[i] == SQL_NULL_DATA)
843  values[i] = QVariant(values[i].type());
844  }
845  return true;
846 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
int type
Definition: qmetatype.cpp:239
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false...
Definition: qsqlresult.cpp:582
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
The QFlag class is a helper data type for QFlags.
Definition: qglobal.h:2289
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
Definition: qdatetime.cpp:382
static bool qMakeStatement(QDB2ResultPrivate *d, bool forwardOnly, bool setForwardOnly=true)
Definition: qsql_db2.cpp:471
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
int day() const
Returns the day of the month (1 to 31) of this date.
Definition: qdatetime.cpp:395
The QDate class provides date functions.
Definition: qdatetime.h:55
int msec() const
Returns the millisecond part (0 to 999) of the time.
Definition: qdatetime.cpp:1611
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QTime class provides clock time functions.
Definition: qdatetime.h:148
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
Definition: qsqlresult.cpp:367
void emptyValueCache()
Definition: qsql_db2.cpp:98
QVariant data(int field)
Returns the data for field index in the current row as a QVariant.
Definition: qsql_db2.cpp:951
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
bool hasOutValues() const
Returns true if at least one of the query&#39;s bound values is a QSql::Out or a QSql::InOut; otherwise r...
Definition: qsqlresult.cpp:916
QSql::ParamType bindValueType(const QString &placeholder) const
Returns the parameter type for the value bound with the given placeholder name.
Definition: qsqlresult.cpp:838
Q_CORE_EXPORT void qWarning(const char *,...)
int second() const
Returns the second part (0 to 59) of the time.
Definition: qdatetime.cpp:1600
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105
int minute() const
Returns the minute part (0 to 59) of the time.
Definition: qdatetime.cpp:1589
quint16 values[128]
static QString qDB2Warn(const QDB2DriverPrivate *d)
Definition: qsql_db2.cpp:142
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
static const SQLSMALLINT qParamType[4]
Definition: qsql_db2.cpp:71
int length() const
Same as size().
Definition: qbytearray.h:356
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2311
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
static QSqlField qMakeFieldInfo(const QDB2ResultPrivate *d, int i)
Definition: qsql_db2.cpp:234
QVector< QVariant * > valueCache
Definition: qsql_db2.cpp:107
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
const void * constData() const
Definition: qvariant.cpp:3065
void resize(int size)
Sets the size of the byte array to size bytes.
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
Definition: qsqlrecord.cpp:312
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
Definition: qsqlresult.cpp:402
void clear()
Removes all the record&#39;s fields.
Definition: qsqlrecord.cpp:367
int year() const
Returns the year of this date.
Definition: qdatetime.cpp:353
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368
Definition: qsql.h:68
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2330
QVector< QVariant > & boundValues() const
Returns a vector of the result&#39;s bound values for the current record (row).
Definition: qsqlresult.cpp:859
QSqlRecord recInf
Definition: qsql_db2.cpp:106
int hour() const
Returns the hour part (0 to 23) of the time.
Definition: qdatetime.cpp:1578

◆ fetch()

bool QDB2Result::fetch ( int  index)
protectedvirtual

Positions the result to an arbitrary (zero-based) row index.

This function is only called if the result is in an active state. Derived classes must reimplement this function and position the result to the row index, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.

See also
isActive(), fetchFirst(), fetchLast(), fetchNext(), fetchPrevious()

Implements QSqlResult.

Definition at line 848 of file qsql_db2.cpp.

Referenced by fetchLast().

849 {
850  if (isForwardOnly() && i < at())
851  return false;
852  if (i == at())
853  return true;
854  d->clearValueCache();
855  int actualIdx = i + 1;
856  if (actualIdx <= 0) {
858  return false;
859  }
860  SQLRETURN r;
861  if (isForwardOnly()) {
862  bool ok = true;
863  while (ok && i > at())
864  ok = fetchNext();
865  return ok;
866  } else {
867  r = SQLFetchScroll(d->hStmt,
868  SQL_FETCH_ABSOLUTE,
869  actualIdx);
870  }
871  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r != SQL_NO_DATA) {
873  "Unable to fetch record %1").arg(i), QSqlError::StatementError, d));
874  return false;
875  }
876  else if (r == SQL_NO_DATA)
877  return false;
878  setAt(i);
879  return true;
880 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false...
Definition: qsqlresult.cpp:582
int at() const
Returns the current (zero-based) row position of the result.
Definition: qsqlresult.cpp:306
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105
void clearValueCache()
Definition: qsql_db2.cpp:91
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
bool fetchNext()
Positions the result to the next available record (row) in the result.
Definition: qsql_db2.cpp:882

◆ fetchFirst()

bool QDB2Result::fetchFirst ( )
protectedvirtual

Positions the result to the first record (row 0) in the result.

This function is only called if the result is in an active state. Derived classes must reimplement this function and position the result to the first record, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.

See also
fetch(), fetchLast()

Implements QSqlResult.

Definition at line 899 of file qsql_db2.cpp.

900 {
901  if (isForwardOnly() && at() != QSql::BeforeFirstRow)
902  return false;
903  if (isForwardOnly())
904  return fetchNext();
905  d->clearValueCache();
906  SQLRETURN r;
907  r = SQLFetchScroll(d->hStmt,
908  SQL_FETCH_FIRST,
909  0);
910  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
911  if(r!= SQL_NO_DATA)
912  setLastError(qMakeError(QCoreApplication::translate("QDB2Result", "Unable to fetch first"),
914  return false;
915  }
916  setAt(0);
917  return true;
918 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false...
Definition: qsqlresult.cpp:582
int at() const
Returns the current (zero-based) row position of the result.
Definition: qsqlresult.cpp:306
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105
void clearValueCache()
Definition: qsql_db2.cpp:91
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
bool fetchNext()
Positions the result to the next available record (row) in the result.
Definition: qsql_db2.cpp:882

◆ fetchLast()

bool QDB2Result::fetchLast ( )
protectedvirtual

Positions the result to the last record (last row) in the result.

This function is only called if the result is in an active state. Derived classes must reimplement this function and position the result to the last record, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.

See also
fetch(), fetchFirst()

Implements QSqlResult.

Definition at line 920 of file qsql_db2.cpp.

921 {
922  d->clearValueCache();
923 
924  int i = at();
925  if (i == QSql::AfterLastRow) {
926  if (isForwardOnly()) {
927  return false;
928  } else {
929  if (!fetch(0))
930  return false;
931  i = at();
932  }
933  }
934 
935  while (fetchNext())
936  ++i;
937 
938  if (i == QSql::BeforeFirstRow) {
940  return false;
941  }
942 
943  if (!isForwardOnly())
944  return fetch(i);
945 
946  setAt(i);
947  return true;
948 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false...
Definition: qsqlresult.cpp:582
int at() const
Returns the current (zero-based) row position of the result.
Definition: qsqlresult.cpp:306
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
bool fetch(int i)
Positions the result to an arbitrary (zero-based) row index.
Definition: qsql_db2.cpp:848
void clearValueCache()
Definition: qsql_db2.cpp:91
bool fetchNext()
Positions the result to the next available record (row) in the result.
Definition: qsql_db2.cpp:882

◆ fetchNext()

bool QDB2Result::fetchNext ( )
protectedvirtual

Positions the result to the next available record (row) in the result.

This function is only called if the result is in an active state. The default implementation calls fetch() with the next index. Derived classes can reimplement this function and position the result to the next record in some other way, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.

See also
fetch(), fetchPrevious()

Reimplemented from QSqlResult.

Definition at line 882 of file qsql_db2.cpp.

Referenced by fetch(), fetchFirst(), and fetchLast().

883 {
884  SQLRETURN r;
885  d->clearValueCache();
886  r = SQLFetchScroll(d->hStmt,
887  SQL_FETCH_NEXT,
888  0);
889  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
890  if (r != SQL_NO_DATA)
892  "Unable to fetch next"), QSqlError::StatementError, d));
893  return false;
894  }
895  setAt(at() + 1);
896  return true;
897 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
int at() const
Returns the current (zero-based) row position of the result.
Definition: qsqlresult.cpp:306
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105
void clearValueCache()
Definition: qsql_db2.cpp:91
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167

◆ handle()

QVariant QDB2Result::handle ( ) const
virtual

Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVariant if there is no handle.

Warning
Use this with uttermost care and only if you know what you're doing.
The handle returned here can become a stale pointer if the result is modified (for example, if you clear it).
The handle can be NULL if the result was not executed yet.

The handle returned here is database-dependent, you should query the type name of the variant before accessing it.

This example retrieves the handle for a sqlite result:

QSqlQuery query = ...
QVariant v = query.result()->handle();
if (v.isValid() && qstrcmp(v.typeName(), "sqlite3_stmt*")) {
// v.data() returns a pointer to the handle
sqlite3_stmt *handle = *static_cast<sqlite3_stmt **>(v.data());
if (handle != 0) { // check that it is not NULL
...
}
}

This snippet returns the handle for PostgreSQL or MySQL:

if (v.typeName() == "PGresult*") {
PGresult *handle = *static_cast<PGresult **>(v.data());
if (handle != 0) ...
}
if (v.typeName() == "MYSQL_STMT*") {
MYSQL_STMT *handle = *static_cast<MYSQL_STMT **>(v.data());
if (handle != 0) ...
}
See also
QSqlDriver::handle()

Reimplemented from QSqlResult.

Definition at line 513 of file qsql_db2.cpp.

514 {
515  return QVariant(qRegisterMetaType<SQLHANDLE>("SQLHANDLE"), &d->hStmt);
516 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105

◆ isNull()

bool QDB2Result::isNull ( int  i)
protectedvirtual

Returns true if the field at position index in the current row is null; otherwise returns false.

Implements QSqlResult.

Definition at line 1057 of file qsql_db2.cpp.

Referenced by data().

1058 {
1059  if (i >= d->valueCache.size())
1060  return true;
1061 
1062  if (d->valueCache[i])
1063  return d->valueCache[i]->isNull();
1064  return data(i).isNull();
1065 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
QVariant data(int field)
Returns the data for field index in the current row as a QVariant.
Definition: qsql_db2.cpp:951
QVector< QVariant * > valueCache
Definition: qsql_db2.cpp:107
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ nextResult()

bool QDB2Result::nextResult ( )
protected

Definition at line 1090 of file qsql_db2.cpp.

Referenced by virtual_hook().

1091 {
1092  setActive(false);
1094  d->recInf.clear();
1095  d->emptyValueCache();
1096  setSelect(false);
1097 
1098  SQLRETURN r = SQLMoreResults(d->hStmt);
1099  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1100  if (r != SQL_NO_DATA) {
1102  "Unable to fetch last"), QSqlError::ConnectionError, d));
1103  }
1104  return false;
1105  }
1106 
1107  SQLSMALLINT fieldCount;
1108  r = SQLNumResultCols(d->hStmt, &fieldCount);
1109  setSelect(fieldCount > 0);
1110  for (int i = 0; i < fieldCount; ++i)
1111  d->recInf.append(qMakeFieldInfo(d, i));
1112 
1113  d->valueCache.resize(fieldCount);
1114  d->valueCache.fill(NULL);
1115  setActive(true);
1116 
1117  return true;
1118 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
Definition: qsqlresult.cpp:367
void emptyValueCache()
Definition: qsql_db2.cpp:98
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
static QSqlField qMakeFieldInfo(const QDB2ResultPrivate *d, int i)
Definition: qsql_db2.cpp:234
QVector< QVariant * > valueCache
Definition: qsql_db2.cpp:107
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
Definition: qsqlrecord.cpp:312
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
Definition: qsqlresult.cpp:402
void clear()
Removes all the record&#39;s fields.
Definition: qsqlrecord.cpp:367
QSqlRecord recInf
Definition: qsql_db2.cpp:106

◆ numRowsAffected()

int QDB2Result::numRowsAffected ( )
protectedvirtual

Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or if the query is a SELECT statement.

See also
size()

Implements QSqlResult.

Definition at line 1067 of file qsql_db2.cpp.

1068 {
1069  SQLINTEGER affectedRowCount = 0;
1070  SQLRETURN r = SQLRowCount(d->hStmt, &affectedRowCount);
1071  if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
1072  return affectedRowCount;
1073  else
1074  qSqlWarning(QLatin1String("QDB2Result::numRowsAffected: Unable to count affected rows"), d);
1075  return -1;
1076 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
Definition: qsql_db2.cpp:155
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105

◆ prepare()

bool QDB2Result::prepare ( const QString query)
virtual

Prepares the given query for execution; the query will normally use placeholders so that it can be executed repeatedly.

Returns true if the query is prepared successfully; otherwise returns false.

See also
exec()

Reimplemented from QSqlResult.

Definition at line 573 of file qsql_db2.cpp.

574 {
575  setActive(false);
577  SQLRETURN r;
578 
579  d->recInf.clear();
580  d->emptyValueCache();
581 
582  if (!qMakeStatement(d, isForwardOnly()))
583  return false;
584 
585  r = SQLPrepare(d->hStmt,
586  qToTChar(query),
587  (SQLINTEGER) query.length());
588 
589  if (r != SQL_SUCCESS) {
591  "Unable to prepare statement"), QSqlError::StatementError, d));
592  return false;
593  }
594  return true;
595 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false...
Definition: qsqlresult.cpp:582
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static bool qMakeStatement(QDB2ResultPrivate *d, bool forwardOnly, bool setForwardOnly=true)
Definition: qsql_db2.cpp:471
static SQLTCHAR * qToTChar(const QString &str)
Definition: qsql_db2.cpp:117
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417
void emptyValueCache()
Definition: qsql_db2.cpp:98
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
Definition: qsqlresult.cpp:402
void clear()
Removes all the record&#39;s fields.
Definition: qsqlrecord.cpp:367
QSqlRecord recInf
Definition: qsql_db2.cpp:106

◆ record()

QSqlRecord QDB2Result::record ( ) const
protectedvirtual

Returns the current record if the query is active; otherwise returns an empty QSqlRecord.

The default implementation always returns an empty QSqlRecord.

See also
isActive()

Reimplemented from QSqlResult.

Definition at line 1083 of file qsql_db2.cpp.

1084 {
1085  if (isActive())
1086  return d->recInf;
1087  return QSqlRecord();
1088 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
Definition: qsqlresult.cpp:340
The QSqlRecord class encapsulates a database record.
Definition: qsqlrecord.h:58
QSqlRecord recInf
Definition: qsql_db2.cpp:106

◆ reset()

bool QDB2Result::reset ( const QString query)
protectedvirtual

Sets the result to use the SQL statement query for subsequent data retrieval.

Derived classes must reimplement this function and apply the query to the database. This function is only called after the result is set to an inactive state and is positioned before the first record of the new result. Derived classes should return true if the query was successful and ready to be used, or false otherwise.

See also
setQuery()

Implements QSqlResult.

Definition at line 537 of file qsql_db2.cpp.

538 {
539  setActive(false);
541  SQLRETURN r;
542 
543  d->recInf.clear();
544  d->emptyValueCache();
545 
546  if (!qMakeStatement(d, isForwardOnly()))
547  return false;
548 
549  r = SQLExecDirect(d->hStmt,
550  qToTChar(query),
551  (SQLINTEGER) query.length());
552  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
554  "Unable to execute statement"), QSqlError::StatementError, d));
555  return false;
556  }
557  SQLSMALLINT count;
558  r = SQLNumResultCols(d->hStmt, &count);
559  if (count) {
560  setSelect(true);
561  for (int i = 0; i < count; ++i) {
563  }
564  } else {
565  setSelect(false);
566  }
567  d->valueCache.resize(count);
568  d->valueCache.fill(NULL);
569  setActive(true);
570  return true;
571 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false...
Definition: qsqlresult.cpp:582
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static bool qMakeStatement(QDB2ResultPrivate *d, bool forwardOnly, bool setForwardOnly=true)
Definition: qsql_db2.cpp:471
static SQLTCHAR * qToTChar(const QString &str)
Definition: qsql_db2.cpp:117
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
Definition: qsqlresult.cpp:367
void emptyValueCache()
Definition: qsql_db2.cpp:98
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
static QSqlField qMakeFieldInfo(const QDB2ResultPrivate *d, int i)
Definition: qsql_db2.cpp:234
QVector< QVariant * > valueCache
Definition: qsql_db2.cpp:107
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
Definition: qsqlrecord.cpp:312
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
Definition: qsqlresult.cpp:402
void clear()
Removes all the record&#39;s fields.
Definition: qsqlrecord.cpp:367
QSqlRecord recInf
Definition: qsql_db2.cpp:106

◆ size()

int QDB2Result::size ( )
protectedvirtual

Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELECT statement.

See also
numRowsAffected()

Implements QSqlResult.

Definition at line 1078 of file qsql_db2.cpp.

1079 {
1080  return -1;
1081 }

◆ virtual_hook()

void QDB2Result::virtual_hook ( int  id,
void *  data 
)
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QSqlResult.

Definition at line 1120 of file qsql_db2.cpp.

1121 {
1122  switch (id) {
1124  Q_ASSERT(data);
1125  *static_cast<bool*>(data) = nextResult();
1126  break;
1128  if (d->hStmt)
1129  SQLCloseCursor(d->hStmt);
1130  break;
1131  default:
1133  }
1134 }
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QVariant data(int field)
Returns the data for field index in the current row as a QVariant.
Definition: qsql_db2.cpp:951
bool nextResult()
Definition: qsql_db2.cpp:1090
SQLHANDLE hStmt
Definition: qsql_db2.cpp:105
virtual void virtual_hook(int id, void *data)
Definition: qsqlresult.cpp:962

Properties

◆ d

QDB2ResultPrivate* QDB2Result::d
private

The documentation for this class was generated from the following files: