Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsqlrecord.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QSQLRECORD_H
6#define QSQLRECORD_H
7
8#include <QtSql/qtsqlglobal.h>
9#include <QtCore/qshareddata.h>
10#include <QtCore/qstring.h>
11
12QT_BEGIN_NAMESPACE
13
14
15class QSqlField;
16class QVariant;
18QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QSqlRecordPrivate, Q_SQL_EXPORT)
19
20class Q_SQL_EXPORT QSqlRecord
21{
22public:
23 QSqlRecord();
24 QSqlRecord(const QSqlRecord &other);
25 QSqlRecord(QSqlRecord &&other) noexcept = default;
26 QSqlRecord& operator=(const QSqlRecord &other);
27 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QSqlRecord)
28 ~QSqlRecord();
29
30 void swap(QSqlRecord &other) noexcept { d.swap(other.d); }
31
32 bool operator==(const QSqlRecord &other) const;
33 inline bool operator!=(const QSqlRecord &other) const { return !operator==(other); }
34
35 QVariant value(int i) const;
36#if QT_SQL_REMOVED_SINCE(6, 8)
37 QVariant value(const QString &name) const;
38#endif
39 QVariant value(QAnyStringView name) const;
40 void setValue(int i, const QVariant &val);
41#if QT_SQL_REMOVED_SINCE(6, 8)
42 void setValue(const QString &name, const QVariant &val);
43#endif
44 void setValue(QAnyStringView name, const QVariant &val);
45
46 void setNull(int i);
47#if QT_SQL_REMOVED_SINCE(6, 8)
48 void setNull(const QString &name);
49#endif
50 void setNull(QAnyStringView name);
51 bool isNull(int i) const;
52#if QT_SQL_REMOVED_SINCE(6, 8)
53 bool isNull(const QString &name) const;
54#endif
55 bool isNull(QAnyStringView name) const;
56
57#if QT_SQL_REMOVED_SINCE(6, 8)
58 int indexOf(const QString &name) const;
59#endif
60 int indexOf(QAnyStringView name) const;
61 QString fieldName(int i) const;
62
63 QSqlField field(int i) const;
64#if QT_SQL_REMOVED_SINCE(6, 8)
65 QSqlField field(const QString &name) const;
66#endif
67 QSqlField field(QAnyStringView name) const;
68
69 bool isGenerated(int i) const;
70#if QT_SQL_REMOVED_SINCE(6, 8)
71 bool isGenerated(const QString &name) const;
72#endif
73 bool isGenerated(QAnyStringView name) const;
74#if QT_SQL_REMOVED_SINCE(6, 8)
75 void setGenerated(const QString &name, bool generated);
76#endif
77 void setGenerated(QAnyStringView name, bool generated);
78 void setGenerated(int i, bool generated);
79
80 void append(const QSqlField &field);
81 void replace(int pos, const QSqlField &field);
82 void insert(int pos, const QSqlField &field);
83 void remove(int pos);
84
85 bool isEmpty() const;
86#if QT_SQL_REMOVED_SINCE(6, 8)
87 bool contains(const QString &name) const;
88#endif
89 bool contains(QAnyStringView name) const;
90 void clear();
91 void clearValues();
92 int count() const;
93 QSqlRecord keyValues(const QSqlRecord &keyFields) const;
94
95private:
96 void detach();
97 QExplicitlySharedDataPointer<QSqlRecordPrivate> d;
98};
99
101
102#ifndef QT_NO_DEBUG_STREAM
103Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlRecord &);
104#endif
105
106QT_END_NAMESPACE
107
108#endif // QSQLRECORD_H
void qSplitTableQualifier(const QString &qualifier, QString &catalog, QString &schema, QString &table) const
Definition qsql_db2.cpp:443
QList< QVariant * > valueCache
Definition qsql_db2.cpp:115
QSqlRecord recInf
Definition qsql_db2.cpp:114
bool fetchLast() override
Positions the result to the last record (last row) in the result.
Definition qsql_db2.cpp:940
QVariant handle() const override
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
Definition qsql_db2.cpp:528
void detachFromResultSet() override
void virtual_hook(int id, void *data) override
int numRowsAffected() override
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
bool fetch(int i) override
Positions the result to an arbitrary (zero-based) row index.
Definition qsql_db2.cpp:865
bool isNull(int i) override
Returns true if the field at position index in the current row is null; otherwise returns false.
bool exec() override
Executes the query, returning true if successful; otherwise returns false.
Definition qsql_db2.cpp:613
bool fetchFirst() override
Positions the result to the first record (row 0) in the result.
Definition qsql_db2.cpp:918
int size() override
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
bool prepare(const QString &query) override
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
Definition qsql_db2.cpp:588
QSqlRecord record() const override
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
bool fetchNext() override
Positions the result to the next available record (row) in the result.
Definition qsql_db2.cpp:900
bool reset(const QString &query) override
Sets the result to use the SQL statement query for subsequent data retrieval.
Definition qsql_db2.cpp:551
bool nextResult() override
QVariant data(int field) override
Returns the data for field index in the current row as a QVariant.
Definition qsql_db2.cpp:972
\inmodule QtCore \reentrant
Definition qdatetime.h:29
Definition qlist.h:80
The QSqlError class provides SQL database error information.
Definition qsqlerror.h:18
The QSqlField class manipulates the fields in SQL database tables and views.
Definition qsqlfield.h:20
The QSqlIndex class provides functions to manipulate and describe database indexes.
Definition qsqlindex.h:19
The QSqlRecord class encapsulates a database record.
Definition qsqlrecord.h:21
\inmodule QtCore \reentrant
Definition qdatetime.h:250
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568
static QSqlField qMakeFieldInfo(const QDB2ResultPrivate *d, int i)
Definition qsql_db2.cpp:252
static QSqlField qMakeFieldInfo(const SQLHANDLE hStmt)
Definition qsql_db2.cpp:469
static bool qMakeStatement(QDB2ResultPrivate *d, bool forwardOnly, bool setForwardOnly=true)
Definition qsql_db2.cpp:486
static QByteArray qGetBinaryData(SQLHANDLE hStmt, int column, SQLLEN &lengthIndicator, bool &isNull)
Definition qsql_db2.cpp:387
static void qSqlWarning(const QString &message, const T *d)
Definition qsql_db2.cpp:182
static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool &isNull)
Definition qsql_db2.cpp:347
static SQLBIGINT qGetBigIntData(SQLHANDLE hStmt, int column, bool &isNull)
Definition qsql_db2.cpp:330
static int qGetIntData(SQLHANDLE hStmt, int column, bool &isNull)
Definition qsql_db2.cpp:293
static SQLTCHAR * qToTChar(const QString &str)
Definition qsql_db2.cpp:125
static const SQLSMALLINT TABLENAMESIZE
Definition qsql_db2.cpp:40
static const SQLSMALLINT qParamType[4]
Definition qsql_db2.cpp:41
static QString qFromTChar(SQLTCHAR *str)
Definition qsql_db2.cpp:118
static const int COLNAMESIZE
Definition qsql_db2.cpp:36
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const T *p)
Definition qsql_db2.cpp:189
static QMetaType qDecodeDB2Type(SQLSMALLINT sqltype)
Definition qsql_db2.cpp:197
static QString qDB2Warn(const QDB2DriverPrivate *d, QStringList *errorCodes=nullptr)
Definition qsql_db2.cpp:153
static QString qWarnDB2Handle(int handleType, SQLHANDLE handle, int *errorCode)
Definition qsql_db2.cpp:130
static QString qDB2Warn(const QDB2ResultPrivate *d, QStringList *errorCodes=nullptr)
Definition qsql_db2.cpp:169
static double qGetDoubleData(SQLHANDLE hStmt, int column, bool &isNull)
Definition qsql_db2.cpp:311