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

Last change on this file since 643 was 561, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 4.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 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#if defined (Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3)
53// assume we use iodbc on MACX
54// comment next line out if you use a
55// unicode compatible manager
56# define Q_ODBC_VERSION_2
57#endif
58
59#ifdef QT_PLUGIN
60#define Q_EXPORT_SQLDRIVER_ODBC
61#else
62#define Q_EXPORT_SQLDRIVER_ODBC Q_SQL_EXPORT
63#endif
64
65#ifdef Q_OS_UNIX
66#define HAVE_LONG_LONG 1 // force UnixODBC NOT to fall back to a struct for BIGINTs
67#endif
68
69#if defined(Q_CC_BOR)
70// workaround for Borland to make sure that SQLBIGINT is defined
71# define _MSC_VER 900
72#endif
73#include <sql.h>
74#if defined(Q_CC_BOR)
75# undef _MSC_VER
76#endif
77
78#ifndef Q_ODBC_VERSION_2
79#include <sqlucode.h>
80#endif
81
82#include <sqlext.h>
83
84QT_BEGIN_HEADER
85
86QT_BEGIN_NAMESPACE
87
88class QODBCPrivate;
89class QODBCDriverPrivate;
90class QODBCDriver;
91class QSqlRecordInfo;
92
93class QODBCResult : public QSqlResult
94{
95public:
96 QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p);
97 virtual ~QODBCResult();
98
99 bool prepare(const QString& query);
100 bool exec();
101
102 QVariant handle() const;
103 virtual void setForwardOnly(bool forward);
104
105protected:
106 bool fetchNext();
107 bool fetchFirst();
108 bool fetchLast();
109 bool fetchPrevious();
110 bool fetch(int i);
111 bool reset (const QString& query);
112 QVariant data(int field);
113 bool isNull(int field);
114 int size();
115 int numRowsAffected();
116 QSqlRecord record() const;
117 void virtual_hook(int id, void *data);
118 bool nextResult();
119
120private:
121 QODBCPrivate *d;
122};
123
124class Q_EXPORT_SQLDRIVER_ODBC QODBCDriver : public QSqlDriver
125{
126 Q_OBJECT
127public:
128 explicit QODBCDriver(QObject *parent=0);
129 QODBCDriver(SQLHANDLE env, SQLHANDLE con, QObject * parent=0);
130 virtual ~QODBCDriver();
131 bool hasFeature(DriverFeature f) const;
132 void close();
133 QSqlResult *createResult() const;
134 QStringList tables(QSql::TableType) const;
135 QSqlRecord record(const QString& tablename) const;
136 QSqlIndex primaryIndex(const QString& tablename) const;
137 QVariant handle() const;
138 QString formatValue(const QSqlField &field,
139 bool trimStrings) const;
140 bool open(const QString& db,
141 const QString& user,
142 const QString& password,
143 const QString& host,
144 int port,
145 const QString& connOpts);
146
147 QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
148
149protected Q_SLOTS:
150 bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
151
152protected:
153 bool beginTransaction();
154 bool commitTransaction();
155 bool rollbackTransaction();
156
157private:
158 void init();
159 bool endTrans();
160 void cleanup();
161 QODBCDriverPrivate* d;
162 friend class QODBCPrivate;
163};
164
165QT_END_NAMESPACE
166
167QT_END_HEADER
168
169#endif // QSQL_ODBC_H
Note: See TracBrowser for help on using the repository browser.