RWDBBoundExpr RWDBExpr
None
#include <rw/db/expr.h>
RWDBBoundExpr is a specialized type of RWDBExpr that is evaluated as a placeholder within a dynamic SQL statement. It provides a type-safe interface for allowing applications to bind a local variable and an optional null indicator to a dynamic SQL statement.
In this example, an RWDBBoundExpr is created and shifted into an RWDBInserter. The RWDBInserter is then executed several times after changing the bound local variable.
RWDBConnection connection = myDbase.connection(); RWDBTable myTable = myDbase.table("myTable"); RWDBInserter inserter = myDbase.inserter( myTable ); RWDBNullIndicator nullIndicator = 0; float avg = .453; inserter << RWDBBoundExpr(&avg, &nullIndicator); inserter.execute( connection ); // Insert .453. nullIndicator = RWDBNullIndicator(TRUE); // Set to true. inserter.execute( connection ); // Insert Null. nullIndicator = RWDBNullIndicator(FALSE); // Set to false. avg = .329; inserter.execute( connection ); // Insert .329
Notice that an explicit connection is used for each execution of the RWDBInserter. It is the application's responsibility to insure that the bound local variable and the RWDBNullIndicator pointed at by the optional null indicator remain in scope for all executions.
RWDBBoundExpr can be used in conjunction with any of the other expression classes and operators, such as RWDBAssignment.
Other classes that use RWDBBoundExpr include RWDBSelector, RWDBDeleter, RWDBInserter, and RWDBUpdater.
RWDBBoundExpr();
The default constructor builds an empty RWDBBoundExpr. An empty RWDBBoundExpr is one whose method:
asString(const RWDBPhraseBook& phraseBook)
returns an SQL NULL keyword, as specified in phraseBook.
RWDBBoundExpr(short* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(unsigned short* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(int* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(unsigned int* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(long* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(unsigned long* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(float* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(double* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(RWCString* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(RWDecimalPortable* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(RWDate* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(RWDBDateTime* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(RWDBDuration* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(RWDBBlob* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(RWDBMBString* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1); RWDBBoundExpr(RWWString* valuePtr, RWDBNullIndicator* nullIndicator = NULL, size_t entries = 1);
Creates an RWDBBoundExpr from the given value, and an optional pointer to a null indicator. Sets entries to 1, where entries is the number of entries that valuePtr and nullIndicator point to, and 1 is the only currently supported value.
When the asString method expands in the context of a dynamic SQL statement, the RWDBBoundExpr becomes a placeholder, with syntax that varies among access libraries. The application's value and the dynamic SQL statement are then considered bound. If the optional pointer to a null indicator is passed, the bound value is treated as NULL when the value pointed at by nullIndicator is nonzero.
NOTE:In previous versions of DBTools.h++, the null indicator parameters were of type RWBoolean. This type is now changed to RWDBNullIndicator.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.