1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtSql module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
45 #include <QtCore/qvariant.h>
46 #include <QtCore/qvector.h>
47 #include <QtSql/qsql.h>
56 template <typename T> class QVector;
60 class QSqlResultPrivate;
62 class Q_SQL_EXPORT QSqlResult
64 friend class QSqlQuery;
65 friend class QSqlTableModelPrivate;
66 friend class QSqlResultPrivate;
69 virtual ~QSqlResult();
70 virtual QVariant handle() const;
78 explicit QSqlResult(const QSqlDriver * db);
80 QString lastQuery() const;
81 QSqlError lastError() const;
83 bool isActive() const;
84 bool isSelect() const;
85 bool isForwardOnly() const;
86 const QSqlDriver* driver() const;
87 virtual void setAt(int at);
88 virtual void setActive(bool a);
89 virtual void setLastError(const QSqlError& e);
90 virtual void setQuery(const QString& query);
91 virtual void setSelect(bool s);
92 virtual void setForwardOnly(bool forward);
94 // prepared query support
96 virtual bool prepare(const QString& query);
97 virtual bool savePrepare(const QString& sqlquery);
98 virtual void bindValue(int pos, const QVariant& val, QSql::ParamType type);
99 virtual void bindValue(const QString& placeholder, const QVariant& val,
100 QSql::ParamType type);
101 void addBindValue(const QVariant& val, QSql::ParamType type);
102 QVariant boundValue(const QString& placeholder) const;
103 QVariant boundValue(int pos) const;
104 QSql::ParamType bindValueType(const QString& placeholder) const;
105 QSql::ParamType bindValueType(int pos) const;
106 int boundValueCount() const;
107 QVector<QVariant>& boundValues() const;
108 QString executedQuery() const;
109 QString boundValueName(int pos) const;
111 bool hasOutValues() const;
113 BindingSyntax bindingSyntax() const;
115 virtual QVariant data(int i) = 0;
116 virtual bool isNull(int i) = 0;
117 virtual bool reset(const QString& sqlquery) = 0;
118 virtual bool fetch(int i) = 0;
119 virtual bool fetchNext();
120 virtual bool fetchPrevious();
121 virtual bool fetchFirst() = 0;
122 virtual bool fetchLast() = 0;
123 virtual int size() = 0;
124 virtual int numRowsAffected() = 0;
125 virtual QSqlRecord record() const;
126 virtual QVariant lastInsertId() const;
128 enum VirtualHookOperation { };
129 virtual void virtual_hook(int id, void *data);
130 virtual bool execBatch(bool arrayBind = false);
131 virtual void detachFromResultSet();
132 virtual void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy);
133 QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
134 virtual bool nextResult();
137 QSqlResultPrivate* d;
138 void resetBindCount(); // HACK
141 Q_DISABLE_COPY(QSqlResult)
148 #endif // QSQLRESULT_H