DBRecord Class Reference

[DataWidget Index] [DataWidget Hierarchy]


Database specific part of the manager More...

#include <dbrecord.h>

Public Members


Detailed Description

Database specific part of the manager. The manager consists of two classes. DBDatasource keeps track of the state and emits the signals. A class derrived from DBRecord handles the database connection.


DBRecord()

Constructor does nothing

virtual ~DBRecord()

Destructor does nothing

virtual bool isReadOnly()

Is update, insert or delete possible ?

virtual const QString &getErrorInfo()

Returns a description of the last error

virtual void setQuery(const QString &str, bool removeTables = false)

Defines the query string.

Parameters:
removeTables Remove table definitions set by addTable()
str The query eg. "select * from table where id = ?"

virtual void addTable(const char *table, const char *primaries, const char *columns)

Defines a table, the primary keys and the columns. If you want to update the table, you have to define the primary keys.

Parameters:
table The name of the database table.
columns The names of the columns seperated by blanks. It defaults to all columns if the string is 0 or "".
primaries Pairs of name=position sperated by blanks eg. "id=0 mid=1"

virtual bool open()

Opens the database connection.

virtual void close()

Closes the database connection.

virtual bool refresh()

Refreshes the dataset after a write operation. If you don't call refresh, the data is undefined.

virtual bool first(bool *invalid)

Go to the first record.

Parameters:
invalid Will become true if the record does not exist.
Returns:
False if error or if the record does not exist.

virtual bool prior(bool *invalid)

Go to the previous record.

Parameters:
invalid Will become true if the record does not exist.
Returns:
False if error or if the record does not exist.

virtual bool next(bool *invalid)

Go to the next record.

Parameters:
invalid Will become true if the record does not exist.
Returns:
False if error or if the record does not exist.

virtual bool last(bool *invalid)

Go to the last record.

Parameters:
invalid Will become true if the record does not exist.
Returns:
False if error or if the record does not exist.

virtual bool moveBy(bool *invalid, long offset)

Go to the given record.

Parameters:
invalid Will become true if the record does not exist.
offset Number of records to move.
Returns:
False if error or if the record does not exist.

virtual bool moveTo(bool *invalid, long position)

Go to the given record.

Parameters:
position Index of the record, zero based.
invalid Will become true if the record does not exist.
Returns:
False if error or if the record does not exist.

virtual long getCursor()

Returns the position of the record [zero based] or BOFCursor, EOFCursor, InsertCursor, InitCursor.

virtual bool cancel()

Cancels append and setValue, restores the old values.

virtual bool isDirty()

Is an insert/update necessary

virtual bool update(bool *done = 0, bool force = false)

Updates the Database if the values had been changed.

Parameters:
done Becomes true if the update was performd.
force Update even if no field had been changed.
Returns:
False if an error occured.

virtual bool insert(bool *done = 0, bool force = false)

Insert into the Database if the values had been changed.

Parameters:
done Becomes true if the insert was performd.
force Insert even if no field had been changed.
Returns:
False if an error occured.

virtual bool append(int todo)

Prepare working area for an insert.

Parameters:
todo SetCopy fetches the values from the current record.
SetZero init to 0 or "".
SetNull init null values
SetAutoNull init autoincrement columns for generating a new value

virtual bool remove()

Deletes the current record from the database.

virtual void backup()

Saves the current state, the cursor and the curernt values of the fields.

virtual bool restore()

Restores the state from the last backup.

virtual int getNumCols()

Returns the number of columns;

virtual const char *getColumnName(int col)

Returns the name or alias of the column, zero based.

virtual const char *getColumnQualifierName(int col)

Returns the name or alias of the table, zero based.

virtual int getColumnType(int col)

Returns the type of the column, zero based.

Returns:
DBTypes::TypeLong DBTypes::TypeDouble DBTypes::TypeDate DBTypes::TypeTime DBTypes::TypeDateTime DBTypes::TypeBinary DBTypes::TypeString

virtual const char *getColumnTypeName(int col)

Returns the type of the column, zero based.

virtual long getColumnLength(int col)

Returns the size of the column, zero based.

virtual int getColumnPrecision(int col)

Returns the precision of the column, zero based.

virtual int getColumnScale(int )

Returns the scale of the column, zero based.

virtual long getColumnDisplaySize(int col)

Returns the display size of the column, zero based.

virtual int getColumnNullable(int col)

Is the column nullable, zero based.

virtual int getColumnUnsigned(int col)

Is the column unsigned, zero based.

virtual int getColumnMoney(int col)

Is the column a money value, zero based.

virtual int getColumnUpdatable(int col)

Is the column updateable, zero based.

virtual int getColumnAutoIncrement(int col)

Is it a auto increment column, zero based.

virtual long getNumRows()

Returns the number of rows of query.

virtual bool setValue(const DBField *field, int column, bool markDirty = true)

Changes the value in the working area.

Parameters:
field The new value
column The index of the column, zero based.
markDirty An insert() or update() will do nothing if there was no markDirty call.

virtual bool setParameter(const DBField *field, int column)

Changes the parameter of the select statement.

Parameters:
field The new value
column The index of the column, zero based.

virtual const DBField *getValue(int pos)

Returns the value from the working area. If the working area was not initialzed with append() and the value had not been set with setValue(), the value is fetched from the database.

virtual const DBField *getParameter(int pos)

If setParameter was called, the method returns the old value. Otherwise it creates a DBField with a proper type.


  • Author: Edwin Glaser
  • Version: $Name: $ $Date: 2000/02/07 21:42:04 $
  • Documentation generated by eg@wonko on Sam Feb 19 00:09:53 MET 2000
Kdoc