Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWDBStoredProc



Data Type and Member Function Indexes
(exclusive of constructors and destructors)

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 implementations vary widely among RDBMS vendors. If an RWDBStoredProc feature is not supported by the underlying database, DBTools.h++ reports an RWDBStatus::notSupported error. The remainder of this section assumes that all features are supported. Check the DBTools.h++ access library 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 needs to obtain 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 status of the RWDBStoredProc 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, DBTools.h++ passes along whatever the database reports to the application. DBTools.h++ 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, DBTools.h++ passes along whatever the database reports to the application.

In order to support parameter passing, DBTools.h++ 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 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 Classes

RWDBValueManip rwdbNull;

Public Constructors

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 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<< (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<< (RWDBDateTime* valPtr); 
RWDBStoredProc&
operator<< (RWDBDuration* valPtr); 
RWDBStoredProc&
operator<< (RWDBBlob* valPtr); 
RWDBStoredProc&
operator<< (RWCString* valPtr); 
RWDBStoredProc& 
operator<<(RWDBMBString* valPtr);
RWDBStoredProc& 
operator<<(RWWString* valPtr);
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);
RWBoolean
exists(RWBoolean forceLookup = FALSE) const;
RWBoolean
exists(const RWDBConnection& connection, 
       RWBoolean forceLookup = FALSE) const;
RWDBStatus
fetchReturnParams();
RWBoolean
isNull(size_t index) const;
RWBoolean
isNull(const RWCString& name) const;
RWBoolean
isNull(const RWDBColumn& column) const;
RWBoolean
isReady() const;
RWBoolean
isValid() const;
RWCString
name() const;
RWDBSchema
params(RWBoolean forceLookup = FALSE) const;
RWDBSchema
params(const RWDBConnection& connection, 
       RWBoolean forceLookup = FALSE) const;
void
release() const;
RWDBValue
returnValue() const;
void
setErrorHandler(RWDBStatus::ErrorHandler handler);
RWDBStatus
status() const;
RWCString
text(RWBoolean forceLookup = FALSE) const;
RWCString
text(const RWDBConnection& connection, 
     RWBoolean forceLookup = FALSE) const;


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.