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

#include <qsql_oci.h>

Inheritance diagram for QOCIResult:
QSqlCachedResult 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...
 
 QOCIResult (const QOCIDriver *db, const QOCIDriverPrivate *p)
 
 ~QOCIResult ()
 
- Public Functions inherited from QSqlCachedResult
virtual ~QSqlCachedResult ()
 
- Public Functions inherited from QSqlResult
virtual ~QSqlResult ()
 Destroys the object and frees any allocated resources. More...
 

Protected Functions

bool gotoNext (ValueCache &values, int index)
 
QVariant lastInsertId () const
 Returns the object ID of the most recent inserted row if the database supports it. More...
 
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 QSqlCachedResult
ValueCachecache ()
 
void cleanup ()
 
void clearValues ()
 
int colCount () const
 
QVariant data (int i)
 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 fetchPrevious ()
 Positions the result to the previous record (row) in the result. More...
 
void init (int colCount)
 
bool isNull (int i)
 Returns true if the field at position index in the current row is null; otherwise returns false. More...
 
 QSqlCachedResult (const QSqlDriver *db)
 
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...
 
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...
 
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

QOCIResultPrivated
 

Friends

class QOCICols
 
class QOCIDriver
 
struct QOCIResultPrivate
 

Additional Inherited Members

- Public Types inherited from QSqlCachedResult
typedef QVector< QVariantValueCache
 
- 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 67 of file qsql_oci.h.

Constructors and Destructors

◆ QOCIResult()

QOCIResult::QOCIResult ( const QOCIDriver db,
const QOCIDriverPrivate p 
)

Definition at line 1803 of file qsql_oci.cpp.

1804  : QSqlCachedResult(db)
1805 {
1806  d = new QOCIResultPrivate(this, p);
1807 }
friend struct QOCIResultPrivate
Definition: qsql_oci.h:70
QSqlCachedResult(const QSqlDriver *db)
QOCIResultPrivate * d
Definition: qsql_oci.h:89

◆ ~QOCIResult()

QOCIResult::~QOCIResult ( )

Definition at line 1809 of file qsql_oci.cpp.

1810 {
1811  if (d->sql) {
1812  int r = OCIHandleFree(d->sql, OCI_HTYPE_STMT);
1813  if (r != 0)
1814  qWarning("~QOCIResult: unable to free statement handle");
1815  }
1816  delete d;
1817 }
Q_CORE_EXPORT void qWarning(const char *,...)
QOCIResultPrivate * d
Definition: qsql_oci.h:89

Functions

◆ exec()

bool QOCIResult::exec ( )
virtual

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

See also
prepare()

Reimplemented from QSqlResult.

Definition at line 1947 of file qsql_oci.cpp.

Referenced by reset().

1948 {
1949  int r = 0;
1950  ub2 stmtType=0;
1951  ub4 iters;
1952  ub4 mode;
1953  QList<QByteArray> tmpStorage;
1954  IndicatorArray indicators(boundValueCount());
1955  SizeArray tmpSizes(boundValueCount());
1956 
1957  r = OCIAttrGet(d->sql,
1958  OCI_HTYPE_STMT,
1959  &stmtType,
1960  NULL,
1961  OCI_ATTR_STMT_TYPE,
1962  d->err);
1963 
1964  if (r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO) {
1965  qOraWarning("QOCIResult::exec: Unable to get statement type:", d->err);
1967  "Unable to get statement type"), QSqlError::StatementError, d->err));
1968 #ifdef QOCI_DEBUG
1969  qDebug() << "lastQuery()" << lastQuery();
1970 #endif
1971  return false;
1972  }
1973 
1974  if (stmtType == OCI_STMT_SELECT) {
1975  iters = 0;
1976  mode = OCI_DEFAULT;
1977  } else {
1978  iters = 1;
1979  mode = d->transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS;
1980  }
1981 
1982  // bind placeholders
1983  if (boundValueCount() > 0
1984  && d->bindValues(boundValues(), indicators, tmpSizes, tmpStorage) != OCI_SUCCESS) {
1985  qOraWarning("QOCIResult::exec: unable to bind value: ", d->err);
1986  setLastError(qMakeError(QCoreApplication::translate("QOCIResult", "Unable to bind value"),
1988 #ifdef QOCI_DEBUG
1989  qDebug() << "lastQuery()" << lastQuery();
1990 #endif
1991  return false;
1992  }
1993 
1994  // execute
1995  r = OCIStmtExecute(d->svc,
1996  d->sql,
1997  d->err,
1998  iters,
1999  0,
2000  0,
2001  0,
2002  mode);
2003  if (r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO) {
2004  qOraWarning("QOCIResult::exec: unable to execute statement:", d->err);
2006  "Unable to execute statement"), QSqlError::StatementError, d->err));
2007 #ifdef QOCI_DEBUG
2008  qDebug() << "lastQuery()" << lastQuery();
2009 #endif
2010  return false;
2011  }
2012 
2013  if (stmtType == OCI_STMT_SELECT) {
2014  ub4 parmCount = 0;
2015  int r = OCIAttrGet(d->sql, OCI_HTYPE_STMT, reinterpret_cast<void **>(&parmCount),
2016  0, OCI_ATTR_PARAM_COUNT, d->err);
2017  if (r == 0 && !d->cols)
2018  d->cols = new QOCICols(parmCount, d);
2019  setSelect(true);
2020  QSqlCachedResult::init(parmCount);
2021  } else { /* non-SELECT */
2022  setSelect(false);
2023  }
2025  setActive(true);
2026 
2027  if (hasOutValues())
2028  d->outValues(boundValues(), indicators, tmpStorage);
2029 
2030  return true;
2031 }
QOCICols * cols
Definition: qsql_oci.cpp:169
QString lastQuery() const
Returns the current SQL query text, or an empty string if there isn&#39;t one.
Definition: qsqlresult.cpp:294
friend class QOCICols
Definition: qsql_oci.h:71
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
Q_CORE_EXPORT void qDebug(const char *,...)
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
OCISvcCtx *& svc
Definition: qsql_oci.cpp:173
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
int boundValueCount() const
Returns the number of bound values in the result.
Definition: qsqlresult.cpp:848
OCIError * err
Definition: qsql_oci.cpp:172
void outValues(QVector< QVariant > &values, IndicatorArray &indicators, QList< QByteArray > &tmpStorage)
Definition: qsql_oci.cpp:446
int bindValues(QVector< QVariant > &values, IndicatorArray &indicators, SizeArray &tmpSizes, QList< QByteArray > &tmpStorage)
Definition: qsql_oci.cpp:400
QOCIResultPrivate * d
Definition: qsql_oci.h:89
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 init(int colCount)
QVector< QVariant > & boundValues() const
Returns a vector of the result&#39;s bound values for the current record (row).
Definition: qsqlresult.cpp:859
static QSqlError qMakeError(const QString &errString, QSqlError::ErrorType type, OCIError *err)
Definition: qsql_oci.cpp:554
static void qOraWarning(const char *msg, OCIError *err)
Definition: qsql_oci.cpp:531

◆ gotoNext()

bool QOCIResult::gotoNext ( QSqlCachedResult::ValueCache values,
int  index 
)
protectedvirtual

Implements QSqlCachedResult.

Definition at line 1831 of file qsql_oci.cpp.

1832 {
1833  if (at() == QSql::AfterLastRow)
1834  return false;
1835 
1836  bool piecewise = false;
1837  int r = OCI_SUCCESS;
1838  r = OCIStmtFetch(d->sql, d->err, 1, OCI_FETCH_NEXT, OCI_DEFAULT);
1839 
1840  if (index < 0) //not interested in values
1841  return r == OCI_SUCCESS || r == OCI_SUCCESS_WITH_INFO;
1842 
1843  switch (r) {
1844  case OCI_SUCCESS:
1845  break;
1846  case OCI_SUCCESS_WITH_INFO:
1847  qOraWarning("QOCIResult::gotoNext: SuccessWithInfo: ", d->err);
1848  r = OCI_SUCCESS; //ignore it
1849  break;
1850  case OCI_NO_DATA:
1851  // end of rowset
1852  return false;
1853  case OCI_NEED_DATA:
1854  piecewise = true;
1855  r = OCI_SUCCESS;
1856  break;
1857  case OCI_ERROR:
1858  if (qOraErrorNumber(d->err) == 1406) {
1859  qWarning("QOCI Warning: data truncated for %s", lastQuery().toLocal8Bit().constData());
1860  r = OCI_SUCCESS; /* ignore it */
1861  break;
1862  }
1863  // fall through
1864  default:
1865  qOraWarning("QOCIResult::gotoNext: ", d->err);
1867  "Unable to goto next"),
1869  break;
1870  }
1871 
1872  // need to read piecewise before assigning values
1873  if (r == OCI_SUCCESS && piecewise)
1874  r = d->cols->readPiecewise(values, index);
1875 
1876  if (r == OCI_SUCCESS)
1877  d->cols->getValues(values, index);
1878  if (r == OCI_SUCCESS)
1879  r = d->cols->readLOBs(values, index);
1880  if (r != OCI_SUCCESS)
1882  return r == OCI_SUCCESS || r == OCI_SUCCESS_WITH_INFO;
1883 }
int at() const
Returns the current (zero-based) row position of the result.
Definition: qsqlresult.cpp:306
QOCICols * cols
Definition: qsql_oci.cpp:169
QString lastQuery() const
Returns the current SQL query text, or an empty string if there isn&#39;t one.
Definition: qsqlresult.cpp:294
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
int readLOBs(QVector< QVariant > &values, int index=0)
Definition: qsql_oci.cpp:1679
Q_CORE_EXPORT void qWarning(const char *,...)
int readPiecewise(QVector< QVariant > &values, int index=0)
Definition: qsql_oci.cpp:1055
OCIError * err
Definition: qsql_oci.cpp:172
static int qOraErrorNumber(OCIError *err)
Definition: qsql_oci.cpp:541
void getValues(QVector< QVariant > &v, int index)
Definition: qsql_oci.cpp:1718
QOCIResultPrivate * d
Definition: qsql_oci.h:89
quint16 index
static QSqlError qMakeError(const QString &errString, QSqlError::ErrorType type, OCIError *err)
Definition: qsql_oci.cpp:554
static void qOraWarning(const char *msg, OCIError *err)
Definition: qsql_oci.cpp:531

◆ handle()

QVariant QOCIResult::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 1819 of file qsql_oci.cpp.

1820 {
1821  return QVariant::fromValue(d->sql);
1822 }
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
QOCIResultPrivate * d
Definition: qsql_oci.h:89

◆ lastInsertId()

QVariant QOCIResult::lastInsertId ( ) const
protectedvirtual

Returns the object ID of the most recent inserted row if the database supports it.

An invalid QVariant will be returned if the query did not insert any value or if the database does not report the id back. If more than one row was touched by the insert, the behavior is undefined.

Note that for Oracle databases the row's ROWID will be returned, while for MySQL databases the row's auto-increment field will be returned.

See also
QSqlDriver::hasFeature()

Reimplemented from QSqlResult.

Definition at line 2041 of file qsql_oci.cpp.

2042 {
2043  if (isActive()) {
2045 
2046  int r = OCIAttrGet(d->sql, OCI_HTYPE_STMT, ptr.constData()->id,
2047  0, OCI_ATTR_ROWID, d->err);
2048  if (r == OCI_SUCCESS)
2049  return QVariant::fromValue(ptr);
2050  }
2051  return QVariant();
2052 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
Definition: qsqlresult.cpp:340
const T * ptr(const T &t)
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
OCIError * err
Definition: qsql_oci.cpp:172
QOCIResultPrivate * d
Definition: qsql_oci.h:89
The QSharedDataPointer class represents a pointer to an implicitly shared object. ...
Definition: qshareddata.h:54

◆ numRowsAffected()

int QOCIResult::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 1890 of file qsql_oci.cpp.

1891 {
1892  int rowCount;
1893  OCIAttrGet(d->sql,
1894  OCI_HTYPE_STMT,
1895  &rowCount,
1896  NULL,
1897  OCI_ATTR_ROW_COUNT,
1898  d->err);
1899  return rowCount;
1900 }
OCIError * err
Definition: qsql_oci.cpp:172
QOCIResultPrivate * d
Definition: qsql_oci.h:89

◆ prepare()

bool QOCIResult::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 1902 of file qsql_oci.cpp.

Referenced by reset().

1903 {
1904  int r = 0;
1905  QSqlResult::prepare(query);
1906 
1907  delete d->cols;
1908  d->cols = 0;
1910 
1911  if (d->sql) {
1912  r = OCIHandleFree(d->sql, OCI_HTYPE_STMT);
1913  if (r != OCI_SUCCESS)
1914  qOraWarning("QOCIResult::prepare: unable to free statement handle:", d->err);
1915  }
1916  if (query.isEmpty())
1917  return false;
1918  r = OCIHandleAlloc(d->env,
1919  reinterpret_cast<void **>(&d->sql),
1920  OCI_HTYPE_STMT,
1921  0,
1922  0);
1923  if (r != OCI_SUCCESS) {
1924  qOraWarning("QOCIResult::prepare: unable to alloc statement:", d->err);
1926  "Unable to alloc statement"), QSqlError::StatementError, d->err));
1927  return false;
1928  }
1930  const OraText *txt = reinterpret_cast<const OraText *>(query.utf16());
1931  const int len = query.length() * sizeof(QChar);
1932  r = OCIStmtPrepare(d->sql,
1933  d->err,
1934  txt,
1935  len,
1936  OCI_NTV_SYNTAX,
1937  OCI_DEFAULT);
1938  if (r != OCI_SUCCESS) {
1939  qOraWarning("QOCIResult::prepare: unable to prepare statement:", d->err);
1941  "Unable to prepare statement"), QSqlError::StatementError, d->err));
1942  return false;
1943  }
1944  return true;
1945 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QOCICols * cols
Definition: qsql_oci.cpp:169
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
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
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
virtual bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
Definition: qsqlresult.cpp:641
OCIError * err
Definition: qsql_oci.cpp:172
QOCIResultPrivate * d
Definition: qsql_oci.h:89
void setStatementAttributes()
Definition: qsql_oci.cpp:227
static QSqlError qMakeError(const QString &errString, QSqlError::ErrorType type, OCIError *err)
Definition: qsql_oci.cpp:554
static void qOraWarning(const char *msg, OCIError *err)
Definition: qsql_oci.cpp:531
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290

◆ record()

QSqlRecord QOCIResult::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 2033 of file qsql_oci.cpp.

2034 {
2035  QSqlRecord inf;
2036  if (!isActive() || !isSelect() || !d->cols)
2037  return inf;
2038  return d->cols->rec;
2039 }
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
QOCICols * cols
Definition: qsql_oci.cpp:169
QSqlRecord rec
Definition: qsql_oci.cpp:801
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
Definition: qsqlresult.cpp:379
QOCIResultPrivate * d
Definition: qsql_oci.h:89

◆ reset()

bool QOCIResult::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 1824 of file qsql_oci.cpp.

1825 {
1826  if (!prepare(query))
1827  return false;
1828  return exec();
1829 }
bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
Definition: qsql_oci.cpp:1902
bool exec()
Executes the query, returning true if successful; otherwise returns false.
Definition: qsql_oci.cpp:1947

◆ size()

int QOCIResult::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 1885 of file qsql_oci.cpp.

1886 {
1887  return -1;
1888 }

◆ virtual_hook()

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

Reimplemented from QSqlResult.

Definition at line 2054 of file qsql_oci.cpp.

2055 {
2056  Q_ASSERT(data);
2057 
2058  switch (id) {
2060  QOCICols::execBatch(d, boundValues(), *reinterpret_cast<bool *>(data));
2061  break;
2062  default:
2064  }
2065 }
QVariant data(int i)
Returns the data for field index in the current row as a QVariant.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static bool execBatch(QOCIResultPrivate *d, QVector< QVariant > &boundValues, bool arrayBind)
Definition: qsql_oci.cpp:1283
QOCIResultPrivate * d
Definition: qsql_oci.h:89
QVector< QVariant > & boundValues() const
Returns a vector of the result&#39;s bound values for the current record (row).
Definition: qsqlresult.cpp:859
void virtual_hook(int id, void *data)

Friends and Related Functions

◆ QOCICols

friend class QOCICols
friend

Definition at line 71 of file qsql_oci.h.

Referenced by exec().

◆ QOCIDriver

friend class QOCIDriver
friend

Definition at line 69 of file qsql_oci.h.

◆ QOCIResultPrivate

friend struct QOCIResultPrivate
friend

Definition at line 70 of file qsql_oci.h.

Referenced by QOCIResult().

Properties

◆ d

QOCIResultPrivate* QOCIResult::d
private

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