#include "qsql_db2.h"
#include <qcoreapplication.h>
#include <qdatetime.h>
#include <qsqlfield.h>
#include <qsqlerror.h>
#include <qsqlindex.h>
#include <qsqlrecord.h>
#include <qstringlist.h>
#include <qvarlengtharray.h>
#include <qvector.h>
#include <QDebug>
#include <sqlcli1.h>
#include <string.h>
Go to the source code of this file.
|
static QString | qDB2Warn (const QDB2DriverPrivate *d) |
|
static QString | qDB2Warn (const QDB2ResultPrivate *d) |
|
static QVariant::Type | qDecodeDB2Type (SQLSMALLINT sqltype) |
|
static QString | qFromTChar (SQLTCHAR *str) |
|
static SQLBIGINT | qGetBigIntData (SQLHANDLE hStmt, int column, bool &isNull) |
|
static QByteArray | qGetBinaryData (SQLHANDLE hStmt, int column, SQLINTEGER &lengthIndicator, bool &isNull) |
|
static double | qGetDoubleData (SQLHANDLE hStmt, int column, bool &isNull) |
|
static int | qGetIntData (SQLHANDLE hStmt, int column, bool &isNull) |
|
static QString | qGetStringData (SQLHANDLE hStmt, int column, int colSize, bool &isNull) |
|
static QSqlError | qMakeError (const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p) |
|
static QSqlError | qMakeError (const QString &err, QSqlError::ErrorType type, const QDB2ResultPrivate *p) |
|
static QSqlField | qMakeFieldInfo (const QDB2ResultPrivate *d, int i) |
|
static QSqlField | qMakeFieldInfo (const SQLHANDLE hStmt) |
|
static bool | qMakeStatement (QDB2ResultPrivate *d, bool forwardOnly, bool setForwardOnly=true) |
|
static void | qSplitTableQualifier (const QString &qualifier, QString *catalog, QString *schema, QString *table) |
|
static void | qSqlWarning (const QString &message, const QDB2DriverPrivate *d) |
|
static void | qSqlWarning (const QString &message, const QDB2ResultPrivate *d) |
|
static SQLTCHAR * | qToTChar (const QString &str) |
|
static QString | qWarnDB2Handle (int handleType, SQLHANDLE handle) |
|
|
static const int | COLNAMESIZE = 255 |
|
static const SQLSMALLINT | qParamType [4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT } |
|
◆ UNICODE
◆ qDB2Warn() [1/2]
◆ qDB2Warn() [2/2]
Definition at line 148 of file qsql_db2.cpp.
static QString qWarnDB2Handle(int handleType, SQLHANDLE handle)
const QDB2DriverPrivate * dp
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
◆ qDecodeDB2Type()
Definition at line 179 of file qsql_db2.cpp.
Referenced by qMakeFieldInfo().
202 case SQL_LONGVARBINARY:
216 case SQL_TYPE_TIMESTAMP:
221 case SQL_WLONGVARCHAR:
224 case SQL_LONGVARCHAR:
Type
This enum type defines the types of variable that a QVariant can contain.
◆ qFromTChar()
static QString qFromTChar |
( |
SQLTCHAR * |
str | ) |
|
|
static |
◆ qGetBigIntData()
static SQLBIGINT qGetBigIntData |
( |
SQLHANDLE |
hStmt, |
|
|
int |
column, |
|
|
bool & |
isNull |
|
) |
| |
|
static |
Definition at line 307 of file qsql_db2.cpp.
Referenced by QDB2Result::data().
311 SQLINTEGER lengthIndicator = 0;
312 SQLRETURN r = SQLGetData(hStmt,
315 (SQLPOINTER) &lngbuf,
318 if ((r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) || lengthIndicator == SQL_NULL_DATA)
static bool isNull(const QVariant::Private *d)
◆ qGetBinaryData()
static QByteArray qGetBinaryData |
( |
SQLHANDLE |
hStmt, |
|
|
int |
column, |
|
|
SQLINTEGER & |
lengthIndicator, |
|
|
bool & |
isNull |
|
) |
| |
|
static |
Definition at line 364 of file qsql_db2.cpp.
Referenced by QDB2Result::data().
367 SQLSMALLINT colNameLen;
370 SQLSMALLINT colScale;
371 SQLSMALLINT nullable;
372 SQLRETURN r = SQL_ERROR;
375 r = SQLDescribeCol(hStmt,
384 if (r != SQL_SUCCESS)
385 qWarning(
"qGetBinaryData: Unable to describe column %d", column);
389 else if (colSize > 65536)
391 char * buf =
new char[colSize];
393 r = SQLGetData(hStmt,
395 colType == SQL_DBCLOB ? SQL_C_CHAR : SQL_C_BINARY,
399 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
400 if (lengthIndicator == SQL_NULL_DATA) {
405 r == SQL_SUCCESS ? rSize = lengthIndicator : rSize = colSize;
406 if (lengthIndicator == SQL_NO_TOTAL)
409 if (r == SQL_SUCCESS)
QByteArray & append(char c)
Appends the character ch to this byte array.
The QByteArray class provides an array of bytes.
Q_CORE_EXPORT void qWarning(const char *,...)
static const int COLNAMESIZE
static bool isNull(const QVariant::Private *d)
◆ qGetDoubleData()
static double qGetDoubleData |
( |
SQLHANDLE |
hStmt, |
|
|
int |
column, |
|
|
bool & |
isNull |
|
) |
| |
|
static |
Definition at line 288 of file qsql_db2.cpp.
Referenced by QDB2Result::data().
292 SQLINTEGER lengthIndicator = 0;
293 SQLRETURN r = SQLGetData(hStmt,
296 (SQLPOINTER) &dblbuf,
299 if ((r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) || lengthIndicator == SQL_NULL_DATA) {
304 return (
double) dblbuf;
static bool isNull(const QVariant::Private *d)
◆ qGetIntData()
static int qGetIntData |
( |
SQLHANDLE |
hStmt, |
|
|
int |
column, |
|
|
bool & |
isNull |
|
) |
| |
|
static |
Definition at line 270 of file qsql_db2.cpp.
Referenced by QDB2Result::data(), and qMakeFieldInfo().
274 SQLINTEGER lengthIndicator = 0;
275 SQLRETURN r = SQLGetData(hStmt,
278 (SQLPOINTER) &intbuf,
281 if ((r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) || lengthIndicator == SQL_NULL_DATA) {
static bool isNull(const QVariant::Private *d)
◆ qGetStringData()
static QString qGetStringData |
( |
SQLHANDLE |
hStmt, |
|
|
int |
column, |
|
|
int |
colSize, |
|
|
bool & |
isNull |
|
) |
| |
|
static |
Definition at line 324 of file qsql_db2.cpp.
Referenced by QDB2Result::data(), QDB2Driver::primaryIndex(), qMakeFieldInfo(), and QDB2Driver::tables().
327 SQLRETURN r = SQL_ERROR;
328 SQLINTEGER lengthIndicator = 0;
332 else if (colSize > 65536)
336 SQLTCHAR* buf =
new SQLTCHAR[colSize];
339 r = SQLGetData(hStmt,
343 colSize *
sizeof(SQLTCHAR),
345 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
346 if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) {
352 }
else if (r == SQL_NO_DATA) {
355 qWarning(
"qGetStringData: Error while fetching data (%d)", r);
The QString class provides a Unicode character string.
Q_CORE_EXPORT void qWarning(const char *,...)
void clear()
Clears the contents of the string and makes it empty.
static QString qFromTChar(SQLTCHAR *str)
static bool isNull(const QVariant::Private *d)
◆ qMakeError() [1/2]
Definition at line 167 of file qsql_db2.cpp.
Referenced by QDB2Driver::commitTransaction(), QDB2Result::exec(), QDB2Result::fetch(), QDB2Result::fetchFirst(), QDB2Result::fetchNext(), QDB2Result::nextResult(), QDB2Driver::open(), QDB2Result::prepare(), QDB2Result::reset(), QDB2Driver::rollbackTransaction(), and QDB2Driver::setAutoCommit().
The QSqlError class provides SQL database error information.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QString qDB2Warn(const QDB2DriverPrivate *d)
◆ qMakeError() [2/2]
Definition at line 173 of file qsql_db2.cpp.
The QSqlError class provides SQL database error information.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QString qDB2Warn(const QDB2DriverPrivate *d)
◆ qMakeFieldInfo() [1/2]
Definition at line 234 of file qsql_db2.cpp.
Referenced by QDB2Result::exec(), QDB2Result::nextResult(), QDB2Driver::record(), and QDB2Result::reset().
236 SQLSMALLINT colNameLen;
239 SQLSMALLINT colScale;
240 SQLSMALLINT nullable;
241 SQLRETURN r = SQL_ERROR;
243 r = SQLDescribeCol(d->
hStmt,
253 if (r != SQL_SUCCESS) {
259 if (nullable == SQL_NO_NULLS)
261 else if (nullable == SQL_NULLABLE)
262 f.setRequired(
false);
264 f.setLength(colSize == 0 ? -1 :
int(colSize));
265 f.setPrecision(colScale == 0 ? -1 :
int(colScale));
266 f.setSqlType(
int(colType));
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
static QVariant::Type qDecodeDB2Type(SQLSMALLINT sqltype)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
The QSqlField class manipulates the fields in SQL database tables and views.
static const int COLNAMESIZE
static QString qFromTChar(SQLTCHAR *str)
◆ qMakeFieldInfo() [2/2]
static QSqlField qMakeFieldInfo |
( |
const SQLHANDLE |
hStmt | ) |
|
|
static |
Definition at line 453 of file qsql_db2.cpp.
460 if (required == SQL_NO_NULLS)
462 else if (required == SQL_NULLABLE)
463 f.setRequired(
false);
static QVariant::Type qDecodeDB2Type(SQLSMALLINT sqltype)
static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool &isNull)
The QSqlField class manipulates the fields in SQL database tables and views.
static int qGetIntData(SQLHANDLE hStmt, int column, bool &isNull)
static bool isNull(const QVariant::Private *d)
◆ qMakeStatement()
static bool qMakeStatement |
( |
QDB2ResultPrivate * |
d, |
|
|
bool |
forwardOnly, |
|
|
bool |
setForwardOnly = true |
|
) |
| |
|
static |
Definition at line 471 of file qsql_db2.cpp.
Referenced by QDB2Result::exec(), QDB2Result::prepare(), and QDB2Result::reset().
475 r = SQLAllocHandle(SQL_HANDLE_STMT,
478 if (r != SQL_SUCCESS) {
483 r = SQLFreeStmt(d->
hStmt, SQL_CLOSE);
484 if (r != SQL_SUCCESS) {
494 r = SQLSetStmtAttr(d->
hStmt,
495 SQL_ATTR_CURSOR_TYPE,
496 (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY,
499 r = SQLSetStmtAttr(d->
hStmt,
500 SQL_ATTR_CURSOR_TYPE,
501 (SQLPOINTER) SQL_CURSOR_STATIC,
504 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QDB2DriverPrivate * dp
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
◆ qSplitTableQualifier()
Definition at line 420 of file qsql_db2.cpp.
Referenced by QDB2Driver::primaryIndex(), and QDB2Driver::record().
423 if (!catalog || !schema || !table)
428 int i = 0, n = l.
count();
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
int count(const T &t) const
Returns the number of occurrences of value in the list.
iterator Iterator
Qt-style synonym for QList::iterator.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
The QStringList class provides a list of strings.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
◆ qSqlWarning() [1/2]
◆ qSqlWarning() [2/2]
Definition at line 161 of file qsql_db2.cpp.
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
static QString qDB2Warn(const QDB2DriverPrivate *d)
const char * constData() const
Returns a pointer to the data stored in the byte array.
◆ qToTChar()
static SQLTCHAR* qToTChar |
( |
const QString & |
str | ) |
|
|
static |
◆ qWarnDB2Handle()
static QString qWarnDB2Handle |
( |
int |
handleType, |
|
|
SQLHANDLE |
handle |
|
) |
| |
|
static |
Definition at line 122 of file qsql_db2.cpp.
Referenced by qDB2Warn().
124 SQLINTEGER nativeCode;
126 SQLRETURN r = SQL_ERROR;
127 SQLTCHAR state[SQL_SQLSTATE_SIZE + 1];
128 SQLTCHAR description[SQL_MAX_MESSAGE_LENGTH];
129 r = SQLGetDiagRec(handleType,
134 (SQLTCHAR*) description,
135 SQL_MAX_MESSAGE_LENGTH - 1,
137 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
The QString class provides a Unicode character string.
static QString qFromTChar(SQLTCHAR *str)
◆ COLNAMESIZE
const int COLNAMESIZE = 255 |
|
static |
◆ qParamType
const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT } |
|
static |