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

RWDBExpr

Module:  DB Interface Module   Group:  Expression Classes


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/db/expr.h>

Description

RWDBExpr represents expressions used in constructing SQL statements. It allows the SQL to be constructed using C++ syntax. Because there are several types of expressions, this class is simply an interface to a family of implementations that can represent numeric and string constants, columns from tables, or other expressions. By its nature, an RWDBExpr can actually represent a complete complex expression in the form of a parse tree.

Because instances of this class are typically created anonymously, there are constructors taking the various operands used in expressions. These include the C++ primitive types, as well as the structured types used by the DB Interface Module, such as RWCString and RWDBColumn.

RWDBExpr is designed around the Interface/Implementation paradigm. An RWDBExpr instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation.

Example

In this example, an RWDBExpr is created anonymously to be used as part of an SQL SELECT statement. The intent is to create a selector that adds the value of the program variable x to each value selected.

Related Classes

RWDBAssignment is a special kind of expression used to encapsulate the SQL phrase:

SET column = expression.

RWDBAssignment instances are produced by the method RWDBColumn::assign() .

RWDBBoundExpr is used to bind application variables to an SQL statement.

RWDBCollectableExpr derives from RWDBExpr and RWCollectable.

RWDBPhraseBook is used to store database-specific SQL syntax.

RWDBCriterion is a special kind of expression used to encapsulate an SQL WHERE clause. It is formed from RWDBExprs connected with logical operators.

RWDBExprFormDefinition provides an extensible mechanism that allows application programmers to define their own functional SQL notation.

RWDBJoinExpr is used to construct ANSI SQL join syntax.

Public Enum

enum AsStringControlFlag 
{ normal, suppressTagsOnColumns, noPlaceHolder  }

Public Constructors

RWDBExpr();
RWDBExpr(const RWDBExpr& expr);
RWDBExpr(char value);
RWDBExpr(unsigned char value);
RWDBExpr(short value);
RWDBExpr(unsigned short value);
RWDBExpr(int value);
RWDBExpr(unsigned int value);
RWDBExpr(long int value);
RWDBExpr(unsigned long int value);
RWDBExpr(long long value);
RWDBExpr(unsigned long long value);
RWDBExpr(float value);
RWDBExpr(double value);
RWDBExpr(long double value);
RWDBExpr(const char* value);
RWDBExpr(const RWDBMBString& value);
RWDBExpr(const RWWString& value);
RWDBExpr(const wchar_t* value);
RWDBExpr(const RWBasicUString& value);

NOTE -- This function accepts Unicode strings. For more information, see the entry for RWBasicUString in the Essential Tools Module Reference Guide and Chapter 13, "Internationalization," in the DB Interface Module User's Guide.
RWDBExpr(const RWDBValue& value, 
         bool usePhraseBook = true);
RWDBExpr(const RWDBColumn& column);
RWDBExpr(const RWDBColumn& left, const RWDBValue& right);
RWDBExpr(const RWDBColumn& left, const RWDBExpr& right);
RWDBExpr(const RWDateTime& value);
RWDBExpr(const RWCString& value);
RWDBExpr(const RWDecimalPortable& value);
RWDBExpr(const RWDBDateTime& value);
RWDBExpr(const RWDBDuration& value);
RWDBExpr(const RWDate& value);
RWDBExpr(const RWTime& value);
RWDBExpr(const RWDBBlob& value);
RWDBExpr(const RWDBSelectorBase& subQuery);
RWDBExpr(RWDBValueManip manip);
RWDBExpr(const RWCollection& collection);
RWDBExpr(const RWDBExpr& left, 
         RWDBPhraseBook::RWDBPhraseKey op,
         const RWDBExpr& right);
RWDBExpr(const RWDBTable& aTable);

Public Member Operator

RWDBExpr&
operator=(const RWDBExpr& expr);

Public Member Functions

RWCString
asString (const RWDBPhraseBook& phraseBook, 
          AsStringControlFlag control = normal)const;
RWDBCriterion
between(const RWDBExpr& expression1, 
        const RWDBExpr& expression2) const;
RWDBPhraseBook::RWDBPhraseKey 
getOperator() const;
RWDBCriterion
in(const RWDBExpr& expression) const;
RWDBCriterion 
isNull()const;
bool 
isValid() const;
RWDBCriterion
leftOuterJoin(const RWDBExpr& expression) const;
RWDBCriterion
like(const RWDBExpr& expression) const;
RWDBCriterion
matchUnique(const RWDBExpr& expression) const;
RWDBCriterion
rightOuterJoin(const RWDBExpr& expression) const;

Related Global Operators

Arithmetic operators may be applied to RWDBExpr instances to build complex RWDBExprs. Logical operators may be applied to produce an RWDBCriterion.

RWDBExpr
operator+(const RWDBExpr&, const RWDBExpr&);
RWDBExpr
operator+(const RWDBExpr&);
RWDBExpr
operator-(const RWDBExpr&, const RWDBExpr&);
RWDBExpr
operator-(const RWDBExpr&);
RWDBExpr
operator*(const RWDBExpr&, const RWDBExpr&);
RWDBExpr
operator/(const RWDBExpr&, const RWDBExpr&);
RWDBExpr
operator%(const RWDBExpr&, const RWDBExpr&);
RWDBCriterion
operator&&(const RWDBCriterion&, const RWDBCriterion&);
RWDBCriterion
operator||(const RWDBCriterion&, const RWDBCriterion&);
RWDBCriterion
operator!(const RWDBCriterion&);
RWDBCriterion
operator==(const RWDBExpr&, const RWDBExpr&);
RWDBCriterion
operator!=(const RWDBExpr&, const RWDBExpr&);
RWDBCriterion
operator>(const RWDBExpr&, const RWDBExpr&);
RWDBCriterion
operator<(const RWDBExpr&, const RWDBExpr&);
RWDBCriterion
operator>=(const RWDBExpr&, const RWDBExpr&);
RWDBCriterion
operator<=(const RWDBExpr&, const RWDBExpr&);

Related Global Functions

These functions may be applied to RWDBExpr instances to build RWDBExprs representing SQL functions.The SQL syntax for these functions typically varies among the various vendors' implementations. The DB Interface Module hides the variations by providing the database-specific syntax at runtime.

The DB Interface Module also provides an extensible mechanism for applications to define their own functional notation. See RWDBExprFormDefinition.

RWDBExpr
rwdbAvg(const RWDBExpr& expr);
RWDBExpr
rwdbCast(const RWDBExpr& expr, const RWDBValue& type);
RWDBExpr 
rwdbCast(const RWDBExpr& expr, const RWDBValue& typeName,
         const RWDBExpr& formatString);
RWDBExpr 
rwdbCast(const RWDBExpr& expr, 
         const RWDBValue& typeName,
         const RWDBExpr& formatString, 
         const RWDBExpr& secondaryFormat);
RWDBExpr 
rwdbCharLength (const RWDBExpr& expr);
RWDBExpr
rwdbCount(const RWDBExpr& expr);
RWDBExpr 
rwdbCount();
RWDBExpr 
rwdbCountDistinct (const RWDBExpr& expr);
RWDBExpr 
rwdbCurrentUser ();
RWDBCriterion
rwdbExists(const RWDBSelectorBase& select);
RWDBExpr
rwdbLower(const RWDBExpr& expr);
RWDBExpr
rwdbMax(const RWDBExpr& expr);
RWDBExpr
rwdbMin(const RWDBExpr& expr);
RWDBExpr
rwdbName(const RWCString& name, const RWDBExpr& expr);
RWDBExpr
rwdbPosition(const RWDBExpr& expr1,const RWDBExpr& expr2);
RWDBExpr
rwdbSessionUser();
RWDBExpr
rwdbSubString(const RWDBExpr& expr1, const RWDBExpr& expr2);
RWDBExpr
rwdbSubString(const RWDBExpr& expr1, 
              const RWDBExpr& expr2,
              const RWDBExpr& expr3);
RWDBExpr
rwdbSum(const RWDBExpr& expr);
RWDBExpr
rwdbSystemDateTime();
RWDBExpr
rwdbSystemUser();
RWDBExpr
rwdbTrimLeading(const RWDBExpr& expr1,
                const RWDBExpr& expr2);
RWDBExpr
rwdbTrimTrailing(const RWDBExpr& expr1, 
                 const RWDBExpr& expr2);
RWDBExpr
rwdbTrimBoth(const RWDBExpr& expr1, const RWDBExpr& expr2);
RWDBExpr
rwdbUpper(const RWDBExpr& expr);


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.