SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWDBSelector Class Reference

Encapsulates the SQL SELECT statement. More...

#include <rw/db/select.h>

Inheritance diagram for RWDBSelector:
RWDBSelectorBase

Public Types

enum  FromGeneration { ExplicitOrImplicit , ExplicitAndImplicit }
 

Public Member Functions

 RWDBSelector ()
 
 RWDBSelector (const RWDBSelector &select)
 
RWCString asString () const
 
RWCString asString (bool verbose) const
 
RWCString asString (const RWDBConnection &conn) const
 
RWCString asString (const RWDBConnection &conn, bool verbose) const
 
RWDBBulkReader bulkReader (const RWDBConnection &conn) const
 
RWDBStatus clear ()
 
RWDBColumn column (const RWCString &name) const
 
RWDBColumn column (const RWCString &name, RWCString::caseCompare caseCompare) const
 
RWDBColumn column (size_t index) const
 
RWDBCursor cursor (const RWDBConnection &connection, RWDBCursor::CursorType type=RWDBCursor::Sequential, RWDBCursor::CursorAccess access=RWDBCursor::Read) const
 
RWDBCursor cursor (const RWDBSchema &updateCols, const RWDBConnection &connection, RWDBCursor::CursorType type=RWDBCursor::Sequential, RWDBCursor::CursorAccess access=RWDBCursor::Read) const
 
RWDBCursor cursor (const RWDBSchema &updateCols, RWDBCursor::CursorType type=RWDBCursor::Sequential, RWDBCursor::CursorAccess access=RWDBCursor::Read) const
 
RWDBCursor cursor (RWDBCursor::CursorType type=RWDBCursor::Sequential, RWDBCursor::CursorAccess access=RWDBCursor::Read) const
 
RWDBDatabase database () const
 
virtual RWDBCompoundSelector difference (const RWDBSelectorBase &selector) const
 
RWDBSelectordistinct (bool logic=true)
 
RWDBResult execute ()
 
RWDBResult execute (const RWDBConnection &connection)
 
bool fetchSchema ()
 
bool fetchSchema (const RWDBConnection &connection)
 
RWDBSelectorfrom (const RWCString &tableName)
 
RWDBSelectorfrom (const RWDBJoinExpr &jExpr)
 
RWDBSelectorfrom (const RWDBTable &table)
 
RWDBSelectorfromClear ()
 
RWDBSelectorfromExtern (const RWDBTable &table)
 
RWDBSelectorfromExternClear ()
 
FromGeneration fromGeneration () const
 
RWDBSelectorfromGeneration (FromGeneration flag)
 
RWDBSelectorgroupBy (const RWDBColumn &column)
 
RWDBSelectorgroupBy (const RWDBExpr &expr)
 
RWDBSelectorgroupBy (int columnNumber)
 
RWDBSelectorgroupByClear ()
 
RWDBSelectorhaving (const RWDBCriterion &criterion)
 
virtual RWDBCompoundSelector intersection (const RWDBSelectorBase &selector) const
 
RWDBSelectorinto (const RWCString &tableName)
 
bool isValid () const
 
RWDBSelectoron (const RWDBColumn &column)
 
RWDBSelectoron (const RWDBCriterion &criterion)
 
RWDBSelectoroperator<< (const RWDBExpr &expr)
 
RWDBSelectoroperator<< (const RWDBTable &table)
 
RWDBSelectoroperator<< (RWDBValueManip manip)
 
RWDBSelectoroperator= (const RWDBSelector &select)
 
RWDBColumn operator[] (const RWCString &name) const
 
RWDBColumn operator[] (size_t position) const
 
RWDBSelectororderBy (const RWDBColumn &column)
 
RWDBSelectororderBy (const RWDBExpr &expr)
 
RWDBSelectororderBy (int columnNumber)
 
RWDBSelectororderByClear ()
 
RWDBSelectororderByDescending (const RWDBColumn &column)
 
RWDBSelectororderByDescending (int columnNumber)
 
RWDBReader reader (const RWDBConnection &connection, size_t cacheSize=0) const
 
RWDBReader reader (size_t cacheSize=0) const
 
RWDBSchema schema () const
 
RWDBSelectorselect (const RWDBExpr &expr)
 
RWDBSelectorselect (const RWDBTable &table)
 
RWDBSelectorselectClear ()
 
void setErrorHandler (RWDBStatus::ErrorHandler handler)
 
RWDBStatus status () const
 
virtual RWDBCompoundSelector union_ (const RWDBSelectorBase &selector) const
 
virtual RWDBCompoundSelector unionAll (const RWDBSelectorBase &selector) const
 
RWDBCriterion where () const
 
RWDBSelectorwhere (const RWDBCriterion &criterion)
 

Related Symbols

(Note that these are not member symbols.)

RWDBCompoundSelector operator* (const RWDBSelectorBase &left, const RWDBSelectorBase &right)
 
RWDBCompoundSelector operator+ (const RWDBSelectorBase &left, const RWDBSelectorBase &right)
 
RWDBCompoundSelector operator- (const RWDBSelectorBase &left, const RWDBSelectorBase &right)
 

Detailed Description

RWDBSelector is an encapsulation of an SQL SELECT statement. Its methods provide an application with explicit control over the SELECT statement's select list, as well as its FROM, WHERE, ORDER BY, and GROUP BY clauses. The set operators +, *, and - (union, intersection, and difference) may be applied to RWDBSelector objects in order to achieve the semantics of the SQL UNION, INTERSECTION, and DIFFERENCE operations. See the entry for RWDBCompoundSelector. An RWDBSelector may be used to instantiate an RWDBExpr, so subqueries are also supported. See the entry for RWDBExpr.

The insertion operator operator<<() is used to add items to an RWDBSelector select list; the where() method is used to specify a WHERE clause. The items which are inserted into an RWDBSelector are RWDBExpr objects, which may be any combination of constants, column references, predefined functions, or RWDBSelector objects combined by arithmetic or functional operators. The WHERE clause is encapsulated by an RWDBCriterion, which is some number of RWDBExpr objects combined with logical operators.

The result of an SQL SELECT statement execution is an SQL table expression. The DB Interface Module represents this concept as a ResultTable. Hence, the following are equivalent:

(1) RWDBReader rdr = selector.execute().table().reader();
(2) RWDBReader rdr = selector.reader();

RWDBSelector also derives from RWDBSelectorBase so that RWDBSelector and RWDBCompoundSelector may be handled in a uniform manner.

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

Most RWDBSelector methods return a reference to self. This allows calls to be stacked, as in:

select.where(...).orderBy(...).groupBy(...), etc.
Synopsis
#include <rw/db/select.h>
RWDBSelector select = myDbase.selector();
Encapsulates the SQL SELECT statement.
Definition select.h:369
RWDBSelector & select(const RWDBExpr &expr)
Example

Example1

Assuming that dBase is a valid RWDBDatabase, we can encapsulate the SQL statement:

SELECT myTable.name, yourTable.city FROM myTable,
yourTable WHERE myTable.key = yourTable.key

as follows:

RWDBTable myTable = dBase.table("myTable");
RWDBTable yourTable = dBase.table("yourTable");
RWDBSelector select = dBase.selector();
select << myTable["name"] << yourTable["city"];
select.where(myTable["key"] == yourTable["key"]);
RWDBCriterion where() const
Base class for a family of classes that represent the abstract notion of a database table in a number...
Definition table.h:89

Notice that it is not necessary to specify the FROM clause. The DB Interface Module deduces what tables to select from the column references in the select list; it generates a member of the FROM clause for each unique table reference. You can override this behavior by using the from(), fromGeneration(), and fromExtern() member functions.

Assuming that the name and city columns mentioned above are strings, we would read the results of our query like this:

RWCString name;
RWCString city;
while (rdr()) {
rdr >> name >> city;
// process the name and city
}
Offers powerful and convenient facilities for manipulating strings.
Definition stdcstring.h:826
Provides row-by-row access to tabular data.
Definition reader.h:136
RWDBReader reader(size_t cacheSize=0) const
Definition select.h:950

Example 2

To introduce multiple instances of a table into an encapsulated SELECT statement, declare additional RWDBTable instances. The fragment:

SELECT a.name, b.type from myTable a, myTable b

can be captured as in the following example:

RWDBTable aTable = myDbase.table("myTable");
RWDBTable bTable = myDbase.table("myTable");
RWDBSelector select = myDbase.selector();
select << aTable["name"] << bTable["type"];

Note that the instantiations of aTable and bTable do not require database access, so this technique does not incur excessive overhead.

Example 3

This example introduces the binding of application variables within a WHERE clause of a SELECT statement. This allows an application to repeatedly execute the RWDBSelector without clearing and constructing the WHERE clause each time. The following example uses an AutoParts table in the database, with text column name and integer column id:

RWDBTable partsTable = myDbase.table("AllParts");
RWDBConnection connection = myDbase.connection();
RWDBSelector select = myDbase.selector();
int id = 1001;
select << partsTable["name"];
select.where(partsTable["id"] == RWDBBoundExpr(&id));
// process reader...
id = 2001;
reader = select.reader(connection);
// process reader...
Acts as a placeholder in a dynamic SQL statement, providing a type-safe interface for binding a local...
Definition expr.h:935
Represents an explicit database connection object that can be used in place of the implicit database ...
Definition connect.h:81

Member Enumeration Documentation

◆ FromGeneration

A class-scoped enum presents different behaviors that can be used to compose the FROM clause. It is used in the fromGeneration() methods. Please refer to the Section "Composing FROM clause" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide, for detailed information.

Enumerator
ExplicitOrImplicit 

If there are any explicit from() entries, uses only those to generate the FROM clause, otherwise uses only implicit entries.

ExplicitAndImplicit 

Combines the implicit and explicit entries to generate the FROM clause, removing duplicate entries.

Constructor & Destructor Documentation

◆ RWDBSelector() [1/2]

RWDBSelector::RWDBSelector ( )

The default constructor creates an RWDBSelector whose status is RWDBStatus::notInitialized. This constructor is provided as a convenience, for example, for declaring an array of RWDBSelector objects. Usable RWDBSelector instances are obtained from RWDBDatabase.

◆ RWDBSelector() [2/2]

RWDBSelector::RWDBSelector ( const RWDBSelector & select)

Copy constructor. The created object shares an implementation with select.

Member Function Documentation

◆ asString() [1/4]

RWCString RWDBSelector::asString ( ) const
inline

Returns the SQL equivalent of:

SELECT <column-list> FROM <from-list>
WHERE <where-clause> GROUP BY <groupby-list>
HAVING <having-clause> ORDER BY <orderby-list>

This method returns an SQL statement that would be produced by executing self with an implicit RWDBConnection object. An implicit RWDBConnection object inherits the time zone setting from the producer RWDBDatabase instance. Hence, the time zone setting of the producer RWDBDatabase object will be used for creating the string representations of any RWDateTime instances in self.

The behavior of this method depends upon the RWDBDatabase::verboseAsString() setting in the producer RWDBDatabase instance.

  • If verboseAsString() is false, the SQL returned is the same as that passed to the database for execution. This is the default.
  • If verboseAsString() is true, any placeholders in the returned SQL are replaced with their bound values.
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 this method with RWDBDatabase::verboseAsString() set to true will result in a string with blob data returned as hex numbers, such as 0x0A32F5.
See also
RWDBDatabase::timeZone(const RWZone*) for time zone setting on RWDBDatabase.

◆ asString() [2/4]

RWCString RWDBSelector::asString ( bool verbose) const
inline

Returns the SQL equivalent of:

SELECT <column-list> FROM <from-list>
WHERE <where-clause> GROUP BY <groupby-list>
HAVING <having-clause> ORDER BY <orderby-list>

This method returns an SQL statement that would be produced by executing self with an implicit RWDBConnection object. An implicit RWDBConnection object inherits the time zone setting from the producer RWDBDatabase instance. Hence, the time zone setting of the producer RWDBDatabase object will be used for creating the string representations of any RWDateTime instances in self.

The behavior of this method depends on the value of verbose, and is independent of the RWDBDatabase::verboseAsString() setting.

  • If verbose is false, the SQL returned is the same as that passed to the database for execution.
  • If verbose is true, any placeholders in the returned SQL are replaced with their bound values although the SQL passed to the database for execution will not be affected.
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 this method with verbose as true will result in a string with blob data returned as hex numbers, such as 0x0A32F5.
See also
RWDBDatabase::timeZone(const RWZone*) for time zone setting on RWDBDatabase.

◆ asString() [3/4]

RWCString RWDBSelector::asString ( const RWDBConnection & conn) const
inline

Returns the SQL equivalent of:

SELECT <column-list> FROM <from-list>
WHERE <where-clause> GROUP BY <groupby-list>
HAVING <having-clause> ORDER BY <orderby-list>

This method returns an SQL statement that would be produced by executing self with conn. The time zone setting of conn will be used for creating string representations of any RWDateTime instances in self.

The behavior of this method depends upon the RWDBDatabase::verboseAsString() setting in the producer RWDBDatabase instance.

  • If verboseAsString() is false, the SQL returned is the same as that passed to the database for execution. This is the default.
  • If verboseAsString() is true, any placeholders in the returned SQL are replaced with their bound values.
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 this method with RWDBDatabase::verboseAsString() set to true will result in a string with blob data returned as hex numbers, such as 0x0A32F5.
See also
RWDBConnection::timeZone(const RWZone*) for time zone setting on RWDBConnection.

◆ asString() [4/4]

RWCString RWDBSelector::asString ( const RWDBConnection & conn,
bool verbose ) const
inline

Returns the SQL equivalent of:

SELECT <column-list> FROM <from-list>
WHERE <where-clause> GROUP BY <groupby-list>
HAVING <having-clause> ORDER BY <orderby-list>

This method returns an SQL statement that would be produced by executing self with conn. The time zone setting of conn will be used for creating string representations of any RWDateTime instances in self.

The behavior of this method depends on the value of verbose, and is independent of the RWDBDatabase::verboseAsString() setting.

  • If verbose is false, the SQL returned is the same as that passed to the database for execution.
  • If verbose is true, any placeholders in the returned SQL are replaced with their bound values although the SQL passed to the database for execution will not be affected.
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 this method with verbose as true will result in a string with blob data returned as hex numbers, such as 0x0A32F5.
See also
RWDBConnection::timeZone(const RWZone*) for time zone setting on RWDBConnection.

◆ bulkReader()

RWDBBulkReader RWDBSelector::bulkReader ( const RWDBConnection & conn) const
inline

Returns an RWDBBulkReader able to read the result set associated with the rows of self. The RWDBBulkReader executes using the supplied connection.

◆ clear()

RWDBStatus RWDBSelector::clear ( )
inline

Clears self's clauses, selection lists, and internal controls.

◆ column() [1/3]

RWDBColumn RWDBSelector::column ( const RWCString & name) const
inline

Returns a deep copy of the first RWDBColumn in self's schema whose name matches the given name. If no matching column is found, returns an RWDBColumn whose status is RWDBStatus::columnNotFound. A deep copy is made so that applications can modify the returned RWDBColumn without modifying self's schema.

◆ column() [2/3]

RWDBColumn RWDBSelector::column ( const RWCString & name,
RWCString::caseCompare caseCompare ) const
inline

Returns a deep copy of the first RWDBColumn in self's schema whose name matches the given name. If no matching column is found, returns an RWDBColumn whose status is RWDBStatus::columnNotFound. A deep copy is made so that applications can modify the returned RWDBColumn without modifying self's schema. The caseCompare argument toggles case sensitivity when comparing column names. Valid arguments are RWCString::exact and RWCString::ignoreCase.

◆ column() [3/3]

RWDBColumn RWDBSelector::column ( size_t index) const
inline

Returns a deep copy of the RWDBColumn in self's schema at the given index. If index is out of range, returns an RWDBColumn with status RWDBStatus::invalidPosition. A deep copy is made so that applications can modify the returned RWDBColumn without modifying self's schema.

◆ cursor() [1/4]

RWDBCursor RWDBSelector::cursor ( const RWDBConnection & connection,
RWDBCursor::CursorType type = RWDBCursor::Sequential,
RWDBCursor::CursorAccess access = RWDBCursor::Read ) const
inline

Produces an RWDBCursor for execution of the SQL statement encapsulated by self. The cursor is created on the supplied database connection, using the type and access specifications provided. The connection is held by the RWDBCursor until the RWDBCursor is destroyed. This function can behave asynchronously if executed using an asynchronous connection.

◆ cursor() [2/4]

RWDBCursor RWDBSelector::cursor ( const RWDBSchema & updateCols,
const RWDBConnection & connection,
RWDBCursor::CursorType type = RWDBCursor::Sequential,
RWDBCursor::CursorAccess access = RWDBCursor::Read ) const
inline

Produces an RWDBCursor for execution of the SQL statement encapsulated by self. The cursor is created on the supplied database connection, using the type and access specifications provided. The connection is held by the RWDBCursor until the RWDBCursor is destroyed. The argument updateCols is used in building a clause:

FOR UPDATE OF column-name, column-name, ...

Some SQL dialects require this form. This function can behave asynchronously if executed using an asynchronous connection.

◆ cursor() [3/4]

RWDBCursor RWDBSelector::cursor ( const RWDBSchema & updateCols,
RWDBCursor::CursorType type = RWDBCursor::Sequential,
RWDBCursor::CursorAccess access = RWDBCursor::Read ) const
inline

Produces an RWDBCursor for execution of the SQL select statement encapsulated by self. The argument updateCols is used in building a clause:

FOR UPDATE OF column-name, column-name, ...

Some SQL dialects require this form. The cursor is created on a default database connection, using the type and access specifications provided. The connection is held by the RWDBCursor until the RWDBCursor is destroyed.

◆ cursor() [4/4]

Produces an RWDBCursor for execution of the SQL select statement encapsulated by self. The cursor is created on a default database connection, using the type and access specifications provided. The connection is held by the RWDBCursor until the RWDBCursor is destroyed.

◆ database()

RWDBDatabase RWDBSelector::database ( ) const
inline

Returns the RWDBDatabase that produced this selector. If there is no such object, for example, if this selector was created using the default constructor, returns an RWDBDatabase with a status of RWDBStatus::notInitialized.

◆ difference()

virtual RWDBCompoundSelector RWDBSelector::difference ( const RWDBSelectorBase & selector) const
virtual

Returns an RWDBCompoundSelector that represents the SQL selector:

select-stmt DIFFERENCE selector

where select-stmt is the SELECT statement represented by self.

Reimplemented from RWDBSelectorBase.

◆ distinct()

RWDBSelector & RWDBSelector::distinct ( bool logic = true)

By default, adds the DISTINCT SQL keyword to the select statement encapsulated by self. If logic is specified as false, removes the DISTINCT keyword if it is present. Returns a reference to self.

◆ execute() [1/2]

RWDBResult RWDBSelector::execute ( )
inline

Uses a default database connection to submit the SQL SELECT statement encapsulated by self for execution. There will always be one or more RWDBTable objects in the returned RWDBResult.

◆ execute() [2/2]

RWDBResult RWDBSelector::execute ( const RWDBConnection & connection)
inline

Uses the supplied connection to submit the SQL SELECT statement encapsulated by self for execution. There will always be one or more RWDBTable objects in the returned RWDBResult. This function can behave asynchronously if executed using an asynchronous connection.

◆ fetchSchema() [1/2]

bool RWDBSelector::fetchSchema ( )
inline

Executes the SQL statement associated with self, then populates self's internal schema with the result set, that is, the columns in the table that resulted from the execution of the SQL statement. This function returns true if successful.

To obtain schema information, the DB Interface Module uses a default database connection to query the database. If no schema can be obtained, this function returns false.

◆ fetchSchema() [2/2]

bool RWDBSelector::fetchSchema ( const RWDBConnection & connection)
inline

Executes the SQL statement associated with self, then populates self's internal schema with the result set, that is, the columns in the table that resulted from the execution of the SQL statement. This function returns true if successful.

To obtain schema information, the DB Interface Module uses the supplied connection to query the database. If no schema can be obtained, this function returns false.

◆ from() [1/3]

RWDBSelector & RWDBSelector::from ( const RWCString & tableName)

Adds tableName to self's explicit FROM list. Normally, RWDBSelector has no explicit FROM clause. It can deduce which tables to query from the column references in its select list. By using the from() method, you can manipulate default FROM clause generation and cause an explicit FROM list to be maintained. Each call to from() adds an entry to the explicit FROM list. The explicit FROM list can be used by itself or combined with the default implicit list, depending on the fromGeneration() setting. This is explained in detail in the Section "Composing FROM clause" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide. Returns a reference to self.

◆ from() [2/3]

RWDBSelector & RWDBSelector::from ( const RWDBJoinExpr & jExpr)

Adds jExpr to self's explicit FROM list. This method is used for adding outer join constructs to the FROM clause. Each call to from() adds an entry to the explicit FROM list. See the Section on "Outer Joins" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide and the RWDBJoinExpr entry in this Reference Guide for information on generating appropriate outer join constructs. The FROM clause generation is explained in detail in the Section "Composing FROM clause" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide. Returns a reference to self.

◆ from() [3/3]

RWDBSelector & RWDBSelector::from ( const RWDBTable & table)

Adds name of table to self's explicit FROM list. Normally, RWDBSelector has no explicit FROM clause. It can deduce which tables to query from the column references in its select list. By using the from() method, you can manipulate default FROM clause generation and cause an explicit FROM list to be maintained. Each call to from() adds an entry to the explicit FROM list. The explicit FROM list can be used by itself or combined with the default implicit list, depending on the fromGeneration() setting. This is explained in detail in the Section "Composing FROM clause" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide. Returns a reference to self.

◆ fromClear()

RWDBSelector & RWDBSelector::fromClear ( )

Clears self's explicit FROM list. See from() for an explanation of implicit and explicit FROM clauses. This is also explained in detail in the Section "Composing FROM clause" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide. Returns a reference to self.

◆ fromExtern()

RWDBSelector & RWDBSelector::fromExtern ( const RWDBTable & table)

Declares table as an externally defined table and hence to not be included in the self's FROM clause. Each call to fromExtern() adds an entry to self's extern table list. This method is especially useful in forming correlated SQLs in which the correlated subquery references a table defined in the outer SQL. The FROM clause generation and correlated subqueries are explained in detail in the Section "Composing FROM clause" and the Section "Subqueries" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide. Returns a reference to self.

◆ fromExternClear()

RWDBSelector & RWDBSelector::fromExternClear ( )

Clears self's extern table list. See fromExtern() for an explanation of the extern table list. The FROM clause generation is explained in detail in the Section "Composing FROM clause" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide. Returns a reference to self.

◆ fromGeneration() [1/2]

FromGeneration RWDBSelector::fromGeneration ( ) const

Returns self's FROM clause generation behavior. Class-scoped enum FromGeneration defines the behaviors in which to generate self's FROM clause from the implicit and explicit FROM entries. The default behavior is ExplicitOrImplicit. The FROM clause generation is explained in detail in the Section "Composing FROM clause" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide.

◆ fromGeneration() [2/2]

RWDBSelector & RWDBSelector::fromGeneration ( FromGeneration flag)

Sets self's FROM clause generation behavior. Class-scoped enum FromGeneration defines the behavior in generating self's FROM clause from the implicit and explicit FROM entries. The default behavior is ExplicitOrImplicit. The FROM clause generation is explained in detail in the Section "Composing FROM clause" in the Chapter "The Data Manipulation Classes" in the DB Interface Module User's Guide. Returns a reference to self.

◆ groupBy() [1/3]

RWDBSelector & RWDBSelector::groupBy ( const RWDBColumn & column)

Specifies column as a GROUP BY column for self. A select statement may have multiple GROUP BY columns; successive calls to groupBy() add GROUP BY columns to self. The order of groupBy() calls is retained. Returns a reference to self.

◆ groupBy() [2/3]

RWDBSelector & RWDBSelector::groupBy ( const RWDBExpr & expr)

Specifies expr as a GROUP BY <expression> for self. A select statement may have multiple GROUP BY expressions; successive calls to groupBy() add GROUP BY expressions to self. The order of groupBy() calls is retained. Returns a reference to self.

◆ groupBy() [3/3]

RWDBSelector & RWDBSelector::groupBy ( int columnNumber)

Specifies columnNumber as a GROUP BY column for self. A select statement may have multiple GROUP BY columns; successive calls to groupBy() add GROUP BY columns to self. The order of groupBy() calls is retained. Returns a reference to self.

◆ groupByClear()

RWDBSelector & RWDBSelector::groupByClear ( )

Clears self's GROUP BY clause. Returns a reference to self.

◆ having()

RWDBSelector & RWDBSelector::having ( const RWDBCriterion & criterion)

Specifies criterion as self's HAVING clause. If self already has a HAVING clause, this method replaces it. This method is most often used in conjunction with groupBy(). Returns a reference to self.

◆ intersection()

virtual RWDBCompoundSelector RWDBSelector::intersection ( const RWDBSelectorBase & selector) const
virtual

Returns an RWDBCompoundSelector that represents the SQL selector:

select-stmt INTERSECTION selector

where select-stmt is the SELECT statement represented by self.

Reimplemented from RWDBSelectorBase.

◆ into()

RWDBSelector & RWDBSelector::into ( const RWCString & tableName)

Specifies the INTO clause of a select statement. If self already has an INTO clause, this method replaces it. A blank tableName removes the clause from self. If self's database does not support SELECT INTO, the DB Interface Module does not attempt to emulate this functionality. In such cases this method sets self's status to RWDBStatus::notSupported. Returns a reference to self.

◆ isValid()

bool RWDBSelector::isValid ( ) const
inline

Returns true if self's status is RWDBStatus::ok, otherwise returns false. Does not return false if the previous executed statement failed. You must check the status of the RWDBResult returned from execute() instead of the status of the RWDBSelector object.

◆ on() [1/2]

RWDBSelector & RWDBSelector::on ( const RWDBColumn & column)
Deprecated
As of SourcePro 1, use RWDBJoinExpr::on(const RWDBColumn&) to add a column to the SQL USING clause of a specific RWDBJoinExpr.

Adds the column to the SQL USING clause of the first RWDBJoinExpr attached to self using the from() method. Returns a reference to self.

◆ on() [2/2]

RWDBSelector & RWDBSelector::on ( const RWDBCriterion & criterion)
Deprecated
As of SourcePro 1, use RWDBJoinExpr::on(const RWDBCriterion&) to attach a join condition to a specific RWDBJoinExpr.

Attaches the criterion as an SQL ON clause to the first RWDBJoinExpr attached to self using the from() method. If the first RWDBJoinExpr already has an ON clause, this method replaces it. Returns a reference to self.

◆ operator<<() [1/3]

RWDBSelector & RWDBSelector::operator<< ( const RWDBExpr & expr)

The insertion operator adds an item to self's select list. The supplied expr may be made up of constants, column references, predefined functions, or RWDBSelector instances, combined with arithmetic or functional operators. See RWDBExpr. Returns a reference to self.

◆ operator<<() [2/3]

RWDBSelector & RWDBSelector::operator<< ( const RWDBTable & table)

Use this method to specify SELECT * FROM table. Returns a reference to self.

◆ operator<<() [3/3]

RWDBSelector & RWDBSelector::operator<< ( RWDBValueManip manip)

The insertion operator adds manip to self's select list. Returns a reference to self.

◆ operator=()

RWDBSelector & RWDBSelector::operator= ( const RWDBSelector & select)

Assignment operator. Self shares an implementation with select. Returns a reference to self.

◆ operator[]() [1/2]

RWDBColumn RWDBSelector::operator[] ( const RWCString & name) const
inline

Returns a deep copy of the first RWDBColumn in self's schema whose name matches the given name. If no matching column is found, returns an RWDBColumn whose status is RWDBStatus::columnNotFound. A deep copy is made so that applications can modify the returned RWDBColumn without modifying self's schema.

◆ operator[]() [2/2]

RWDBColumn RWDBSelector::operator[] ( size_t position) const
inline

Returns a deep copy of the RWDBColumn in self's schema whose position matches the given position. If no matching column is found, returns an RWDBColumn whose status is RWDBStatus::columnNotFound. A deep copy is made so that the application can modify the returned RWDBColumn without modifying self's schema.

◆ orderBy() [1/3]

RWDBSelector & RWDBSelector::orderBy ( const RWDBColumn & column)

Specifies column as an ORDER BY column for self. A select statement may have multiple ORDER BY columns; successive calls to orderBy() and orderByDescending() add ORDER BY columns to self. The order of orderBy() and orderByDescending() calls is retained. Returns a reference to self.

◆ orderBy() [2/3]

RWDBSelector & RWDBSelector::orderBy ( const RWDBExpr & expr)

Specifies expr as an ORDER BY <expression> for self. A select statement may have multiple ORDER BY expressions; successive calls to orderBy() and orderByDescending() add ORDER BY expressions to self. The order of orderBy() and orderByDescending() calls is retained. Returns a reference to self.

◆ orderBy() [3/3]

RWDBSelector & RWDBSelector::orderBy ( int columnNumber)

Specifies columnNumber as an ORDER BY column for self. A select statement may have multiple ORDER BY columns; successive calls to orderBy() and orderByDescending() add ORDER BY columns to self. The order of orderBy() and orderByDescending() calls is retained. Returns a reference to self.

◆ orderByClear()

RWDBSelector & RWDBSelector::orderByClear ( )

Clears self's ORDER BY clause. Returns a reference to self.

◆ orderByDescending() [1/2]

RWDBSelector & RWDBSelector::orderByDescending ( const RWDBColumn & column)

Specifies column as an ORDER BY DESCENDING column for self. A select statement may have multiple ORDER BY columns; successive calls to orderBy() and orderByDescending() add ORDER BY columns to self. The order of orderBy() and orderByDescending() calls is retained. Returns a reference to self.

◆ orderByDescending() [2/2]

RWDBSelector & RWDBSelector::orderByDescending ( int columnNumber)

Specifies columnNumber as an ORDER BY DESCENDING column for self. A select statement may have multiple ORDER BY columns; successive calls to orderBy() and orderByDescending() add ORDER BY columns to self. The order of orderBy() and orderByDescending() calls is retained. Returns a reference to self.

◆ reader() [1/2]

RWDBReader RWDBSelector::reader ( const RWDBConnection & connection,
size_t cacheSize = 0 ) const
inline

Produces an RWDBReader that can be used to read data from self one row at a time. Uses the supplied connection, which is held by the RWDBReader until the RWDBReader is destroyed. This function can behave asynchronously if executed using an asynchronous connection.

Note
When cacheSize is 0, an acceptable default is selected by your Access Module. Please check your Access Module documentation for limitations on the cache size.

◆ reader() [2/2]

RWDBReader RWDBSelector::reader ( size_t cacheSize = 0) const
inline

Produces an RWDBReader that can be used to read data from self one row at a time. Uses a default database connection which is held by the RWDBReader until the RWDBReader is destroyed.

Note
When cacheSize is 0, an acceptable default is selected by your Access Module. Please check your Access Module documentation for limitations on the cache size.

◆ schema()

RWDBSchema RWDBSelector::schema ( ) const
inline

Returns a deep copy of self's RWDBSchema. The copy is made so that an application can modify the returned RWDBSchema without modifying self's schema. The schema is empty until self's fetchSchema() method is called.

◆ select() [1/2]

RWDBSelector & RWDBSelector::select ( const RWDBExpr & expr)

This is a synonym for *this << expr. Returns a reference to self.

◆ select() [2/2]

RWDBSelector & RWDBSelector::select ( const RWDBTable & table)

This is a synonym for *this << table. Returns a reference to self.

◆ selectClear()

RWDBSelector & RWDBSelector::selectClear ( )

Clears self's select list. Returns a reference to self.

◆ setErrorHandler()

void RWDBSelector::setErrorHandler ( RWDBStatus::ErrorHandler handler)
inline

Installs handler as self's error handler. The supplied handler is inherited by all objects produced by self. By default, an RWDBStatus::ErrorHandler is inherited from the object that produced self; this method overrides the default.

◆ status()

RWDBStatus RWDBSelector::status ( ) const
inline

Returns the status of self.

◆ union_()

virtual RWDBCompoundSelector RWDBSelector::union_ ( const RWDBSelectorBase & selector) const
virtual

Returns an RWDBCompoundSelector that represents the SQL selector:

select-stmt UNION selector

where select-stmt is the SELECT statement represented by self. The trailing underscore is to avoid conflict with the C++ union keyword.

Reimplemented from RWDBSelectorBase.

◆ unionAll()

virtual RWDBCompoundSelector RWDBSelector::unionAll ( const RWDBSelectorBase & selector) const
virtual

Returns an RWDBCompoundSelector which represents the SQL selector:

select-stmt UNION ALL selector

where select-stmt is the SELECT statement represented by self.

Reimplemented from RWDBSelectorBase.

◆ where() [1/2]

RWDBCriterion RWDBSelector::where ( ) const

Returns a copy of self's RWDBCriterion, an encapsulated SQL WHERE clause. Returns an empty RWDBCriterion if self has no WHERE clause.

◆ where() [2/2]

RWDBSelector & RWDBSelector::where ( const RWDBCriterion & criterion)

Specifies criterion as self's SQL WHERE clause. If self already has a WHERE clause, this method replaces it. Returns a reference to self.

Friends And Related Symbol Documentation

◆ operator*()

RWDBCompoundSelector operator* ( const RWDBSelectorBase & left,
const RWDBSelectorBase & right )
related

Intersection. Equivalent to

left.intersection(right);

◆ operator+()

RWDBCompoundSelector operator+ ( const RWDBSelectorBase & left,
const RWDBSelectorBase & right )
related

Union. Equivalent to

left.union_(right);

◆ operator-()

RWDBCompoundSelector operator- ( const RWDBSelectorBase & left,
const RWDBSelectorBase & right )
related

Difference. Equivalent to

left.difference(right);

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.