Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Interface Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWDBUpdater

Module:  DB Interface Module   Group:  Data Manipulation Classes


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/db/updater.h>

RWDBUpdater updater = myTable.updater();

Description

RWDBUpdater is an encapsulation of an SQL UPDATE statement. Its methods provide an application with explicit control over the UPDATE statement's SET and WHERE clauses.

The insertion operator << is used to add encapsulated SET clauses to an RWDBUpdater; the where() method is used to specify a WHERE clause. The items which are inserted into an RWDBUpdater are RWDBAssignments, which are created by the assign() method of RWDBColumn. The WHERE clause is encapsulated by an RWDBCriterion, which is some number of RWDBExprs combined with logical operators.

An UPDATE statement does not normally produce results. However, the DB Interface Module recognizes that some database vendors provide triggers, which can cause results to be generated by an UPDATE statement. Consequently, RWDBUpdater's execute() method returns an RWDBResult, which is a sequence of zero or more RWDBTables. Applications are not obliged to request any tables from the returned object.

RWDBUpdater is designed around the Interface/Implementation paradigm. An RWDBUpdater instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation. An RWDBUpdater's implementation is a base class from which a family of database-specific updater implementations is derived.

Example 1

This example uses an RWDBUpdater to increment the number column of the Inventory table by 50 wherever red is found in the color column.

Example 2

This example accomplishes the same task as Example 1, but provides bindings to an application variable. This allows the application to repeatedly execute the update with different values without reshifting in values.

Related Classes

The encapsulated WHERE clause of an RWDBUpdater is an RWDBCriterion, which is composed of RWDBExprs. Each encapsulated SET clause is an RWDBAssignment, produced by the assign() method of RWDBColumn. See RWDBAssignment, RWDBCriterion, RWDBExpr, and RWDBColumn for details.

The result of RWDBUpdater::execute() is an RWDBResult, which represents a sequence of zero or more RWDBTables. See RWDBResult and RWDBTable for details.

Public Constructors

RWDBUpdater();
RWDBUpdater(const RWDBUpdater& upd);

Public Member Operators

RWDBUpdater&
operator=(const RWDBUpdater& upd);

Public Member Functions

void
acquire() const;
RWCString
asString() const;

NOTE -- When the RWDBDatabase::verboseAsString() option is set to true, the SQL returned by this method may not be a valid SQL statement. However, this method's return value is not necessarily the same SQL that is sent to the database for execution. For example, if an RWDBBlob object is bound, calling asString() with RWDBDatabase::verboseAsString() set to true will result in a string with blob data returned as hex numbers, such as 0x0A32F5.

RWCString asString(bool verbose) const;

NOTE -- The SQL returned by this method when verbose is true may not be a valid SQL statement. However, this is not necessarily the same SQL sent to the database for execution. For example, if an RWDBBlob object is bound, calling asString(true) will result in a string with blob data returned as hex numbers, such as 0x0A32F5.
RWCString
asString(const RWDBConnector conn) const;

NOTE -- When the RWDBDatabase::verboseAsString() option is set to true, the SQL returned by this method may not be a valid SQL statement. However, this method's return value is not necessarily the same SQL that is sent to the database for execution. For example, if an RWDBBlob object is bound, calling asString() with RWDBDatabase::verboseAsString() set to true will result in a string with blob data returned as hex numbers, such as 0x0A32F5.

RWCString asString(const RWDBConnector conn, bool verbose) const;

NOTE -- The SQL returned by this method when verbose is true may not be a valid SQL statement. However, this is not necessarily the same SQL sent to the database for execution. For example, if an RWDBBlob object is bound, calling asString(true) will result in a string with blob data returned as hex numbers, such as 0x0A32F5.
RWDBStatus
clear();
RWDBStatus::ErrorHandler
errorHandler() const;
RWDBResult
execute();
RWDBResult
execute(const RWDBConnection& connection);
bool
isReady() const;
bool
isValid() const;
void
release() const;
RWDBUpdater&
set(const RWDBAssignment& assignment);
void
setErrorHandler(RWDBStatus::ErrorHandler handler);
RWDBStatus
status() const;
RWDBTable
table() const;
RWDBCriterion
where() const;
RWDBUpdater&
where(const RWDBCriterion& criterion);

Related Global Operator

RWDBUpdater&
operator<<(RWDBUpdater& updater,
           const RWDBAssignment assignment);
RWDBUpdater&
operator[](size_t index);


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.