- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qsqlresult.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtSql module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QSQLRESULT_H
    00043 #define QSQLRESULT_H
    00044
    00045 #include <QtCore/qvariant.h>
    00046 #include <QtCore/qvector.h>
    00047 #include <QtSql/qsql.h>
    00048
    00049 QT_BEGIN_HEADER
    00050
    00051 QT_BEGIN_NAMESPACE
    00052
    00053 QT_MODULE(Sql)
    00054
    00055 class QString;
    00056 class QSqlRecord;
    00057 template <typename T> class QVector;
    00058 class QVariant;
    00059 class QSqlDriver;
    00060 class QSqlError;
    00061 class QSqlResultPrivate;
    00062
    00063 class Q_SQL_EXPORT QSqlResult
    00064 {
    00065     friend class QSqlQuery;
    00066     friend class QSqlTableModelPrivate;
    00067     friend class QSqlResultPrivate;
    00068
    00069 public:
    00070     virtual ~QSqlResult();
    00071     virtual QVariant handle() const;
    00072
    00073 protected:
    00074     enum BindingSyntax {
    00075         PositionalBinding,
    00076         NamedBinding
    00077 #ifdef QT3_SUPPORT
    00078         , BindByPosition = PositionalBinding,
    00079         BindByName = NamedBinding
    00080 #endif
    00081     };
    00082
    00083     explicit QSqlResult(const QSqlDriver * db);
    00084     int at() const;
    00085     QString lastQuery() const;
    00086     QSqlError lastError() const;
    00087     bool isValid() const;
    00088     bool isActive() const;
    00089     bool isSelect() const;
    00090     bool isForwardOnly() const;
    00091     const QSqlDriver* driver() const;
    00092     virtual void setAt(int at);
    00093     virtual void setActive(bool a);
    00094     virtual void setLastError(const QSqlError& e);
    00095     virtual void setQuery(const QString& query);
    00096     virtual void setSelect(bool s);
    00097     virtual void setForwardOnly(bool forward);
    00098
    00099     // prepared query support
    00100     virtual bool exec();
    00101     virtual bool prepare(const QString& query);
    00102     virtual bool savePrepare(const QString& sqlquery);
    00103     virtual void bindValue(int pos, const QVariant& val, QSql::ParamType type);
    00104     virtual void bindValue(const QString& placeholder, const QVariant& val,
    00105                            QSql::ParamType type);
    00106     void addBindValue(const QVariant& val, QSql::ParamType type);
    00107     QVariant boundValue(const QString& placeholder) const;
    00108     QVariant boundValue(int pos) const;
    00109     QSql::ParamType bindValueType(const QString& placeholder) const;
    00110     QSql::ParamType bindValueType(int pos) const;
    00111     int boundValueCount() const;
    00112     QVector<QVariant>& boundValues() const;
    00113     QString executedQuery() const;
    00114     QString boundValueName(int pos) const;
    00115     void clear();
    00116     bool hasOutValues() const;
    00117
    00118     BindingSyntax bindingSyntax() const;
    00119
    00120     virtual QVariant data(int i) = 0;
    00121     virtual bool isNull(int i) = 0;
    00122     virtual bool reset(const QString& sqlquery) = 0;
    00123     virtual bool fetch(int i) = 0;
    00124     virtual bool fetchNext();
    00125     virtual bool fetchPrevious();
    00126     virtual bool fetchFirst() = 0;
    00127     virtual bool fetchLast() = 0;
    00128     virtual int size() = 0;
    00129     virtual int numRowsAffected() = 0;
    00130     virtual QSqlRecord record() const;
    00131     virtual QVariant lastInsertId() const;
    00132
    00133     enum VirtualHookOperation { BatchOperation, DetachFromResultSet, SetNumericalPrecision, NextResult };
    00134     virtual void virtual_hook(int id, void *data);
    00135     bool execBatch(bool arrayBind = false);
    00136     void detachFromResultSet();
    00137     void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy);
    00138     QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
    00139     bool nextResult();
    00140
    00141 private:
    00142     QSqlResultPrivate* d;
    00143     void resetBindCount(); // HACK
    00144
    00145 private:
    00146     Q_DISABLE_COPY(QSqlResult)
    00147 };
    00148
    00149 QT_END_NAMESPACE
    00150
    00151 QT_END_HEADER
    00152
    00153 #endif // QSQLRESULT_H