1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtSql module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
45 #include <QtCore/qvariant.h>
46 #include <QtCore/qvector.h>
47 #include <QtSql/qsql.h>
57 template <typename T
> class QVector
;
61 class QSqlResultPrivate
;
63 class Q_SQL_EXPORT QSqlResult
65 friend class QSqlQuery
;
66 friend class QSqlTableModelPrivate
;
67 friend class QSqlResultPrivate
;
70 virtual ~QSqlResult();
71 virtual QVariant
handle() const;
78 , BindByPosition
= PositionalBinding
,
79 BindByName
= NamedBinding
83 explicit QSqlResult(const QSqlDriver
* db
);
85 QString
lastQuery() const;
86 QSqlError
lastError() const;
88 bool isActive() const;
89 bool isSelect() const;
90 bool isForwardOnly() const;
91 const QSqlDriver
* driver() const;
92 virtual void setAt(int at
);
93 virtual void setActive(bool a
);
94 virtual void setLastError(const QSqlError
& e
);
95 virtual void setQuery(const QString
& query
);
96 virtual void setSelect(bool s
);
97 virtual void setForwardOnly(bool forward
);
99 // prepared query support
101 virtual bool prepare(const QString
& query
);
102 virtual bool savePrepare(const QString
& sqlquery
);
103 virtual void bindValue(int pos
, const QVariant
& val
, QSql::ParamType type
);
104 virtual void bindValue(const QString
& placeholder
, const QVariant
& val
,
105 QSql::ParamType type
);
106 void addBindValue(const QVariant
& val
, QSql::ParamType type
);
107 QVariant
boundValue(const QString
& placeholder
) const;
108 QVariant
boundValue(int pos
) const;
109 QSql::ParamType
bindValueType(const QString
& placeholder
) const;
110 QSql::ParamType
bindValueType(int pos
) const;
111 int boundValueCount() const;
112 QVector
<QVariant
>& boundValues() const;
113 QString
executedQuery() const;
114 QString
boundValueName(int pos
) const;
116 bool hasOutValues() const;
118 BindingSyntax
bindingSyntax() const;
120 virtual QVariant
data(int i
) = 0;
121 virtual bool isNull(int i
) = 0;
122 virtual bool reset(const QString
& sqlquery
) = 0;
123 virtual bool fetch(int i
) = 0;
124 virtual bool fetchNext();
125 virtual bool fetchPrevious();
126 virtual bool fetchFirst() = 0;
127 virtual bool fetchLast() = 0;
128 virtual int size() = 0;
129 virtual int numRowsAffected() = 0;
130 virtual QSqlRecord
record() const;
131 virtual QVariant
lastInsertId() const;
133 enum VirtualHookOperation
{ BatchOperation
, DetachFromResultSet
, SetNumericalPrecision
, NextResult
};
134 virtual void virtual_hook(int id
, void *data
);
135 bool execBatch(bool arrayBind
= false);
136 void detachFromResultSet();
137 void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy
);
138 QSql::NumericalPrecisionPolicy
numericalPrecisionPolicy() const;
142 QSqlResultPrivate
* d
;
143 void resetBindCount(); // HACK
146 Q_DISABLE_COPY(QSqlResult
)
153 #endif // QSQLRESULT_H