Qt 4.8
Classes | Macros | Typedefs | Enumerations | Functions | Variables
qsql_oci.cpp File Reference
#include "qsql_oci.h"
#include <qcoreapplication.h>
#include <qvariant.h>
#include <qdatetime.h>
#include <qmetatype.h>
#include <qregexp.h>
#include <qshareddata.h>
#include <qsqlerror.h>
#include <qsqlfield.h>
#include <qsqlindex.h>
#include <qsqlquery.h>
#include <qstringlist.h>
#include <qvarlengtharray.h>
#include <qvector.h>
#include <qdebug.h>
#include <oci.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  OraFieldInfo
 
struct  QOCIBatchCleanupHandler
 
struct  QOCIBatchColumn
 
class  QOCICols
 
class  QOCICols::OraFieldInf
 
struct  QOCIDriverPrivate
 
struct  QOCIResultPrivate
 
class  QOCIRowId
 

Macros

#define QOCI_DYNAMIC_CHUNK_SIZE   65535
 
#define QOCI_PREFETCH_MEM   10240
 
#define QOCI_THREADED
 

Typedefs

typedef QVarLengthArray< sb2, 32 > IndicatorArray
 
typedef QSharedDataPointer< QOCIRowIdQOCIRowIdPointer
 
typedef QVarLengthArray< ub2, 32 > SizeArray
 

Enumerations

enum  { QOCIEncoding = 2002 }
 

Functions

QVariant::Type qDecodeOCIType (const QString &ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
 
QVariant::Type qDecodeOCIType (int ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
 
static QSqlField qFromOraInf (const OraFieldInfo &ofi)
 
static QDateTime qMakeDate (const char *oraDate)
 
static QSqlError qMakeError (const QString &errString, QSqlError::ErrorType type, OCIError *err)
 
static qlonglong qMakeLongLong (const char *ociNumber, OCIError *err)
 
static QByteArray qMakeOCINumber (const qlonglong &ll, OCIError *err)
 Convert qlonglong to the internal Oracle OCINumber format. More...
 
static QByteArray qMakeOCINumber (const qulonglong &ull, OCIError *err)
 Convert qulonglong to the internal Oracle OCINumber format. More...
 
static QByteArray qMakeOraDate (const QDateTime &dt)
 Convert QDateTime to the internal Oracle DATE format NB! It does not handle BCE dates. More...
 
static qulonglong qMakeULongLong (const char *ociNumber, OCIError *err)
 
static int qOraErrorNumber (OCIError *err)
 
static void qOraOutValue (QVariant &value, QList< QByteArray > &storage, OCIError *err)
 
static QString qOraWarn (OCIError *err, int *errorCode=0)
 
static void qOraWarning (const char *msg, OCIError *err)
 
static void qParseOpts (const QString &options, QOCIDriverPrivate *d)
 
template<class T , int sz>
int qReadLob (T &buf, const QOCIResultPrivate *d, OCILobLocator *lob)
 
void qSplitTableAndOwner (const QString &tname, QString *tbl, QString *owner)
 

Variables

static const ub2 qOraCharset = OCI_UCS2ID
 

Macro Definition Documentation

◆ QOCI_DYNAMIC_CHUNK_SIZE

#define QOCI_DYNAMIC_CHUNK_SIZE   65535

Definition at line 75 of file qsql_oci.cpp.

Referenced by QOCICols::readPiecewise().

◆ QOCI_PREFETCH_MEM

#define QOCI_PREFETCH_MEM   10240

Definition at line 76 of file qsql_oci.cpp.

◆ QOCI_THREADED

#define QOCI_THREADED

Definition at line 81 of file qsql_oci.cpp.

Typedef Documentation

◆ IndicatorArray

typedef QVarLengthArray<sb2, 32> IndicatorArray

Definition at line 110 of file qsql_oci.cpp.

◆ QOCIRowIdPointer

Definition at line 157 of file qsql_oci.cpp.

◆ SizeArray

typedef QVarLengthArray<ub2, 32> SizeArray

Definition at line 111 of file qsql_oci.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
QOCIEncoding 

Definition at line 91 of file qsql_oci.cpp.

91 { QOCIEncoding = 2002 }; // AL16UTF16LE

Function Documentation

◆ qDecodeOCIType() [1/2]

QVariant::Type qDecodeOCIType ( const QString ocitype,
QSql::NumericalPrecisionPolicy  precisionPolicy 
)

Definition at line 561 of file qsql_oci.cpp.

Referenced by QOCIDriver::primaryIndex(), QOCICols::qMakeOraField(), and QOCIDriver::record().

562 {
564  if (ocitype == QLatin1String("VARCHAR2") || ocitype == QLatin1String("VARCHAR")
565  || ocitype.startsWith(QLatin1String("INTERVAL"))
566  || ocitype == QLatin1String("CHAR") || ocitype == QLatin1String("NVARCHAR2")
567  || ocitype == QLatin1String("NCHAR"))
568  type = QVariant::String;
569  else if (ocitype == QLatin1String("NUMBER")
570  || ocitype == QLatin1String("FLOAT")
571  || ocitype == QLatin1String("BINARY_FLOAT")
572  || ocitype == QLatin1String("BINARY_DOUBLE")) {
573  switch(precisionPolicy) {
575  type = QVariant::Int;
576  break;
578  type = QVariant::LongLong;
579  break;
581  type = QVariant::Double;
582  break;
583  case QSql::HighPrecision:
584  default:
585  type = QVariant::String;
586  break;
587  }
588  }
589  else if (ocitype == QLatin1String("LONG") || ocitype == QLatin1String("NCLOB")
590  || ocitype == QLatin1String("CLOB"))
591  type = QVariant::ByteArray;
592  else if (ocitype == QLatin1String("RAW") || ocitype == QLatin1String("LONG RAW")
593  || ocitype == QLatin1String("ROWID") || ocitype == QLatin1String("BLOB")
594  || ocitype == QLatin1String("CFILE") || ocitype == QLatin1String("BFILE"))
595  type = QVariant::ByteArray;
596  else if (ocitype == QLatin1String("DATE") || ocitype.startsWith(QLatin1String("TIME")))
597  type = QVariant::DateTime;
598  else if (ocitype == QLatin1String("UNDEFINED"))
599  type = QVariant::Invalid;
600  if (type == QVariant::Invalid)
601  qWarning("qDecodeOCIType: unknown type: %s", ocitype.toLocal8Bit().constData());
602  return type;
603 }
int type
Definition: qmetatype.cpp:239
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433

◆ qDecodeOCIType() [2/2]

QVariant::Type qDecodeOCIType ( int  ocitype,
QSql::NumericalPrecisionPolicy  precisionPolicy 
)

Definition at line 605 of file qsql_oci.cpp.

606 {
608  switch (ocitype) {
609  case SQLT_STR:
610  case SQLT_VST:
611  case SQLT_CHR:
612  case SQLT_AFC:
613  case SQLT_VCS:
614  case SQLT_AVC:
615  case SQLT_RDD:
616  case SQLT_LNG:
617 #ifdef SQLT_INTERVAL_YM
618  case SQLT_INTERVAL_YM:
619 #endif
620 #ifdef SQLT_INTERVAL_DS
621  case SQLT_INTERVAL_DS:
622 #endif
623  type = QVariant::String;
624  break;
625  case SQLT_INT:
626  type = QVariant::Int;
627  break;
628  case SQLT_FLT:
629  case SQLT_NUM:
630  case SQLT_VNU:
631  case SQLT_UIN:
632  switch(precisionPolicy) {
634  type = QVariant::Int;
635  break;
637  type = QVariant::LongLong;
638  break;
640  type = QVariant::Double;
641  break;
642  case QSql::HighPrecision:
643  default:
644  type = QVariant::String;
645  break;
646  }
647  break;
648  case SQLT_VBI:
649  case SQLT_BIN:
650  case SQLT_LBI:
651  case SQLT_LVC:
652  case SQLT_LVB:
653  case SQLT_BLOB:
654  case SQLT_CLOB:
655  case SQLT_FILE:
656  case SQLT_NTY:
657  case SQLT_REF:
658  case SQLT_RID:
659  type = QVariant::ByteArray;
660  break;
661  case SQLT_DAT:
662  case SQLT_ODT:
663 #ifdef SQLT_TIMESTAMP
664  case SQLT_TIMESTAMP:
665  case SQLT_TIMESTAMP_TZ:
666  case SQLT_TIMESTAMP_LTZ:
667 #endif
668  type = QVariant::DateTime;
669  break;
670  default:
671  type = QVariant::Invalid;
672  qWarning("qDecodeOCIType: unknown OCI datatype: %d", ocitype);
673  break;
674  }
675  return type;
676 }
int type
Definition: qmetatype.cpp:239
Q_CORE_EXPORT void qWarning(const char *,...)
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95

◆ qFromOraInf()

static QSqlField qFromOraInf ( const OraFieldInfo ofi)
static

Definition at line 678 of file qsql_oci.cpp.

Referenced by QOCICols::QOCICols().

679 {
680  QSqlField f(ofi.name, ofi.type);
681  f.setRequired(ofi.oraIsNull == 0);
682 
683  if (ofi.type == QVariant::String && ofi.oraType != SQLT_NUM && ofi.oraType != SQLT_VNU)
684  f.setLength(ofi.oraFieldLength);
685  else
686  f.setLength(ofi.oraPrecision == 0 ? 38 : int(ofi.oraPrecision));
687 
688  f.setPrecision(ofi.oraScale);
689  f.setSqlType(int(ofi.oraType));
690  return f;
691 }
ub4 oraFieldLength
Definition: qsql_oci.cpp:508
QString name
Definition: qsql_oci.cpp:502
The QSqlField class manipulates the fields in SQL database tables and views.
Definition: qsqlfield.h:56
sb2 oraPrecision
Definition: qsql_oci.cpp:509
QVariant::Type type
Definition: qsql_oci.cpp:503

◆ qMakeDate()

QDateTime qMakeDate ( const char *  oraDate)
static

Definition at line 773 of file qsql_oci.cpp.

Referenced by QOCICols::execBatch(), QOCICols::getValues(), and qOraOutValue().

774 {
775  int century = uchar(oraDate[0]);
776  if(century >= 100){
777  int year = uchar(oraDate[1]);
778  year = ((century-100)*100) + (year-100);
779  int month = oraDate[2];
780  int day = oraDate[3];
781  int hour = oraDate[4] - 1;
782  int min = oraDate[5] - 1;
783  int sec = oraDate[6] - 1;
784  return QDateTime(QDate(year,month,day), QTime(hour,min,sec));
785  }
786  return QDateTime();
787 }
The QDate class provides date functions.
Definition: qdatetime.h:55
unsigned char uchar
Definition: qglobal.h:994
The QTime class provides clock time functions.
Definition: qdatetime.h:148
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ qMakeError()

QSqlError qMakeError ( const QString errString,
QSqlError::ErrorType  type,
OCIError *  err 
)
static

Definition at line 554 of file qsql_oci.cpp.

Referenced by QOCIDriver::beginTransaction(), QOCIDriver::commitTransaction(), QOCIResult::exec(), QOCICols::execBatch(), QOCIResult::gotoNext(), QOCIDriver::open(), QOCIResult::prepare(), QOCIDriver::QOCIDriver(), and QOCIDriver::rollbackTransaction().

555 {
556  int errorCode = 0;
557  const QString oraErrorString = qOraWarn(err, &errorCode);
558  return QSqlError(errString, oraErrorString, type, errorCode);
559 }
The QSqlError class provides SQL database error information.
Definition: qsqlerror.h:53
int type
Definition: qmetatype.cpp:239
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString qOraWarn(OCIError *err, int *errorCode=0)
Definition: qsql_oci.cpp:512

◆ qMakeLongLong()

qlonglong qMakeLongLong ( const char *  ociNumber,
OCIError *  err 
)
static

Definition at line 757 of file qsql_oci.cpp.

Referenced by QOCICols::execBatch(), and qOraOutValue().

758 {
759  qlonglong qll = 0;
760  OCINumberToInt(err, reinterpret_cast<const OCINumber *>(ociNumber), sizeof(qlonglong),
761  OCI_NUMBER_SIGNED, &qll);
762  return qll;
763 }
qint64 qlonglong
Definition: qglobal.h:951

◆ qMakeOCINumber() [1/2]

QByteArray qMakeOCINumber ( const qlonglong ll,
OCIError *  err 
)
static

Convert qlonglong to the internal Oracle OCINumber format.

Warning
This function is not part of the public interface.

Definition at line 725 of file qsql_oci.cpp.

Referenced by QOCIResultPrivate::bindValue(), and QOCICols::execBatch().

726 {
727  QByteArray ba(sizeof(OCINumber), 0);
728 
729  OCINumberFromInt(err,
730  &ll,
731  sizeof(qlonglong),
732  OCI_NUMBER_SIGNED,
733  reinterpret_cast<OCINumber*>(ba.data()));
734  return ba;
735 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
qint64 qlonglong
Definition: qglobal.h:951

◆ qMakeOCINumber() [2/2]

QByteArray qMakeOCINumber ( const qulonglong ull,
OCIError *  err 
)
static

Convert qulonglong to the internal Oracle OCINumber format.

Warning
This function is not part of the public interface.

Definition at line 745 of file qsql_oci.cpp.

746 {
747  QByteArray ba(sizeof(OCINumber), 0);
748 
749  OCINumberFromInt(err,
750  &ull,
751  sizeof(qlonglong),
752  OCI_NUMBER_UNSIGNED,
753  reinterpret_cast<OCINumber*>(ba.data()));
754  return ba;
755 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
qint64 qlonglong
Definition: qglobal.h:951

◆ qMakeOraDate()

QByteArray qMakeOraDate ( const QDateTime dt)
static

Convert QDateTime to the internal Oracle DATE format NB! It does not handle BCE dates.

Warning
This function is not part of the public interface.

Definition at line 702 of file qsql_oci.cpp.

Referenced by QOCIResultPrivate::bindValue(), and QOCICols::execBatch().

703 {
704  QByteArray ba;
705  ba.resize(7);
706  int year = dt.date().year();
707  ba[0]= (year / 100) + 100; // century
708  ba[1]= (year % 100) + 100; // year
709  ba[2]= dt.date().month();
710  ba[3]= dt.date().day();
711  ba[4]= dt.time().hour() + 1;
712  ba[5]= dt.time().minute() + 1;
713  ba[6]= dt.time().second() + 1;
714  return ba;
715 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
Definition: qdatetime.cpp:382
int day() const
Returns the day of the month (1 to 31) of this date.
Definition: qdatetime.cpp:395
int second() const
Returns the second part (0 to 59) of the time.
Definition: qdatetime.cpp:1600
int minute() const
Returns the minute part (0 to 59) of the time.
Definition: qdatetime.cpp:1589
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
void resize(int size)
Sets the size of the byte array to size bytes.
int year() const
Returns the year of this date.
Definition: qdatetime.cpp:353
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368
int hour() const
Returns the hour part (0 to 23) of the time.
Definition: qdatetime.cpp:1578

◆ qMakeULongLong()

qulonglong qMakeULongLong ( const char *  ociNumber,
OCIError *  err 
)
static

Definition at line 765 of file qsql_oci.cpp.

Referenced by QOCICols::execBatch(), and qOraOutValue().

766 {
767  qulonglong qull = 0;
768  OCINumberToInt(err, reinterpret_cast<const OCINumber *>(ociNumber), sizeof(qulonglong),
769  OCI_NUMBER_UNSIGNED, &qull);
770  return qull;
771 }
quint64 qulonglong
Definition: qglobal.h:952

◆ qOraErrorNumber()

static int qOraErrorNumber ( OCIError *  err)
static

Definition at line 541 of file qsql_oci.cpp.

Referenced by QOCIResult::gotoNext().

542 {
543  sb4 errcode;
544  OCIErrorGet(err,
545  1,
546  0,
547  &errcode,
548  0,
549  0,
550  OCI_HTYPE_ERROR);
551  return errcode;
552 }

◆ qOraOutValue()

static void qOraOutValue ( QVariant value,
QList< QByteArray > &  storage,
OCIError *  err 
)
static

Definition at line 419 of file qsql_oci.cpp.

Referenced by QOCICols::execBatch(), and QOCIResultPrivate::outValues().

420 {
421  switch (value.type()) {
422  case QVariant::Time:
423  value = qMakeDate(storage.takeFirst()).time();
424  break;
425  case QVariant::Date:
426  value = qMakeDate(storage.takeFirst()).date();
427  break;
428  case QVariant::DateTime:
429  value = qMakeDate(storage.takeFirst());
430  break;
431  case QVariant::LongLong:
432  value = qMakeLongLong(storage.takeFirst(), err);
433  break;
434  case QVariant::ULongLong:
435  value = qMakeULongLong(storage.takeFirst(), err);
436  break;
437  case QVariant::String:
438  value = QString(
439  reinterpret_cast<const QChar *>(storage.takeFirst().constData()));
440  break;
441  default:
442  break; //nothing
443  }
444 }
static QDateTime qMakeDate(const char *oraDate)
Definition: qsql_oci.cpp:773
The QString class provides a Unicode character string.
Definition: qstring.h:83
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static qlonglong qMakeLongLong(const char *ociNumber, OCIError *err)
Definition: qsql_oci.cpp:757
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
static qulonglong qMakeULongLong(const char *ociNumber, OCIError *err)
Definition: qsql_oci.cpp:765

◆ qOraWarn()

QString qOraWarn ( OCIError *  err,
int *  errorCode = 0 
)
static

Definition at line 512 of file qsql_oci.cpp.

Referenced by qMakeError(), and qOraWarning().

513 {
514  sb4 errcode;
515  text errbuf[1024];
516  errbuf[0] = 0;
517  errbuf[1] = 0;
518 
519  OCIErrorGet(err,
520  1,
521  0,
522  &errcode,
523  errbuf,
524  sizeof(errbuf),
525  OCI_HTYPE_ERROR);
526  if (errorCode)
527  *errorCode = errcode;
528  return QString(reinterpret_cast<const QChar *>(errbuf));
529 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define text
Definition: qobjectdefs.h:80

◆ qOraWarning()

void qOraWarning ( const char *  msg,
OCIError *  err 
)
static

Definition at line 531 of file qsql_oci.cpp.

Referenced by QOCIDriver::beginTransaction(), QOCIResultPrivate::bindValue(), QOCIDriver::commitTransaction(), QOCIResult::exec(), QOCICols::execBatch(), QOCIResult::gotoNext(), QOCIResult::prepare(), QOCICols::qMakeOraField(), QOCICols::QOCICols(), qReadLob(), QOCICols::readPiecewise(), QOCIDriver::rollbackTransaction(), QOCIResultPrivate::setCharset(), and QOCIResultPrivate::setStatementAttributes().

532 {
533 #ifdef QOCI_DEBUG
534  qWarning("%s %s", msg, qPrintable(qOraWarn(err)));
535 #else
536  Q_UNUSED(msg);
537  Q_UNUSED(err);
538 #endif
539 }
Q_CORE_EXPORT void qWarning(const char *,...)
#define qPrintable(string)
Definition: qglobal.h:1750
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static QString qOraWarn(OCIError *err, int *errorCode=0)
Definition: qsql_oci.cpp:512

◆ qParseOpts()

static void qParseOpts ( const QString options,
QOCIDriverPrivate d 
)
static

Definition at line 2151 of file qsql_oci.cpp.

Referenced by QOCIDriver::open().

2152 {
2153  const QStringList opts(options.split(QLatin1Char(';'), QString::SkipEmptyParts));
2154  for (int i = 0; i < opts.count(); ++i) {
2155  const QString tmp(opts.at(i));
2156  int idx;
2157  if ((idx = tmp.indexOf(QLatin1Char('='))) == -1) {
2158  qWarning("QOCIDriver::parseArgs: Invalid parameter: '%s'",
2159  tmp.toLocal8Bit().constData());
2160  continue;
2161  }
2162  const QString opt = tmp.left(idx);
2163  const QString val = tmp.mid(idx + 1).simplified();
2164  bool ok;
2165  if (opt == QLatin1String("OCI_ATTR_PREFETCH_ROWS")) {
2166  d->prefetchRows = val.toInt(&ok);
2167  if (!ok)
2168  d->prefetchRows = -1;
2169  } else if (opt == QLatin1String("OCI_ATTR_PREFETCH_MEMORY")) {
2170  d->prefetchMem = val.toInt(&ok);
2171  if (!ok)
2172  d->prefetchMem = -1;
2173  } else {
2174  qWarning ("QOCIDriver::parseArgs: Invalid parameter: '%s'",
2175  opt.toLocal8Bit().constData());
2176  }
2177  }
2178 }
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
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.
Definition: qstring.cpp:4049
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
Definition: qstring.cpp:4415
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...
Definition: qstring.cpp:6526
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ qReadLob()

template<class T , int sz>
int qReadLob ( T &  buf,
const QOCIResultPrivate d,
OCILobLocator *  lob 
)

Definition at line 1630 of file qsql_oci.cpp.

1631 {
1632  ub1 csfrm;
1633  ub4 amount;
1634  int r;
1635 
1636  // Read this from the database, don't assume we know what it is set to
1637  r = OCILobCharSetForm(d->env, d->err, lob, &csfrm);
1638  if (r != OCI_SUCCESS) {
1639  qOraWarning("OCIResultPrivate::readLobs: Couldn't get LOB char set form: ", d->err);
1640  csfrm = 0;
1641  }
1642 
1643  // Get the length of the LOB (this is in characters)
1644  r = OCILobGetLength(d->svc, d->err, lob, &amount);
1645  if (r == OCI_SUCCESS) {
1646  if (amount == 0) {
1647  // Short cut for null LOBs
1648  buf.resize(0);
1649  return OCI_SUCCESS;
1650  }
1651  } else {
1652  qOraWarning("OCIResultPrivate::readLobs: Couldn't get LOB length: ", d->err);
1653  return r;
1654  }
1655 
1656  // Resize the buffer to hold the LOB contents
1657  buf.resize(amount);
1658 
1659  // Read the LOB into the buffer
1660  r = OCILobRead(d->svc,
1661  d->err,
1662  lob,
1663  &amount,
1664  1,
1665  buf.data(),
1666  buf.size() * sz, // this argument is in bytes, not characters
1667  0,
1668  0,
1669  // Extract the data from a CLOB in UTF-16 (ie. what QString uses internally)
1670  sz == 1 ? ub2(0) : ub2(QOCIEncoding),
1671  csfrm);
1672 
1673  if (r != OCI_SUCCESS)
1674  qOraWarning("OCIResultPrivate::readLOBs: Cannot read LOB: ", d->err);
1675 
1676  return r;
1677 }
OCISvcCtx *& svc
Definition: qsql_oci.cpp:173
OCIError * err
Definition: qsql_oci.cpp:172
static void qOraWarning(const char *msg, OCIError *err)
Definition: qsql_oci.cpp:531

◆ qSplitTableAndOwner()

void qSplitTableAndOwner ( const QString tname,
QString tbl,
QString owner 
)

Definition at line 2444 of file qsql_oci.cpp.

Referenced by QOCIDriver::primaryIndex(), and QOCIDriver::record().

2446 {
2447  int i = tname.indexOf(QLatin1Char('.')); // prefixed with owner?
2448  if (i != -1) {
2449  *tbl = tname.right(tname.length() - i - 1);
2450  *owner = tname.left(i);
2451  } else {
2452  *tbl = tname;
2453  }
2454 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
Definition: qstring.cpp:3682
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Variable Documentation

◆ qOraCharset

const ub2 qOraCharset = OCI_UCS2ID
static

Definition at line 107 of file qsql_oci.cpp.

Referenced by QOCIResultPrivate::setCharset().