source: trunk/src/sql/drivers/odbc/qsql_odbc.h@ 1036

Last change on this file since 1036 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 4.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtSql module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
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.
23**
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.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QSQL_ODBC_H
43#define QSQL_ODBC_H
44
45#include <QtSql/qsqldriver.h>
46#include <QtSql/qsqlresult.h>
47
48#if defined (Q_OS_WIN32)
49#include <QtCore/qt_windows.h>
50#endif
51
52#ifdef QT_PLUGIN
53#define Q_EXPORT_SQLDRIVER_ODBC
54#else
55#define Q_EXPORT_SQLDRIVER_ODBC Q_SQL_EXPORT
56#endif
57
58#ifdef Q_OS_UNIX
59#define HAVE_LONG_LONG 1 // force UnixODBC NOT to fall back to a struct for BIGINTs
60#endif
61
62#if defined(Q_CC_BOR)
63// workaround for Borland to make sure that SQLBIGINT is defined
64# define _MSC_VER 900
65#endif
66#include <sql.h>
67#if defined(Q_CC_BOR)
68# undef _MSC_VER
69#endif
70
71#include <sqlext.h>
72
73QT_BEGIN_HEADER
74
75QT_BEGIN_NAMESPACE
76
77class QODBCPrivate;
78class QODBCDriverPrivate;
79class QODBCDriver;
80class QSqlRecordInfo;
81
82class QODBCResult : public QSqlResult
83{
84public:
85 QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p);
86 virtual ~QODBCResult();
87
88 bool prepare(const QString& query);
89 bool exec();
90
91 QVariant handle() const;
92 virtual void setForwardOnly(bool forward);
93
94protected:
95 bool fetchNext();
96 bool fetchFirst();
97 bool fetchLast();
98 bool fetchPrevious();
99 bool fetch(int i);
100 bool reset (const QString& query);
101 QVariant data(int field);
102 bool isNull(int field);
103 int size();
104 int numRowsAffected();
105 QSqlRecord record() const;
106 void virtual_hook(int id, void *data);
107 bool nextResult();
108
109private:
110 QODBCPrivate *d;
111};
112
113class Q_EXPORT_SQLDRIVER_ODBC QODBCDriver : public QSqlDriver
114{
115 Q_OBJECT
116public:
117 explicit QODBCDriver(QObject *parent=0);
118 QODBCDriver(SQLHANDLE env, SQLHANDLE con, QObject * parent=0);
119 virtual ~QODBCDriver();
120 bool hasFeature(DriverFeature f) const;
121 void close();
122 QSqlResult *createResult() const;
123 QStringList tables(QSql::TableType) const;
124 QSqlRecord record(const QString& tablename) const;
125 QSqlIndex primaryIndex(const QString& tablename) const;
126 QVariant handle() const;
127 QString formatValue(const QSqlField &field,
128 bool trimStrings) const;
129 bool open(const QString& db,
130 const QString& user,
131 const QString& password,
132 const QString& host,
133 int port,
134 const QString& connOpts);
135
136 QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
137
138protected Q_SLOTS:
139 bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
140
141protected:
142 bool beginTransaction();
143 bool commitTransaction();
144 bool rollbackTransaction();
145
146private:
147 void init();
148 bool endTrans();
149 void cleanup();
150 QODBCDriverPrivate* d;
151 friend class QODBCPrivate;
152};
153
154QT_END_NAMESPACE
155
156QT_END_HEADER
157
158#endif // QSQL_ODBC_H
Note: See TracBrowser for help on using the repository browser.