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

5.9 asString() Methods in the Data Manipulation Classes

The asString() methods in RWDBInserter, RWDBUpdater, RWDBDeleter, RWDBSelector and RWDBCompoundSelector provide the SQL representation of self. Note that these methods do not actually access the database, so there is no performance hit.

Each class contains these asString() methods:

They return the SQL statement generated by the DB Interface Module in either of the following formats:

The first method RWCString asString() returns a string that depends on the verboseAsString() setting of the related RWDBDatabase instance. See RWDBDatabase for more information.

The next method RWCString asString(bool verbose) returns a string that depends on verbose and is therefore independent of the verboseAsString() setting of the RWDBDatabase instance.

For more information on the asString() methods and their application, see RWDBInserter, RWDBUpdater, RWDBDeleter, RWDBSelector, and RWDBCompoundSelector in the SourcePro C++ API Reference Guide.

The following table and example illustrate the behavior of the asString() method given various settings.

Table 7: Output of asString() in various true/ false scenarios

The asString() method called Setting of RWDBDatabase::verboseAsString() Generated Output
asString(false) true or false SQL as sent to the database
asString(true) true or false Placeholders in the SQL replaced by bound values
asString() true Placeholders in the SQL replaced by bound values
asString() false SQL as sent to the database

Example 6: asString() Method

Output

//1

Adds an integer and an RWCString to the inserter.

//2

Sets the verboseAsString setting of the producing RWDBDatabase myDbase to false.

//3

The RWDBDatabase::verboseAsString setting is ignored, and any placeholders in the returned SQL are replaced with the data.

//4

The RWDBDatabase::verboseAsString setting is ignored, and the SQL returned is the same as that which would be sent to the database if the RWDBInserter object insert were executed.

//5

The verboseAsString() setting is used. Since the setting is false, the SQL returned is the same as that which would be sent to the database if the RWDBInserter object insert were executed.

//6

Sets the verboseAsString() setting of the producing RWDBDatabase, myDbase, to true.

//7

The RWDBDatabase::verboseAsString() setting is ignored, and any placeholders in the returned SQL are replaced with the data.

//8

The verboseAsString() setting is ignored, and the SQL returned is the same as that sent to the database when insert is executed.

//9

The verboseAsString() setting is used. Since the setting is true, any placeholders in the returned SQL will be replaced with the data.


A similar enhancement in RWDBTracer allows traced SQL statements with the placeholders to be replaced by the bound data values. See RWDBTracer in the SourcePro C++ API Reference Guide for more information.



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.