Qt 4.8
qsql_oci.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSql module of the Qt Toolkit.
7 **
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.
16 **
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.
24 **
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.
28 **
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.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QSQL_OCI_H
43 #define QSQL_OCI_H
44 
45 #include <QtSql/qsqlresult.h>
46 #include <QtSql/qsqldriver.h>
47 #include <QtSql/private/qsqlcachedresult_p.h>
48 
49 #ifdef QT_PLUGIN
50 #define Q_EXPORT_SQLDRIVER_OCI
51 #else
52 #define Q_EXPORT_SQLDRIVER_OCI Q_SQL_EXPORT
53 #endif
54 
56 
57 typedef struct OCIEnv OCIEnv;
58 typedef struct OCISvcCtx OCISvcCtx;
59 
61 
62 class QOCIDriver;
63 class QOCICols;
64 struct QOCIDriverPrivate;
65 struct QOCIResultPrivate;
66 
68 {
69  friend class QOCIDriver;
70  friend struct QOCIResultPrivate;
71  friend class QOCICols;
72 public:
73  QOCIResult(const QOCIDriver * db, const QOCIDriverPrivate* p);
74  ~QOCIResult();
75  bool prepare(const QString& query);
76  bool exec();
77  QVariant handle() const;
78 
79 protected:
80  bool gotoNext(ValueCache &values, int index);
81  bool reset (const QString& query);
82  int size();
83  int numRowsAffected();
84  QSqlRecord record() const;
85  QVariant lastInsertId() const;
86  void virtual_hook(int id, void *data);
87 
88 private:
90 };
91 
93 {
94  Q_OBJECT
95  friend struct QOCIResultPrivate;
96  friend class QOCIPrivate;
97 public:
98  explicit QOCIDriver(QObject* parent = 0);
99  QOCIDriver(OCIEnv* env, OCISvcCtx* ctx, QObject* parent = 0);
100  ~QOCIDriver();
101  bool hasFeature(DriverFeature f) const;
102  bool open(const QString & db,
103  const QString & user,
104  const QString & password,
105  const QString & host,
106  int port,
107  const QString& connOpts);
108  void close();
109  QSqlResult *createResult() const;
111  QSqlRecord record(const QString& tablename) const;
112  QSqlIndex primaryIndex(const QString& tablename) const;
113  QString formatValue(const QSqlField &field,
114  bool trimStrings) const;
115  QVariant handle() const;
116  QString escapeIdentifier(const QString &identifier, IdentifierType) const;
117 
118 protected:
119  bool beginTransaction();
120  bool commitTransaction();
121  bool rollbackTransaction();
122 private:
124 };
125 
127 
129 
130 #endif // QSQL_OCI_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QSqlIndex class provides functions to manipulate and describe database indexes.
Definition: qsqlindex.h:55
virtual bool rollbackTransaction()
This function is called to rollback a transaction.
Definition: qsqldriver.cpp:338
virtual void close()=0
Derived classes must reimplement this pure virtual function in order to close the database connection...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual QSqlIndex primaryIndex(const QString &tableName) const
Returns the primary index for table tableName.
Definition: qsqldriver.cpp:387
DriverFeature
This enum contains a list of features a driver might support.
Definition: qsqldriver.h:75
virtual QStringList tables(QSql::TableType tableType) const
Returns a list of the names of the tables in the database.
Definition: qsqldriver.cpp:376
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
virtual bool hasFeature(DriverFeature f) const =0
Returns true if the driver supports feature feature; otherwise returns false.
struct OCIEnv OCIEnv
Definition: qsql_oci.h:57
virtual QString escapeIdentifier(const QString &identifier, IdentifierType type) const
Returns the identifier escaped according to the database rules.
Definition: qsqldriver.cpp:412
#define Q_EXPORT_SQLDRIVER_OCI
Definition: qsql_oci.h:52
virtual QSqlRecord record(const QString &tableName) const
Returns a QSqlRecord populated with the names of the fields in table tableName.
Definition: qsqldriver.cpp:399
The QSqlRecord class encapsulates a database record.
Definition: qsqlrecord.h:58
virtual QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
Definition: qsqlresult.cpp:936
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
Definition: qsqldriver.h:68
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual bool open(const QString &db, const QString &user=QString(), const QString &password=QString(), const QString &host=QString(), int port=-1, const QString &connOpts=QString())=0
Derived classes must reimplement this pure virtual function to open a database connection on database...
virtual QVariant lastInsertId() const
Returns the object ID of the most recent inserted row if the database supports it.
Definition: qsqlresult.cpp:955
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual bool commitTransaction()
This function is called to commit a transaction.
Definition: qsqldriver.cpp:325
virtual QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static const char * data(const QByteArray &arr)
TableType
Definition: qsql.h:74
virtual int numRowsAffected()=0
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
quint16 values[128]
virtual bool exec()
Executes the query, returning true if successful; otherwise returns false.
Definition: qsqlresult.cpp:675
virtual bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
Definition: qsqlresult.cpp:641
QOCIDriverPrivate * d
Definition: qsql_oci.h:123
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual bool reset(const QString &sqlquery)=0
Sets the result to use the SQL statement query for subsequent data retrieval.
virtual QSqlResult * createResult() const =0
Creates an empty SQL result on the database.
virtual bool beginTransaction()
This function is called to begin a transaction.
Definition: qsqldriver.cpp:312
#define ctx
Definition: qgl.cpp:6094
virtual QString formatValue(const QSqlField &field, bool trimStrings=false) const
Returns a string representation of the field value for the database.
Definition: qsqldriver.cpp:597
virtual bool gotoNext(ValueCache &values, int index)=0
QOCIResultPrivate * d
Definition: qsql_oci.h:89
quint16 index
virtual QVariant handle() const
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
Definition: qsqldriver.cpp:700
The QSqlField class manipulates the fields in SQL database tables and views.
Definition: qsqlfield.h:56
virtual int size()=0
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
struct OCISvcCtx OCISvcCtx
Definition: qsql_oci.h:58
#define QT_END_HEADER
Definition: qglobal.h:137
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases...
Definition: qsqlresult.h:63
void virtual_hook(int id, void *data)
IdentifierType
This enum contains a list of SQL identifier types.
Definition: qsqldriver.h:83