SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWDBSearchedCaseExpr Class Reference

Used to build searched CASE expressions. More...

#include <rw/db/expr.h>

Inheritance diagram for RWDBSearchedCaseExpr:
RWDBExpr

Public Member Functions

 RWDBSearchedCaseExpr ()
 
 RWDBSearchedCaseExpr (const RWDBSearchedCaseExpr &searchedCaseExpr)
 
void else_ (const RWDBExpr &elseExpr)
 
RWDBSearchedCaseExproperator= (const RWDBSearchedCaseExpr &searchedCaseExpr)
 
void when (const RWDBCriterion &whenCrit, const RWDBExpr &thenExpr)
 
- Public Member Functions inherited from RWDBExpr
 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 wchar_t *value)
 
 RWDBExpr (const RWCString &value)
 
 RWDBExpr (const RWDecimalPortable &value)
 
 RWDBExpr (const RWDateTime &value)
 
 RWDBExpr (const RWDBDateTime &value)
 
 RWDBExpr (const RWDBDuration &value)
 
 RWDBExpr (const RWDate &value)
 
 RWDBExpr (const RWTime &value)
 
 RWDBExpr (const RWDBBlob &value)
 
 RWDBExpr (const RWBasicUString &value)
 
 RWDBExpr (const RWDBMBString &value)
 
 RWDBExpr (const RWWString &value)
 
 RWDBExpr (const RWDBValue &value, bool usePhraseBook=true)
 
 RWDBExpr (const RWDBColumn &column)
 
 RWDBExpr (const RWDBSelectorBase &subSelect)
 
 RWDBExpr (RWDBValueManip manip)
 
 RWDBExpr (const RWCollection &collection)
 
 RWDBExpr (const RWDBTable &)
 
 RWDBExpr (const RWDBColumn &left, const RWDBExpr &right)
 
 RWDBExpr (const RWDBColumn &left, const RWDBValue &right)
 
RWCString asString (const RWDBPhraseBook &phraseBook, AsStringControlFlag control=normal) const
 
RWDBCriterion between (const RWDBExpr &expression1, const RWDBExpr &expression2) const
 
RWDBCriterion in (const RWDBExpr &expression1) const
 
RWDBCriterion isNull (void) const
 
bool isValid (void) const
 
RWDBCriterion leftOuterJoin (const RWDBExpr &expression) const
 
RWDBCriterion like (const RWDBExpr &expression1) const
 
RWDBCriterion matchUnique (const RWDBExpr &expression1) const
 
RWDBExproperator= (const RWDBExpr &expr)
 
RWDBCriterion rightOuterJoin (const RWDBExpr &expression) const
 

Additional Inherited Members

- Public Types inherited from RWDBExpr
enum  AsStringControlFlag { normal, suppressTagsOnColumns, noPlaceHolder, placeHolderNotRecommended }
 

Detailed Description

RWDBSearchedCaseExpr represents a specialized type of RWDBExpr used to specify a searched SQL CASE expression.

Synopsis
#include <rw/db/expr.h>
See also
RWDBSearchedCaseExpr is a special case of RWDBExpr. See RWDBExpr for more details.
Example
In this example, an RWDBSearchedCaseExpr is constructed. The instance adds several WHEN expressions and an ELSE expression, then is finally inserted into the SELECT list.
// SELECT c1,
// (CASE WHEN c2 = 'NameA' THEN c1 * 2 WHEN c2 = 'NameB' THEN c1 * 5 ELSE c1 * 10 END)
// FROM table1
// ORDER BY c2
// Instantiate a table object to represent the table.
RWDBTable t1 = aDatabase.table("table1");
// Instantiate a column object to represent the first column.
RWDBColumn c1 = t1["c1"];
// Instantiate a column object to represent the second column.
RWDBColumn c2 = t1["c2"];
// Instantiate searched CASE expression.
// Add two WHEN clauses that specify a boolean equation to be evaluated.
caseExpr.when(c2 == "NameA", RWDBExpr(c1) * 2);
caseExpr.when(c2 == "NameB", RWDBExpr(c1) * 5);
// Add an ELSE expression that is evaluated if all WHEN clauses
// do not match.
caseExpr.expr_(c1 * 10);
// Instantiate a selector to represent a CASE query.
RWDBSelector aSel = db.selector();
// Add column 1 and the CASE expression to the SELECT list.
aSel << c1 << caseExpr;
// Specify an ORDER BY clause to order on column 2.
aSel.orderBy(c2);

Constructor & Destructor Documentation

RWDBSearchedCaseExpr::RWDBSearchedCaseExpr ( )

The default constructor builds a RWDBSearchedCaseExpr.

RWDBSearchedCaseExpr::RWDBSearchedCaseExpr ( const RWDBSearchedCaseExpr searchedCaseExpr)

Copy constructor. The created RWDBSearchedCaseExpr shares an implementation with searchedCaseExpr.

Member Function Documentation

void RWDBSearchedCaseExpr::else_ ( const RWDBExpr elseExpr)

Specifies the ELSE expression for self as elseExpr. If self already has an ELSE clause, this method replaces it.

RWDBSearchedCaseExpr& RWDBSearchedCaseExpr::operator= ( const RWDBSearchedCaseExpr searchedCaseExpr)

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

void RWDBSearchedCaseExpr::when ( const RWDBCriterion whenCrit,
const RWDBExpr thenExpr 
)

Appends a WHEN/THEN clause to self where the argument whenCrit encapsulates the WHEN condition, and the argument thenExpr encapsulates the THEN return expression.

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