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

RWDBOSql

Module:  DB Interface Module   Group:  Open SQL Classes


Does not inherit

Local Index

Members

Synopsis

#include <rw/db/osql.h>

Description

Class RWDBOSql is an encapsulation of a database-specific SQL statement with all its input and output bindings. Program variables may be bound to placeholders in your statement using operator <<, and shifting in RWDBAbstractBuffers, such as RWDBTBuffers, which describe input data. Class RWDBOSql also contains a vector of RWDBMultiRows, each of which specifies the output bindings for a single result set. You can use the RWDBOSql operator[] to obtain a reference to an RWDBMultiRow, and then use the RWDBMultiRow operator>> to provide output bindings for the RWDBMultiRow.

When executing an RWDBOSql that produces results, there are two options for specifying the output RWDBAbstractBuffers for those results:

RWDBOSql is designed around the Interface/Implementation paradigm. An RWDBInserter instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation.

Example 1

In this example, we use an RWDBOSql to execute a query with a placeholder. The input value and output storage are both specified using RWDBTBuffer. Please note that Oracle-specific placeholder syntax is used here; check your Access Module guide or vendor documentation for appropriate SQL and placeholder syntax.

Example 2

In this example, we use an RWDBOSql to execute a user-supplied ad hoc query. We then use an RWDBMultiRow to fetch the results.

Example 3

In this example, we use an RWDBOSql to execute a stored procedure that has one input parameter and one output parameter. The input value and output storage are both specified using RWDBTBuffer. Please note that Oracle-specific placeholder syntax is used here; check your access module guide or vendor-specific documentation for appropriate SQL and placeholder syntax.

Public Enum

enum StatementType { NonQuery = 0, Query, Procedure };
enum CancelType { Current = 0, All }

Public Constructors

RWDBOSql();
RWDBOSql(const RWCString & sql, 
         StatementType type = NonQuery);
RWDBOSql(const RWDBOSql& osql);

Public Destructor

~RWDBOSql();

Public Member Operators

RWDBOSql& 
operator=(const RWDBOSql& osql);
RWDBOSql&
operator<<(RWDBAbstractBuffer& input);
RWDBMultiRow& 
operator[](size_t index);

Public Member Functions

RWDBOSql& 
cancel(CancelType tp);

NOTE -- This call is only valid after the RWDBOSql is executed. Calling cancel() before execute() invalidates the RWDBOSql, setting an RWDBStatus::invalidUsage error, and calling any associated error handler.
RWDBStatus::errorHandler 
errorHandler() const;
void
execute(RWDBConnection& cn, size_t blkSz=0);
RWDBOSql&
fetch();

NOTE -- This call is only valid after the RWDBOSql is executed. Calling fetch() before execute() invalidates the RWDBOSql, setting an RWDBStatus::invalidUsage error, and calling any associated error handler.
RWDBOSql& 
fetchReturnParams();
bool
hasResult() const; 
bool
isReady() const;
bool
isValid() const;
RWDBValue 
returnValue() const;
long 
rowCount() const;

NOTE -- This method is deprecated. Please use the method rowsAffected().
long
rowsAffected() const;
long 
rowsFetched() const;
RWDBSchema
schema() const;
void 
setErrorHandler(RWDBStatus::ErrorHandler err);
RWCString
statement() const;
RWDBOSql& 
statement(const RWCString& sql, 
          StatementType type = NonQuery); 
RWDBStatus 
status() const;
StatementType 
type() const;


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.