Qt 4.8
Public Functions | Public Variables | List of all members
QSymSQLResultPrivate Class Reference

Public Functions

void cleanup ()
 
bool fetchNext (bool initialFetch)
 
void finalize ()
 
void initColumns (QSqlRecord &rec)
 
 QSymSQLResultPrivate (QSymSQLResult *res)
 

Public Variables

RSqlDatabase access
 
bool prepareCalled
 
QSymSQLResultq
 
bool skippedStatus
 
bool skipRow
 
RSqlStatement stmt
 

Detailed Description

Definition at line 175 of file qsql_symsql.cpp.

Constructors and Destructors

◆ QSymSQLResultPrivate()

QSymSQLResultPrivate::QSymSQLResultPrivate ( QSymSQLResult res)

Definition at line 193 of file qsql_symsql.cpp.

193  : q(res),
194  skipRow(false),
195  skippedStatus(false),
196  prepareCalled(false)
197 {
198 }
QSymSQLResult * q

Functions

◆ cleanup()

void QSymSQLResultPrivate::cleanup ( )

Definition at line 200 of file qsql_symsql.cpp.

Referenced by QSymSQLResult::prepare(), and QSymSQLResult::~QSymSQLResult().

201 {
202  finalize();
203  skippedStatus = false;
204  skipRow = false;
206  q->setActive(false);
207 }
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
QSymSQLResult * q
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
Definition: qsqlresult.cpp:402

◆ fetchNext()

bool QSymSQLResultPrivate::fetchNext ( bool  initialFetch)

Definition at line 254 of file qsql_symsql.cpp.

Referenced by QSymSQLResult::exec(), QSymSQLResult::fetch(), and QSymSQLResult::fetchNext().

255 {
256  int res;
257 
258  if (skipRow) {
259  // already fetched
260  Q_ASSERT(!initialFetch);
261  skipRow = false;
262  return skippedStatus;
263  }
264 
265  skipRow = initialFetch;
266  res = stmt.Next();
267 
268  switch(res) {
269  case KSqlAtRow:
270  return true;
271  case KSqlAtEnd:
272  stmt.Reset();
273  return false;
274  case KSqlErrGeneral:
275  // KSqlErrGeneral is a generic error code and we must call stmt.Reset()
276  // to get the specific error message.
277  stmt.Reset();
279  "Unable to fetch row"), QSqlError::ConnectionError, res));
281  return false;
282  case KSqlErrMisuse:
283  case KSqlErrBusy:
284  default:
285  // something wrong, don't get col info, but still return false
287  "Unable to fetch row"), QSqlError::ConnectionError, res));
288  stmt.Reset();
290  return false;
291  }
292  return false;
293 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
Definition: qsqlresult.cpp:352
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417
static QSqlError qMakeError(RSqlDatabase &access, const QString &descr, QSqlError::ErrorType type, int errorCode=-1)
QSymSQLResult * q
RSqlStatement stmt

◆ finalize()

void QSymSQLResultPrivate::finalize ( )

Definition at line 209 of file qsql_symsql.cpp.

Referenced by cleanup(), QSymSQLResult::exec(), and QSymSQLResult::prepare().

210 {
211  prepareCalled = false;
212  stmt.Close();
213 }
RSqlStatement stmt

◆ initColumns()

void QSymSQLResultPrivate::initColumns ( QSqlRecord rec)

Definition at line 215 of file qsql_symsql.cpp.

Referenced by QSymSQLResult::record().

216 {
217  int nCols = stmt.ColumnCount();
218  if (nCols <= 0) {
220  "Error retrieving column count"), QSqlError::UnknownError, nCols));
221  return;
222  }
223 
224  for (int i = 0; i < nCols; ++i) {
225  TPtrC cName;
226  TInt err = stmt.ColumnName(i, cName);
227 
228  if (err != KErrNone) {
230  "Error retrieving column name"), QSqlError::UnknownError, err));
231  return;
232  }
233 
234  QString colName = qt_TDesC2QString(cName);
235 
236  // must use typeName for resolving the type to match QSymSQLDriver::record
237  TPtrC tName;
238  TSqlColumnType decColType;
239  err = stmt.DeclaredColumnType(i, decColType);
240 
241  if (err != KErrNone) {
243  "Error retrieving column type"), QSqlError::UnknownError, err));
244  return;
245  }
246 
247  int dotIdx = colName.lastIndexOf(QLatin1Char('.'));
248  QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), qGetColumnType(decColType));
249 
250  rec.append(fld);
251  }
252 }
static QVariant::Type qGetColumnType(const TSqlColumnType coltype)
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417
static QSqlError qMakeError(RSqlDatabase &access, const QString &descr, QSqlError::ErrorType type, int errorCode=-1)
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
QSymSQLResult * q
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
Definition: qsqlrecord.cpp:312
The QSqlField class manipulates the fields in SQL database tables and views.
Definition: qsqlfield.h:56
RSqlStatement stmt
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Properties

◆ access

RSqlDatabase QSymSQLResultPrivate::access

◆ prepareCalled

bool QSymSQLResultPrivate::prepareCalled

Definition at line 190 of file qsql_symsql.cpp.

Referenced by QSymSQLResult::exec(), finalize(), and QSymSQLResult::prepare().

◆ q

QSymSQLResult* QSymSQLResultPrivate::q

Definition at line 185 of file qsql_symsql.cpp.

Referenced by cleanup(), fetchNext(), and initColumns().

◆ skippedStatus

bool QSymSQLResultPrivate::skippedStatus

Definition at line 189 of file qsql_symsql.cpp.

Referenced by cleanup(), QSymSQLResult::exec(), QSymSQLResult::fetchLast(), and fetchNext().

◆ skipRow

bool QSymSQLResultPrivate::skipRow

◆ stmt

RSqlStatement QSymSQLResultPrivate::stmt

The documentation for this class was generated from the following file: