Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWDBExpr



Data Type and Member Function Indexes
(exclusive of constructors and destructors)

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 DBTools.h++, 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(float value);
RWDBExpr(double value);
RWDBExpr(const char* value);
RWDBExpr(const RWDBMBString& value);
RWDBExpr(const RWWString& value);
RWDBExpr(const wchar_t* value);
RWDBExpr(const RWDBValue& value, 
         RWBoolean usePhraseBook = TRUE);
RWDBExpr(const RWDBColumn& column);
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);

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;
RWBoolean 
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. DBTools.h++ hides the variations by providing the database-specific syntax at runtime.

DBTools.h++ also provides an extensible mechanism for applications to define their own functional notation. See RWDBExprFormDefinition for details.

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 DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.