SourcePro® 2022.1 |
SourcePro® API Reference Guide |
A C++ representation of expressions used in constructing SQL statements. More...
#include <rw/db/expr.h>
Public Types | |
enum | AsStringControlFlag { normal, suppressTagsOnColumns, noPlaceHolder, placeHolderNotRecommended } |
Public Member Functions | |
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 |
RWDBExpr & | operator= (const RWDBExpr &expr) |
RWDBCriterion | rightOuterJoin (const RWDBExpr &expression) const |
RWDBExpr represents expressions used in constructing SQL statements, allowing 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, it has 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.
This class has a number of related global functions that may be applied to RWDBExpr instances to build RWDBExpr objects 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.
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 stores database-specific SQL syntax.
RWDBCriterion is a special kind of expression used to encapsulate an SQL WHERE
clause. It is formed from RWDBExpr instances connected with logical operators.
RWDBExprFormDefinition provides an extensible mechanism that allows application programmers to define their own functional SQL notation.
RWDBJoinExpr constructs ANSI SQL join syntax.
RWDBSimpleCaseExpr constructs simple CASE
expressions.
RWDBSearchedCaseExpr constructs searched CASE
expressions.
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.
This enum
holds values to format asString() output.
RWDBExpr::RWDBExpr | ( | ) |
The default constructor builds an empty RWDBExpr, that is, one whose asString() method returns an SQL NULL
keyword, as specified in its parameter phraseBook
. Since an empty expression cannot hold a value, RWDBExpr() cannot be used as NULL
value.
RWDBExpr::RWDBExpr | ( | const RWDBExpr & | expr | ) |
Copy constructor. Self shares an implementation with expr.
RWDBExpr::RWDBExpr | ( | char | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | unsigned char | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | short | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | unsigned short | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | int | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | unsigned int | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | long int | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | unsigned long int | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | long long | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | unsigned long long | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | float | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | double | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | long double | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | const char * | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | const wchar_t * | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | const RWDecimalPortable & | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | const RWDateTime & | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | const RWDBDateTime & | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | const RWDBDuration & | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | const RWBasicUString & | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | const RWDBMBString & | value | ) |
Creates an RWDBExpr from the given value.
RWDBExpr::RWDBExpr | ( | const RWDBValue & | value, |
bool | usePhraseBook = true |
||
) |
Creates an RWDBExpr from an RWDBValue. When the asString() function is applied to this RWDBExpr, it passes its phraseBook
parameter on to the RWDBValue for interpretation. Passing false
for the usePhraseBook parameter suppresses this behavior. The effect of suppressing the use of the phraseBook
is to prevent strings from being quoted and RWDateTime instances from using the database's designated format.
RWDBExpr::RWDBExpr | ( | const RWDBColumn & | column | ) |
Creates an RWDBExpr from the column reference.
RWDBExpr::RWDBExpr | ( | const RWDBSelectorBase & | subSelect | ) |
Creates an RWDBExpr from an RWDBSelector or RWDBCompoundSelector. This constructor supports the SQL subquery construct.
RWDBExpr::RWDBExpr | ( | RWDBValueManip | manip | ) |
RWDBExpr::RWDBExpr | ( | const RWCollection & | collection | ) |
Creates an RWDBExpr that represents a delimited list of the items in collection. The parameter collection must be a collection of RWDBCollectableExpr instances. collection must remain in scope for the entire period that the RWDBExpr can be referenced, since the expression is not expanded into a string until the asString() method is called, which can happen long after you assign the collectable to the expression.
RWDBExpr::RWDBExpr | ( | const RWDBColumn & | left, |
const RWDBExpr & | right | ||
) |
Creates an RWDBExpr that represents an encapsulation of the SQL expression:
left = right
where left is the name of the column and right is the expression against which to compare.
RWDBExpr::RWDBExpr | ( | const RWDBColumn & | left, |
const RWDBValue & | right | ||
) |
Creates an RWDBExpr that represents an encapsulation of the SQL expression:
left = right
where left is the name of the column and right is the value against which to compare.
RWCString RWDBExpr::asString | ( | const RWDBPhraseBook & | phraseBook, |
AsStringControlFlag | control = normal |
||
) | const |
Returns an RWCString representing self as a string based on the format found in phraseBook. Normally, references to columns in self are represented in the string with table tags attached. Setting the value of control with RWDBExpr::suppressTagsOnColumns prevents the tags from being included in the string.
RWDBCriterion RWDBExpr::between | ( | const RWDBExpr & | expression1, |
const RWDBExpr & | expression2 | ||
) | const |
Returns an RWDBCriterion that represents an encapsulation of the SQL clause:
expression BETWEEN
expression1 AND
expression2
where expression refers to self. RWDBCriterion encapsulates SQL WHERE
clauses.
RWDBCriterion RWDBExpr::in | ( | const RWDBExpr & | expression1 | ) | const |
Returns an RWDBCriterion that represents an encapsulation of the SQL phrase:
expression IN
expression1
where expression refers to self. An RWDBCriterion is an encapsulation of an SQL WHERE
clause. For example, to produce the SQL clause (shown using Oracle placeholder syntax):
we could write:
To produce the SQL clause:
we could write:
Alternatively, we could write:
false
in the constructor for the RWDBExpr above is required in order to suppress quotation marks in the resultant SQL string. RWDBCriterion RWDBExpr::isNull | ( | void | ) | const |
Returns an RWDBCriterion that represents an encapsulation of the SQL clause:
expression IS NULL
where expression refers to self. An RWDBCriterion is an encapsulation of an SQL WHERE
clause.
bool RWDBExpr::isValid | ( | void | ) | const |
Returns true
if self is not an empty (null) expression.
RWDBCriterion RWDBExpr::leftOuterJoin | ( | const RWDBExpr & | expression | ) | const |
Returns an RWDBCriterion that represents an encapsulation of the LEFT OUTER JOIN
SQL phrase. An RWDBCriterion is an encapsulation of an SQL WHERE
clause.
RWDBCriterion RWDBExpr::like | ( | const RWDBExpr & | expression1 | ) | const |
Returns an RWDBCriterion that represents an encapsulation of the SQL clause:
expression LIKE
expression1
where expression refers to self. For example, to produce the SQL clause:
we would write:
RWDBCriterion RWDBExpr::matchUnique | ( | const RWDBExpr & | expression1 | ) | const |
Returns an RWDBCriterion that represents an encapsulation of the SQL clause:
expression MATCH UNIQUE
expression1
where expression refers to self.
Assignment operator. Self shares an implementation with expr.
RWDBCriterion RWDBExpr::rightOuterJoin | ( | const RWDBExpr & | expression | ) | const |
Returns an RWDBCriterion that represents an encapsulation of the RIGHT OUTER JOIN
SQL phrase. An RWDBCriterion is an encapsulation of an SQL WHERE
clause.
|
related |
Returns an RWDBCriterion representing a monadic expression with the operator !
(not).
|
related |
Returns an RWDBCriterion representing a dyadic expression between two subexpressions with the !=
(inequality) operator.
Returns an RWDBExpr representing a dyadic expression between two subexpressions with the %
(modulo) operator.
|
related |
Returns an RWDBCriterion representing a dyadic expression between two subexpressions with &&
(and) as the operator, if both operands are initialized. If only one operand is initialized, returns an RWDBCriterion representing a monadic expression.
Returns an RWDBExpr representing a dyadic expression between two subexpressions with *
(multiply) as the operator.
Returns an RWDBExpr representing a dyadic expression between two subexpressions with +
(plus) as the operator.
Returns an RWDBExpr representing a monadic expression with +
(plus) as the operator.
Returns an RWDBExpr representing a dyadic expression between two subexpressions with -
(minus) as the operator.
Returns an RWDBExpr representing a monadic expression with -
(minus) as the operator.
Returns an RWDBExpr representing a dyadic expression between two sub-expressions with /
(divide) as the operator.
|
related |
Returns an RWDBCriterion representing a dyadic expression between two subexpressions with the <
(less than) operator.
|
related |
Returns an RWDBCriterion representing a dyadic expression between two subexpressions with the <=
(less than or equal to) operator.
|
related |
Returns an RWDBCriterion representing a dyadic expression between two subexpressions with the ==
(equality) operator.
|
related |
Returns an RWDBCriterion representing a dyadic expression between two subexpressions with the >
(greater than) operator.
|
related |
Returns an RWDBCriterion representing a dyadic expression between two subexpressions with the >=
(greater than or equal to) operator.
|
related |
Returns an RWDBCriterion representing a dyadic expression between two subexpressions with ||
(or) as the operator, if both operands are initialized. If only one operand is initialized, returns an RWDBCriterion representing a monadic expression.
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
AVERAGE
(expr)
|
related |
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
CAST
(expr, typeName, formatString, secondaryFormat)
For example, to produce the SQL phrase:
where the last parameter is a database-specific directive to use French style formatting, write:
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
CHARACTER_LENGTH
(expr)
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
COUNT
(expr)
|
related |
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
COUNT(*)
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
COUNT
DISTINCT
(expr)
|
related |
Returns an RWDBExpr representing the database-specific function that returns the name of the current user.
|
related |
Returns an RWDBCriterion representing the database-specific equivalent of the SQL expression
EXISTS
(<select-statement>).
In this expression, <select-statement> is the SQL select statement encapsulated by select.
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
TOLOWER
(expr)
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
MAX
(expr)
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
MIN
(expr)
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
POSITION
(expr1, expr2)
The goal is to produce an SQL statement that gives the index of the string expr1 in expr2.
|
related |
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
SESSION_USER()
The details of the SESSION_USER()
function are vendor-specific.
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
SUBSTRING
(expr1, expr2)
The goal is to produce an SQL statement that gives the substring of expr1 starting at the index given by expr2.
|
related |
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
SUBSTRING
(expr1, expr2, expr3)
The goal is to produce an SQL statement that gives the substring of expr1 starting at the index given by expr2, with length given by expr3.
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
SUM
(expr)
|
related |
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
SYSTEM_DATETIME()
|
related |
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
SYSTEM_USER()
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
TRIM_BOTH
(expr1, expr2)
where expr1 represents the character to trim and expr2 represents the string expression to be trimmed.
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
TRIM_LEADING
(expr1, expr2)
where expr1 represents the character to trim and expr2 represents the string expression to be trimmed.
Returns an RWDBExpr representing the database-specific equivalent of the SQL function:
TRIM_TRAILING
(exp1, expr2)
where expr1 represents the character to trim and expr2 represents the string expression to be trimmed.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |