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

RWDBStoredProc

Module:  DB Interface Module   Group:  Database Classes


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/db/stored.h>

RWDBStoredProc myProc = myDbase.storedProc("myProcName");

Description

Many modern RDBMS implementations include a mechanism to enforce database policy through stored procedures. Applications may be required to do much of their data manipulation through stored procedures. Unfortunately, the standards bodies have had little to say about stored procedures, so stored procedure implementations vary widely among RDBMS vendors. If an RWDBStoredProc feature is not supported by the underlying database, SourcePro Core reports an RWDBStatus::notSupported error. The remainder of this section assumes that all features are supported. Check the SourcePro Core Access Module guide for information about what features are supported by a particular database.

RWDBStoredProc is an encapsulation of a database stored procedure. RWDBStoredProc supports creating and deleting stored procedures, retrieving stored procedures definitions, executing stored procedures, and processing results returned from stored procedure execution. Parameters may be passed to an RWDBStoredProc prior to execution, and the values of output parameters may be retrieved. If a database vendor's stored procedure may return multiple sets of results, RWDBStoredProc can access each result set in turn.

RWDBStoredProc uses an RWDBSchema to store information about its formal parameters. Use the insertion operator << to pass actual parameters to an RWDBStoredProc. Insert values if the stored procedure expects IN parameters; insert pointers if the stored procedure expects OUT or IN/OUT parameters and your application is interested in obtaining results through the parameters. Insert rwdbNull to pass a literal NULL by value.


NOTE -- It is an error to insert a NULL pointer; if this occurs the RWDBStoredProc's status changes to RWDBStatus::nullReference.

RWDBStoredProc maintains a notion of the current position in its parameter list. The current position is set to zero when the RWDBStoredProc is created, and reset to zero whenever the RWDBStoredProc is executed. Each insertion of an actual parameter increments the current position by one. The indexing operator [ ] can be used to access a particular parameter position by number or by name. Given a stored procedure myStoredProc which expects the parameters number and name in that order, the following notations are equivalent:

RWDBStoredProc does not check actual parameters for type; it allows the database to do type conversion. If there is a type incompatibility, the DB Interface Module passes along whatever the database reports to the application. The DB Interface Module produces an RWDBStatus::invalidPosition error if too many arguments are inserted into an RWDBStoredProc. No check is made for too few arguments. The database may supply defaults; if not, the DB Interface Module passes along whatever the database reports to the application.

In order to support parameter passing, the DB Interface Module uses a connection to query the database for schema information whenever an RWDBStoredProc is produced by an RWDBDatabase.

RWDBStoredProc is designed around the Interface/Implementation paradigm. An RWDBStoredProc instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation. An RWDBStoredProc object's implementation is a base class from which a family of database-specific selector implementations is derived.

Example

In this example, suppose there is a database procedure getId, which expects two parameters: name, an input string representing a customer's name, and id, an output integer parameter representing the customer's id. The procedure is supposed to look up the customer id for the given customer name. If successful, it places the id in its id parameter and returns 0. Otherwise it returns -1 and does not change id.

Related Objects

RWDBValueManip rwdbNull;

Public Constructor

RWDBStoredProc();
RWDBStoredProc(const RWDBStoredProc& proc);

Public Member Operators

RWDBStoredProc&
operator=(const RWDBStoredProc& proc);
RWDBStoredProc&
operator[](size_t index);
RWDBStoredProc&
operator[](const RWCString& paramName);
RWDBStoredProc&
operator[](const RWDBColumn& paramColumn);
RWDBStoredProc& 
operator<<(char value); 
RWDBStoredProc& 
operator<<(unsigned char value); 
RWDBStoredProc&
operator<<(short value); 
RWDBStoredProc& 
operator<<(unsigned short value); 
RWDBStoredProc& 
operator<<(int value); 
RWDBStoredProc& 
operator<<(unsigned int value); 
RWDBStoredProc& 
operator<<(long value); 
RWDBStoredProc& 
operator<<(unsigned long value); 
RWDBStoredProc& 
operator<<(float value); 
RWDBStoredProc& 
operator<<(double value); 
RWDBStoredProc& 
operator<<(const RWDecimalPortable& value); 
RWDBStoredProc&
operator<<(const RWDate& value);
RWDBStoredProc&
operator<<(const RWDateTime& value); 
RWDBStoredProc&
operator<<(const RWDBDateTime& value); 
RWDBStoredProc&
operator<<(const RWDBDuration& value); 
RWDBStoredProc&
operator<<(const RWCString& value); 
RWDBStoredProc&
operator<<(const RWDBBlob& value); 
RWDBStoredProc& 
operator<<(const RWDBMBString& value);
RWDBStoredProc& 
operator<<(const RWWString& value);
RWDBStoredProc& 
operator<<(RWDBValueManip value); 
RWDBStoredProc& 
operator<<(const RWDBValue& value);
RWDBStoredProc& 
operator<<(const RWBasicUString& value); 

NOTE -- This function accepts Unicode strings. For more information, see the entry for RWBasicUString in the Essential Tools Module Reference Guide. For more information on internationalization, see Chapter 12 of the DB Interface Module User's Guide.
RWDBStoredProc&
operator<< (short* valPtr); 
RWDBStoredProc&
operator<< (unsigned short* valPtr); 
RWDBStoredProc&
operator<< (int* valPtr); 
RWDBStoredProc&
operator<< (unsigned int* valPtr); 
RWDBStoredProc&
operator<< (long* valPtr); 
RWDBStoredProc&
operator<< (unsigned long* valPtr); 
RWDBStoredProc&
operator<< (float* valPtr); 
RWDBStoredProc&
operator<< (double* valPtr); 
RWDBStoredProc&
operator<< (RWDecimalPortable* valPtr); 
RWDBStoredProc&
operator<< (RWDate* valPtr);
RWDBStoredProc&
operator<<(RWDateTime* valPtr); 
RWDBStoredProc&
operator<< (RWDBDateTime* valPtr); 
RWDBStoredProc&
operator<< (RWDBDuration* valPtr); 
RWDBStoredProc&
operator<< (RWDBBlob* valPtr); 
RWDBStoredProc&
operator<< (RWCString* valPtr); 
RWDBStoredProc& 
operator<<(RWDBMBString* valPtr);
RWDBStoredProc& 
operator<<(RWWString* valPtr);
RWDBStoredProc&
operator<<(RWBasicUString* valPtr);

NOTE -- This function accepts Unicode strings. For more information, see the entry for RWBasicUString in the Essential Tools Module Reference Guide. For more information on internationalization, see Chapter 12 of the DB Interface Module User's Guide.
RWDBStoredProc&
operator<<(const RWDBBoundExpr&  boundexpr);

Public Member Functions

void
acquire() const;
RWDBStatus
clear();
RWDBDatabase
database() const;
RWDBStatus 
drop();
RWDBStatus 
drop(const RWDBConnection& connection);
RWDBStatus::ErrorHandler
errorHandler() const;
RWDBResult
execute();
RWDBResult
execute(const RWDBConnection& connection);
bool
exists(bool forceLookup = false) const;
bool
exists(const RWDBConnection& connection, 
       bool forceLookup = false) const;
RWDBStatus
fetchReturnParams();
bool
isNull(size_t index) const;
bool
isNull(const RWCString& name) const;
bool
isNull(const RWDBColumn& column) const;
bool
isReady() const;
bool
isValid() const;
RWCString
name() const;
RWDBSchema
params(bool forceLookup = false) const;
RWDBSchema
params(const RWDBConnection& connection, 
       bool forceLookup = false) const;
void
release() const;
RWDBValue
returnValue() const;
void
setErrorHandler(RWDBStatus::ErrorHandler handler);
RWDBStatus
status() const;
RWCString
text(bool forceLookup = false) const;
RWCString
text(const RWDBConnection& connection, 
     bool forceLookup = false) 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.