Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

ODBCPreparedStatement Class Reference

#include <ODBCPreparedStatement.h>

Inheritance diagram for ODBCPreparedStatement:

Inheritance graph
[legend]
Collaboration diagram for ODBCPreparedStatement:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual ~ODBCPreparedStatement ()
void SetNull (Int_t parameterIndex, Int_t sqlType)
void SetBoolean (Int_t parameterIndex, Bool_t x)
void SetByte (Int_t parameterIndex, Char_t x)
void SetShort (Int_t parameterIndex, Short_t x)
void SetInt (Int_t parameterIndex, Int_t x)
void SetLong (Int_t parameterIndex, Long_t x)
void SetFloat (Int_t parameterIndex, Float_t x)
void SetDouble (Int_t parameterIndex, Double_t x)
void SetString (Int_t parameterIndex, const TString &x)
void SetBytes (Int_t parameterIndex, const TArrayC &x)
void SetDate (Int_t parameterIndex, const TSQLDate &x)
void SetTime (Int_t parameterIndex, const TSQLTime &x)
void SetTimestamp (Int_t parameterIndex, const TSQLTimestamp &x)
void SetAsciiStream (Int_t parameterIndex, TBuffer *x, Int_t length)
void SetBinaryStream (Int_t parameterIndex, TBuffer *x, Int_t length)
void SetObject (Int_t parameterIndex, TObject *x)
void ClearParameters ()
virtual Bool_t Execute (const TString &sql="")
virtual TSQLResultSetExecuteQuery (const TString &sql="")
virtual Int_t ExecuteUpdate (const TString &sql="")
TSQLResultSetGetResultSet ()
Bool_t GetMoreResults ()
void Close ()
void Cancel ()
Int_t GetMaxFieldSize ()
void SetMaxFieldSize (Int_t max)
Int_t GetMaxRows ()
void SetMaxRows (Int_t max)
Bool_t GetEscapeProcessing ()
void SetEscapeProcessing (Bool_t enable=kTRUE)
Int_t GetQueryTimeout ()
void SetQueryTimeout (Int_t seconds)
Int_t GetUpdateCount ()
void SetCursorName (const TString &name)
void AddBatch (const TString &sql)
void ClearBatch ()
Int_t * ExecuteBatch ()
Int_t GetFetchDirection ()
void SetFetchDirection (Int_t direction)
Int_t GetFetchSize ()
void SetFetchSize (Int_t rows)
Int_t GetResultSetConcurrency ()
Int_t GetResultSetType ()

Protected Methods

 ODBCPreparedStatement (TSQLConnection *con, void *imp=0)

Friends

class ODBCConnection

Constructor & Destructor Documentation

ODBCPreparedStatement::ODBCPreparedStatement TSQLConnection   con,
void *    imp = 0
[protected]
 

ODBCPreparedStatement::~ODBCPreparedStatement   [virtual]
 

Definition at line 85 of file ODBCPreparedStatement.cxx.

References TSQLStatement::fCurrentResult, TSQL::fImp, ODBCXX_STRING_CSTR, and TSQL::Throw().

00086 {
00087    // dtor
00088 
00089    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00090  
00091    try { 
00092       if(imp) delete  imp;   
00093    } catch(odbc::SQLException& e) {
00094       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00095                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00096                                 e.getErrorCode()) );
00097    }
00098 
00099   // implementation part of fCurrentResult is deleted with statement
00100    if(fCurrentResult) ((ODBCResultSet*)fCurrentResult)->fImp = 0;
00101    fImp = 0;
00102 }


Member Function Documentation

void ODBCPreparedStatement::AddBatch const TString &    sql [virtual]
 

Implements TSQLStatement.

Definition at line 1292 of file ODBCPreparedStatement.cxx.

01293 {
01294    // Adds a SQL command to the current batch of commmands for
01295    // the statement. This method is optional.
01296    //
01297    // Parameters:
01298    //       sql - typically this is a static SQL INSERT or UPDATE 
01299    //       statement
01300    // Throws:
01301    //       TSQLException - if a database access error occurs, or 
01302    //       the  driver does not support batch statements
01303 
01304 }

void ODBCPreparedStatement::Cancel   [virtual]
 

Implements TSQLStatement.

Definition at line 1058 of file ODBCPreparedStatement.cxx.

References odbc::Statement::cancel(), TSQL::fImp, ODBCXX_STRING_CSTR, and TSQL::Throw().

01059 {
01060    // Cancels this statement object if both the DBMS and driver 
01061    // support aborting an SQL statement. This method can be used by 
01062    // one thread to cancel a statement that is being executed by 
01063    // another thread.
01064    //
01065    // Throws:
01066    //       TSQLException - if a database access error occurs
01067    
01068    if(!fImp) { Destroyed(); return; }
01069    odbc::Statement* stmt = (odbc::Statement*)fImp;
01070    
01071    try {
01072       stmt->cancel();
01073    } catch(odbc::SQLException& e) {
01074       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
01075                                 ODBCXX_STRING_CSTR(e.getSQLState()),
01076                                 e.getErrorCode()) );
01077    }
01078 }

void ODBCPreparedStatement::ClearBatch   [virtual]
 

Implements TSQLStatement.

Definition at line 1307 of file ODBCPreparedStatement.cxx.

Referenced by Close().

01308 {
01309    // Makes the set of commands in the current batch empty. This
01310    // method is optional.
01311    //
01312    // Throws:
01313    //       TSQLException - if a database access error occurs or 
01314    //       the driver does not support batch statements
01315 
01316 }

void ODBCPreparedStatement::ClearParameters   [virtual]
 

Implements TSQLPreparedStatement.

Definition at line 574 of file ODBCPreparedStatement.cxx.

References odbc::PreparedStatement::clearParameters(), TSQL::fImp, ODBCXX_STRING_CSTR, and TSQL::Throw().

00575 {
00576    // Clears the current parameter values immediately. 
00577    //
00578    //  In general, parameter values remain in force for repeated
00579    //  use of a TSQLStatement. Setting a parameter value 
00580    //  automatically clears its previous value. However, in some 
00581    //  cases it is useful to immediately release the resources used 
00582    //  by the current parameter values; this can be done by calling
00583    //  ClearParameters().
00584    //   
00585    //   Throws:
00586    //         TSQLException - if a database access error occurs
00587    
00588    if(!fImp) { Destroyed();   return; } 
00589    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00590    
00591    try {
00592       imp->clearParameters();
00593 
00594    } catch(odbc::SQLException& e) {
00595       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00596                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00597                                 e.getErrorCode()) );
00598    }
00599 }

void ODBCPreparedStatement::Close   [virtual]
 

Implements TSQLStatement.

Definition at line 1081 of file ODBCPreparedStatement.cxx.

References ClearBatch(), TSQLStatement::fBatches, TSQLStatement::fCurrentResult, TSQL::fImp, ODBCXX_STRING_CSTR, and TSQL::Throw().

01082 {
01083    // Avoid using this method. Use delete ODBCStatement instead.
01084    //
01085    //  Note: When a ODBCStatement is closed, its current 
01086    //       TSQLResultSet,  if one exists, is also closed.
01087    //
01088    //     Throws:
01089    //      TSQLException - if a database access error occurs
01090    
01091    if(!fImp) { Destroyed(); return; }
01092           
01093    try {    
01094       if(fCurrentResult)  { 
01095          delete fCurrentResult;
01096          fCurrentResult = 0;
01097       }
01098       ClearBatch();
01099       SafeDelete(fBatches);
01100 
01101       odbc::Statement* imp = (odbc::Statement*)fImp;
01102       if(imp) delete  imp;
01103    } catch(odbc::SQLException& e) {
01104       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
01105                                 ODBCXX_STRING_CSTR(e.getSQLState()),
01106                                 e.getErrorCode()) );
01107    }
01108    fImp = 0;
01109    Destroyed();
01110 }

Bool_t ODBCPreparedStatement::Execute const TString &    sql = "" [virtual]
 

Implements TSQLStatement.

Definition at line 642 of file ODBCPreparedStatement.cxx.

References TSQL::ClearWarnings(), odbc::PreparedStatement::execute(), odbc::Statement::execute(), TSQL::fImp, ODBCXX_STRING_C, ODBCXX_STRING_CSTR, and TSQL::Throw().

00643 {
00644    // Executes a SQL statement that may return multiple results.
00645    // Under some (uncommon) situations a single SQL statement may 
00646    // return multiple result sets and/or update counts. Normally you 
00647    // can ignore this unless you are (1) executing a stored
00648    // procedure that you know may return multiple results or (2) you 
00649    // are dynamically executing an unknown SQL string. The methods 
00650    // execute, GetMoreResults(), GetResultSet(), and GetUpdateCount()
00651    // let you navigate through multiple results.
00652    //  The execute method executes a SQL statement and indicates the 
00653    // form of the first result. You can then use GetResultSet() or
00654    // GetUpdateCount() to retrieve the result, and GetMoreResults() 
00655    // to move to any subsequent result(s).
00656    //
00657    // Parameters:
00658    //          sql - any SQL statement
00659    // Returns:
00660    //          kTRUE if the next result is a TSQLResultSet; 
00661    //          kFALSE if it is an update count or there are no more
00662    //          results
00663    // Throws:
00664    //            TSQLException - if a database access error occurs
00665    // See Also: 
00666    //       GetResultSet(), GetUpdateCount(), GetMoreResults()
00667   
00668    if(!fImp) { Destroyed(); return kFALSE; }
00669 
00670    Bool_t return_value = kFALSE;
00671    ClearWarnings();
00672    odbc::Statement* stmt = (odbc::Statement*)fImp;
00673    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00674  
00675    try {
00676       if(!sql.IsNull()) {
00677          return_value = (Bool_t)stmt->execute(ODBCXX_STRING_C(sql.Data()));  
00678       } else {
00679          return_value = imp->execute(); 
00680       }
00681    } catch(odbc::SQLException& e) {
00682       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00683                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00684                                 e.getErrorCode()) );
00685       return_value = kFALSE;
00686    }
00687    return return_value;
00688 }

Int_t * ODBCPreparedStatement::ExecuteBatch   [virtual]
 

Implements TSQLStatement.

Definition at line 1319 of file ODBCPreparedStatement.cxx.

01320 {
01321    // Submits a batch of commands to the database for execution.
01322    // This method is optional.
01323    //
01324    // Returns:
01325    //       an array of update counts containing one element for 
01326    //       each command in the batch. The array is ordered 
01327    //       according  to the order in which commands were inserted 
01328    //       into the  batch.
01329    //
01330    // Throws:
01331    //       TSQLException - if a database access error occurs or 
01332    //       the driver  does not support batch statements
01333 
01334    return 0;
01335 }

TSQLResultSet * ODBCPreparedStatement::ExecuteQuery const TString &    sql = "" [virtual]
 

Implements TSQLStatement.

Definition at line 602 of file ODBCPreparedStatement.cxx.

References TSQL::ClearWarnings(), odbc::PreparedStatement::executeQuery(), odbc::Statement::executeQuery(), TSQLStatement::fCurrentResult, TSQL::fImp, ODBCXX_STRING_C, ODBCXX_STRING_CSTR, and TSQL::Throw().

00603 {
00604    // Executes a SQL statement that returns a single TSQLResultSet
00605    //
00606    // This method also implicitly closes current TSQLResultSet 
00607    //
00608    // Returns:
00609    //       a TSLResultSet that contains the data produced by the query; 
00610    //       NULL - in case of error
00611    //
00612    //   Throws:
00613    //       TSQLException - if a database access error occurs
00614 
00615    if(!fImp) { Destroyed(); return 0; }
00616    odbc::Statement* stmt = (odbc::Statement*)fImp;
00617    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;  
00618    odbc::ResultSet* rs = 0; 
00619    ClearWarnings();
00620 
00621    if(fCurrentResult)  delete fCurrentResult;
00622 
00623    try {
00624       if(!sql.IsNull()) {
00625          rs = stmt->executeQuery(ODBCXX_STRING_C(sql.Data()));
00626       } else {
00627          rs = imp->executeQuery();
00628       }
00629    } catch(odbc::SQLException& e) {
00630       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00631                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00632                                 e.getErrorCode()) );
00633       if(rs) delete rs;
00634       fCurrentResult = 0;
00635       return 0;
00636    }
00637    
00638    return fCurrentResult = new ODBCResultSet(this,(void*)rs);;
00639 }

Int_t ODBCPreparedStatement::ExecuteUpdate const TString &    sql = "" [virtual]
 

Implements TSQLStatement.

Definition at line 691 of file ODBCPreparedStatement.cxx.

References TSQL::ClearWarnings(), odbc::PreparedStatement::executeUpdate(), odbc::Statement::executeUpdate(), TSQL::fImp, ODBCXX_STRING_C, ODBCXX_STRING_CSTR, and TSQL::Throw().

00692 {
00693    // Executes an SQL INSERT, UPDATE or DELETE statement. 
00694    // In addition, SQL statements that return nothing, 
00695    // such as SQL DDL statements, can be executed.
00696    //
00697    //  Parameters:
00698    //      sql - a SQL INSERT, UPDATE or DELETE statement or 
00699    //            a SQL statement that  returns nothing
00700    //
00701    //  Returns:
00702    //      either the row count for INSERT, UPDATE or DELETE or 
00703    //      0 for SQL statements that return nothing
00704    //  Throws:
00705    //      TSQLException - if a database access error occurs
00706    
00707    if(!fImp) { Destroyed(); return 0; }
00708 
00709    Int_t return_value = 0;
00710    ClearWarnings();
00711    odbc::Statement* stmt = (odbc::Statement*)fImp;
00712    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00713 
00714    try {
00715       if(!sql.IsNull()) {
00716          return_value = stmt->executeUpdate(ODBCXX_STRING_C(sql.Data()));
00717       } else {
00718          return_value = imp->executeUpdate();
00719       }   
00720    } catch(odbc::SQLException& e) {
00721       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00722                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00723                                 e.getErrorCode()) );
00724       return_value = 0;
00725    }
00726    return return_value;
00727 }

Bool_t ODBCPreparedStatement::GetEscapeProcessing   [virtual]
 

Implements TSQLStatement.

Definition at line 971 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, odbc::Statement::getEscapeProcessing(), ODBCXX_STRING_CSTR, and TSQL::Throw().

00972 {
00973    //  Returns if escape processing is on or off. 
00974    // If escape scanning is on (the default), the driver will do escape 
00975    // substitution before  sending the SQL to the database.
00976    // 
00977    // Note:
00978    //    Since prepared statements have usually been parsed prior to 
00979    //    making this call, disabling escape processing for prepared 
00980    //    statements will have no effect.
00981    //
00982    // Parameters:
00983    //       enable - kTRUE to enable; kFALSE to disable
00984    // Throws:
00985    //       TSQLException - if a database access error occurs
00986 
00987    if(!fImp) { Destroyed(); return kFALSE; }   
00988 
00989    Bool_t return_value = kFALSE;
00990    odbc::Statement* stmt = (odbc::Statement*)fImp;
00991    
00992    try {
00993       return_value = stmt->getEscapeProcessing();
00994    } catch(odbc::SQLException& e) {
00995       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00996                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00997                                 e.getErrorCode()) );
00998       return kFALSE;
00999    }
01000    return return_value;
01001 }

Int_t ODBCPreparedStatement::GetFetchDirection   [virtual]
 

Implements TSQLStatement.

Definition at line 1171 of file ODBCPreparedStatement.cxx.

01172 {
01173    // Retrieves the direction for fetching rows from database
01174    // tables that is the default for result sets generated from this 
01175    // statement object. If this statement object has not set 
01176    // a fetch direction by calling the method SetFetchDirection(), 
01177    // the return value is implementation-specific.
01178    //
01179    // Returns:
01180    //       the default fetch direction for result sets generated 
01181    //       from this statement object
01182    // Throws:
01183    //       TSQLException - if a database access error occurs
01184 
01185    return 0;
01186 }

Int_t ODBCPreparedStatement::GetFetchSize   [virtual]
 

Implements TSQLStatement.

Definition at line 1207 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, odbc::Statement::getFetchSize(), ODBCXX_STRING_CSTR, and TSQL::Throw().

01208 {
01209    // Retrieves the number of result set rows that is the default 
01210    // fetch size for result sets generated from this ODBCStatement 
01211    // object. If this statement object has not set a fetch size
01212    // by calling the method SetFetchSize(), the return value is
01213    // implementation-specific.
01214    //
01215    // Returns:
01216    //       the default fetch size for result sets generated from 
01217    //       this statement object
01218    // Throws:
01219    //       TSQLException - if a database access error occurs
01220    
01221    Int_t return_value = 0;
01222    
01223    if(!fImp) { Destroyed(); return return_value; }
01224    odbc::Statement* stmt = (odbc::Statement*)fImp;
01225    
01226    try {
01227       return_value = stmt->getFetchSize();
01228    } catch(odbc::SQLException& e) {
01229       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
01230                                 ODBCXX_STRING_CSTR(e.getSQLState()),
01231                                 e.getErrorCode()) );
01232       return 0;
01233    }
01234    return return_value;
01235 }

Int_t ODBCPreparedStatement::GetMaxFieldSize   [virtual]
 

Implements TSQLStatement.

Definition at line 831 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, odbc::Statement::getMaxFieldSize(), ODBCXX_STRING_CSTR, and TSQL::Throw().

00832 {
00833    // Returns the maximum number of bytes allowed for any column 
00834    // value. This limit is the maximum number of bytes that can be
00835    // returned for any column value. The limit applies only to 
00836    // kBINARY, kVARBINARY, kLONGVARBINARY, kCHAR, kVARCHAR, and 
00837    // kLONGVARCHAR columns (see TSQLTypes.h). If the limit is exceeded, 
00838    // the excess data  is silently discarded.
00839    //
00840    // Returns:
00841    //    the current max column size limit; zero means unlimited
00842    // Throws:
00843    //    TSQLException - if a database access error occurs
00844 
00845    if(!fImp) { Destroyed(); return 0; }
00846 
00847    Int_t return_value = 0;
00848    odbc::Statement* stmt = (odbc::Statement*)fImp;
00849    
00850    try {
00851       return_value = stmt->getMaxFieldSize();
00852    } catch(odbc::SQLException& e) {
00853       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00854                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00855                                 e.getErrorCode()) );
00856       return 0;
00857    }
00858    return return_value;
00859 }

Int_t ODBCPreparedStatement::GetMaxRows   [virtual]
 

Implements TSQLStatement.

Definition at line 890 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, odbc::Statement::getMaxRows(), ODBCXX_STRING_CSTR, and TSQL::Throw().

00891 {
00892    // Retrieves the maximum number of rows that a TSQLResultSet can 
00893    // contain. If the limit is exceeded, the excess rows are silently 
00894    // dropped.
00895    //
00896    // Returns:
00897    //       the current max row limit; zero means unlimited
00898    // Throws:
00899    //       TSQLException - if a database access error occurs
00900 
00901    if(!fImp) { Destroyed(); return 0; }
00902 
00903    Int_t return_value = 0;
00904    odbc::Statement* stmt = (odbc::Statement*)fImp;
00905    
00906    try {
00907       return_value = stmt->getMaxRows();
00908    } catch(odbc::SQLException& e) {
00909       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00910                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00911                                 e.getErrorCode()) );
00912       return 0;
00913    }
00914    return return_value;
00915 }

Bool_t ODBCPreparedStatement::GetMoreResults   [virtual]
 

Implements TSQLStatement.

Definition at line 797 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, odbc::Statement::getMoreResults(), ODBCXX_STRING_CSTR, and TSQL::Throw().

00798 {
00799    // Moves to a ODBCStatement's next result. It returns kTRUE if 
00800    // this result is a TSQLResultSet. 
00801    // 
00802    // There are no more results when 
00803    //       (!GetMoreResults() && (GetUpdateCount() == -1)
00804    //
00805    // Returns:
00806    //    kTRUE if the next result is a TSQLResultSet; 
00807    //    kFALSE if it is an update count or there are no more results
00808    //
00809    // Throws:
00810    //       TSQLException - if a database access error occurs
00811    // See Also: 
00812    //       Execute(const TString&)
00813 
00814    Bool_t return_value = kFALSE;
00815    
00816    if(!fImp) { Destroyed(); return return_value; }
00817    odbc::Statement* stmt = (odbc::Statement*)fImp;
00818       
00819    try {
00820       return_value = (Bool_t)stmt->getMoreResults();      
00821    } catch(odbc::SQLException& e) {
00822       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00823                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00824                                 e.getErrorCode()) );
00825       return  kFALSE;
00826    }
00827    return return_value;
00828 }

Int_t ODBCPreparedStatement::GetQueryTimeout   [virtual]
 

Implements TSQLStatement.

Definition at line 1004 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, odbc::Statement::getQueryTimeout(), ODBCXX_STRING_CSTR, and TSQL::Throw().

01005 {
01006    // Retrieves the number of seconds the driver will wait for a
01007    // ODBCStatement to execute. If the limit is exceeded, a 
01008    // TSQLException is thrown.
01009    //
01010    // Returns:
01011    //    the current query timeout limit in seconds; zero means
01012    //    unlimited
01013    // Throws:
01014    //    TSQLException - if a database access error occurs
01015    
01016    Int_t return_value = 0;
01017    
01018    if(!fImp) { Destroyed(); return return_value; }
01019    odbc::Statement* stmt = (odbc::Statement*)fImp;
01020       
01021    try {
01022       return_value = stmt->getQueryTimeout();
01023    } catch(odbc::SQLException& e) {
01024       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
01025                                 ODBCXX_STRING_CSTR(e.getSQLState()),
01026                                 e.getErrorCode()) );
01027       return 0;
01028    }
01029    return return_value;
01030 }

TSQLResultSet * ODBCPreparedStatement::GetResultSet   [virtual]
 

Implements TSQLStatement.

Definition at line 730 of file ODBCPreparedStatement.cxx.

References TSQLStatement::fCurrentResult, TSQL::fImp, odbc::Statement::getResultSet(), ODBCXX_STRING_CSTR, and TSQL::Throw().

00731 {
00732    // Returns the current result as a TSQLResultSet object. 
00733    // This method should be called only once per result.
00734    //
00735    // This method also implicitly closes any current TSQLResultSet 
00736    //   
00737    // Returns:
00738    //       the current result as a TSQLResultSet; null if the result 
00739    //       is an update count or there are no more results
00740    // Throws:
00741    //       TSQLException - if a database access error occurs
00742    // See Also: 
00743    //       Execute(const TString&)
00744    
00745    if(!fImp) { Destroyed(); return 0; }
00746    odbc::ResultSet* rs;
00747    odbc::Statement* stmt = (odbc::Statement*)fImp;
00748 
00749    if(fCurrentResult)  delete fCurrentResult;
00750 
00751    try {     
00752       rs = stmt->getResultSet(); 
00753    } catch(odbc::SQLException& e) {
00754       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00755                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00756                                 e.getErrorCode()) );
00757       if(rs) delete rs;
00758       fCurrentResult = 0;
00759       return 0;
00760    }
00761 
00762    return fCurrentResult = new ODBCResultSet(this,(void*)rs); 
00763 }   

Int_t ODBCPreparedStatement::GetResultSetConcurrency   [virtual]
 

Implements TSQLStatement.

Definition at line 1238 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, odbc::Statement::getResultSetConcurrency(), ODBCXX_STRING_CSTR, and TSQL::Throw().

01239 {
01240    // Retrieves the result set concurrency.
01241    //
01242    // enum EResultSetConcurrency{
01243    //       kCONCUR_READ_ONLY,
01244    //       kCONCUR_UPDATABLE
01245    //    };
01246 
01247    Int_t return_value = 0;
01248    
01249    if(!fImp) { Destroyed(); return return_value; }
01250    odbc::Statement* stmt = (odbc::Statement*)fImp;
01251    
01252    try {
01253       return_value = stmt->getResultSetConcurrency();
01254    } catch(odbc::SQLException& e) {
01255       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
01256                                 ODBCXX_STRING_CSTR(e.getSQLState()),
01257                                 e.getErrorCode()) );
01258       return 0;
01259    }   
01260    return return_value;
01261 }

Int_t ODBCPreparedStatement::GetResultSetType   [virtual]
 

Implements TSQLStatement.

Definition at line 1264 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, odbc::Statement::getResultSetType(), ODBCXX_STRING_CSTR, and TSQL::Throw().

01265 {
01266    // Determine the result set type.
01267    //
01268    // enum EResultSetType{
01269    //       kTYPE_FORWARD_ONLY,
01270    //       kTYPE_SCROLL_INSENSITIVE,
01271    //       kTYPE_SCROLL_SENSITIVE
01272    //       };
01273    //
01274      
01275    Int_t return_value = 0;
01276    
01277    if(!fImp) { Destroyed(); return return_value; }
01278    odbc::Statement* stmt = (odbc::Statement*)fImp;
01279    
01280    try {
01281       return_value = stmt->getResultSetType(); 
01282    } catch(odbc::SQLException& e) {
01283       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
01284                                 ODBCXX_STRING_CSTR(e.getSQLState()),
01285                                 e.getErrorCode()) );
01286       return 0;
01287    }
01288    return return_value;
01289 }

Int_t ODBCPreparedStatement::GetUpdateCount   [virtual]
 

Implements TSQLStatement.

Definition at line 766 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, odbc::Statement::getUpdateCount(), ODBCXX_STRING_CSTR, and TSQL::Throw().

00767 {
00768    // Returns the current result as an update count; 
00769    // if there are no more results, -1 is returned.
00770    // This method should be called only once per result.
00771    //
00772    // Returns:
00773    //       the current result as an update count; -1 if it is a 
00774    //       TSQLResultSet or there are no more results
00775    // Throws:
00776    //       TSQLException - if a database access error occurs
00777    // See Also: 
00778    //       Execute(const TString&)
00779    
00780    if(!fImp) { Destroyed(); return 0; }
00781 
00782    Int_t return_value = 0;
00783    odbc::Statement* stmt = (odbc::Statement*)fImp;
00784       
00785    try {
00786       return_value = stmt->getUpdateCount();
00787    } catch(odbc::SQLException& e) {
00788       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00789                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00790                                 e.getErrorCode()) );
00791       return  0;
00792    }
00793    return return_value;
00794 }

void ODBCPreparedStatement::SetAsciiStream Int_t    parameterIndex,
TBuffer *    x,
Int_t    length
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 480 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setAsciiStream(), and TSQL::Throw().

00483 {
00484   // Sets the designated parameter to the given input stream,
00485   // which will have the specified number of bytes. When a very
00486   // large ASCII value is input to a LONGVARCHAR parameter, it
00487   // may be more practical to send it via a TBuffer
00488   // will read the data from the stream as needed, until it
00489   // reaches end-of-file. The  driver will do any necessary
00490   // conversion from ASCII to the database char format. 
00491   //
00492   //    Parameters:
00493   //          parameterIndex - the first parameter is 1, 
00494   //                           the second is 2, ...
00495   //          x - the  input stream that contains the ASCII
00496   //              parameter value
00497   //          length - the number of bytes in the stream,
00498   //                   total size of buffer is by default. 
00499   //    Throws:
00500   //          TSQLException - if a database access error occurs
00501 
00502    if(!fImp) { Destroyed();   return; } 
00503    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00504    
00505    try {
00506       Int_t xl = x->BufferSize()>length ? length : x->BufferSize();
00507           istrstream* s = new istrstream(x->Buffer(),xl); //
00508       imp->setAsciiStream( parameterIndex,(std::istream*)s,xl );
00509 
00510    } catch(odbc::SQLException& e) {
00511       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00512                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00513                                 e.getErrorCode()) );
00514    }
00515 }

void ODBCPreparedStatement::SetBinaryStream Int_t    parameterIndex,
TBuffer *    x,
Int_t    length
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 518 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setBinaryStream(), and TSQL::Throw().

Referenced by SetObject().

00521 {
00522    // Sets the designated parameter to the given input stream,
00523    // which will have the specified number of bytes. When a very
00524    // large binary value is input to a LONGVARBINARY parameter, it
00525    // may be more practical to send it via a TBuffer.
00526    // will read the data from the stream as needed, until it
00527    // reaches end-of-file. 
00528    //
00529    //   Parameters:
00530    //         parameterIndex - the first parameter is 1, 
00531    //                          the second is 2, ...
00532    //         x - the input tream which contains the binary
00533    //                  parameter value
00534    //         length - the number of bytes in the stream
00535    //                   total size of buffer is by default. 
00536    //   Throws:
00537    //         TSQLException - if a database access error occurs
00538 
00539    if(!fImp) { Destroyed();   return; } 
00540    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00541    
00542    try {
00543       Int_t xl = x->BufferSize()>length ? length : x->BufferSize();
00544       istrstream* s = new istrstream(x->Buffer(),xl); //
00545       imp->setBinaryStream( parameterIndex,(std::istream*)s,xl );
00546 
00547    } catch(odbc::SQLException& e) {
00548       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00549                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00550                                 e.getErrorCode()) );
00551    }
00552 }

void ODBCPreparedStatement::SetBoolean Int_t    parameterIndex,
Bool_t    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 132 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setBoolean(), and TSQL::Throw().

00133 {
00134    // Sets the designated parameter to a Bool_t value. The
00135    // driver converts this to an SQL BIT value when it sends it to
00136    // the database.
00137    //
00138    //   Parameters:
00139    //         parameterIndex - the first parameter is 1, 
00140    //                          the second is 2, ...
00141    //         x - the parameter value
00142    //   Throws:
00143    //         TSQLException - if a database access error occurs
00144    
00145    if(!fImp) { Destroyed();   return; } 
00146    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00147    
00148    try {
00149       imp->setBoolean(parameterIndex,x); 
00150 
00151    } catch(odbc::SQLException& e) {
00152       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00153                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00154                                 e.getErrorCode()) );
00155    }
00156 }

void ODBCPreparedStatement::SetByte Int_t    parameterIndex,
Char_t    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 159 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setByte(), and TSQL::Throw().

00160 {
00161    // Sets the designated parameter to a  byte value. The
00162    // driver converts this to an SQL TINYINT value when it sends
00163    // it to the database.
00164    //
00165    //   Parameters:
00166    //         parameterIndex - the first parameter is 1, 
00167    //                          the second is 2, ...
00168    //         x - the parameter value
00169    //   Throws:
00170    //         TSQLException - if a database access error occurs
00171    
00172    if(!fImp) { Destroyed();   return; } 
00173    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00174    
00175    try {   
00176       imp->setByte(parameterIndex,x); 
00177 
00178    } catch(odbc::SQLException& e) {
00179       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00180                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00181                                 e.getErrorCode()) );
00182    }
00183 }

void ODBCPreparedStatement::SetBytes Int_t    parameterIndex,
const TArrayC &    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 350 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_BYTES_C, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setBytes(), and TSQL::Throw().

00352 {
00353    // Sets the designated parameter to a  array of bytes. The
00354    // driver converts this to an SQL VARBINARY or LONGVARBINARY
00355    // (depending on the argument's size relative to the driver's
00356    // limits on VARBINARYs) when it sends it to the database.
00357    //
00358    //   Parameters:
00359    //         parameterIndex - the first parameter is 1, 
00360    //                          the second is 2, ...
00361    //         x - the parameter value
00362    //   Throws:
00363    //         TSQLException - if a database access error occurs
00364 
00365    if(!fImp) { Destroyed();   return; } 
00366    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00367    
00368    try {
00369       imp->setBytes( parameterIndex,
00370                      ODBCXX_BYTES_C(x.GetArray(),x.GetSize()) );
00371 
00372    } catch(odbc::SQLException& e) {
00373       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00374                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00375                                 e.getErrorCode()) );
00376    }
00377 }

void ODBCPreparedStatement::SetCursorName const TString &    name [virtual]
 

Implements TSQLStatement.

Definition at line 1113 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_C, ODBCXX_STRING_CSTR, odbc::Statement::setCursorName(), and TSQL::Throw().

01114 {
01115    // Defines the SQL cursor name that will be used by subsequent
01116    // ODBCStatement execute methods. This name can then be used in 
01117    // SQL positioned update/delete statements to identify the 
01118    // current row in the TSQLResultSet generated by this statement. 
01119    // If the database doesn't support positioned update/delete, 
01120    // this method is a noop. To insure that a cursor has the proper 
01121    // isolation level to support updates, the cursor's SELECT 
01122    // statement should be of the form 'SELECT FOR UPDATE ...'. If
01123    // the 'FOR UPDATE' phrase is omitted, positioned updates may 
01124    // fail. 
01125    //
01126    // Note: By definition, positioned update/delete execution must 
01127    //    be done by a different ODBCStatement than the one which 
01128    //    generated the TSQLResultSet being used for positioning.
01129    //    Also, cursor names must be unique within a connection.
01130    //
01131    // Parameters:
01132    //       name - the new cursor name, which must be unique within
01133    //       a connection
01134    // Throws:
01135    //       TSQLException - if a database access error occurs
01136    
01137    if(!fImp) { Destroyed(); return; }
01138    odbc::Statement* stmt = (odbc::Statement*)fImp;
01139    
01140    try {
01141       stmt->setCursorName(ODBCXX_STRING_C(name.Data()));
01142    } catch(odbc::SQLException& e) {
01143       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
01144                                 ODBCXX_STRING_CSTR(e.getSQLState()),
01145                                 e.getErrorCode()) );
01146    }
01147 }

void ODBCPreparedStatement::SetDate Int_t    parameterIndex,
const TSQLDate   x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 380 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, TSQLDate::GetDay(), TSQLDate::GetMonth(), TSQLDate::GetYear(), ODBCXX_STRING_CSTR, odbc::PreparedStatement::setDate(), and TSQL::Throw().

00382 {
00383    //  Sets the designated parameter to a TSQLDate value. The
00384    //  driver converts this to an SQL DATE value when it sends it
00385    //  to the database.
00386    //
00387    //   Parameters:
00388    //         parameterIndex - the first parameter is 1, 
00389    //                          the second is 2, ...
00390    //         x - the parameter value
00391    //   Throws:
00392    //         TSQLException - if a database access error occurs
00393    
00394    if(!fImp) { Destroyed();   return; } 
00395    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00396    
00397    try {
00398       odbc::Date dt( x.GetYear(),
00399                      x.GetMonth(),
00400                      x.GetDay() );
00401 
00402       imp->setDate(parameterIndex,dt);
00403 
00404    } catch(odbc::SQLException& e) {
00405       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00406                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00407                                 e.getErrorCode()) );
00408    }
00409 }

void ODBCPreparedStatement::SetDouble Int_t    parameterIndex,
Double_t    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 294 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setDouble(), and TSQL::Throw().

00295 {
00296    // Sets the designated parameter to a  double value. The
00297    // driver converts this to an SQL DOUBLE value when it sends it
00298    // to the database.
00299    //
00300    //   Parameters:
00301    //         parameterIndex - the first parameter is 1, 
00302    //                          the second is 2, ...
00303    //         x - the parameter value
00304    //   Throws:
00305    //         TSQLException - if a database access error occurs
00306    
00307    if(!fImp) { Destroyed();   return; } 
00308    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00309    
00310    try {
00311       imp->setDouble(parameterIndex,x);
00312 
00313    } catch(odbc::SQLException& e) {
00314       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00315                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00316                                 e.getErrorCode()) );
00317    }
00318 }

void ODBCPreparedStatement::SetEscapeProcessing Bool_t    enable = kTRUE [virtual]
 

Implements TSQLStatement.

Definition at line 942 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::Statement::setEscapeProcessing(), and TSQL::Throw().

00943 {
00944    // Sets escape processing on or off. If escape scanning is on 
00945    // (the default), the driver will do escape substitution before 
00946    // sending the SQL to the database.
00947    // 
00948    // Note:
00949    //    Since prepared statements have usually been parsed prior to 
00950    //    making this call, disabling escape processing for prepared 
00951    //    statements will have no effect.
00952    //
00953    // Parameters:
00954    //       enable - kTRUE to enable; kFALSE to disable
00955    // Throws:
00956    //       TSQLException - if a database access error occurs
00957    
00958    if(!fImp) { Destroyed(); return; }
00959    odbc::Statement* stmt = (odbc::Statement*)fImp;
00960    
00961    try {
00962       stmt->setEscapeProcessing(enable);
00963    } catch(odbc::SQLException& e) {
00964       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00965                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00966                                 e.getErrorCode()) );
00967    }
00968 }

void ODBCPreparedStatement::SetFetchDirection Int_t    direction [virtual]
 

Implements TSQLStatement.

Definition at line 1150 of file ODBCPreparedStatement.cxx.

References TSQL::fImp.

01151 {
01152    // Gives the driver a hint as to the direction in which the
01153    // rows in a result set will be processed. The hint applies only 
01154    // to result sets created using this statement object. 
01155    // The default value is TSQLResultSet::kTYPE_FORWARD_ONLY
01156    //
01157    // Note that this method sets the default fetch direction for 
01158    // result sets generated by this statement object.
01159    //
01160    // Parameters:
01161    //    direction - the initial direction for processing rows
01162    // Throws:
01163    //    TSQLException - if a database access error occurs or the 
01164    //                   given direction is not one of 
01165    // 
01166    
01167    if(!fImp) { Destroyed(); return; }
01168 }

void ODBCPreparedStatement::SetFetchSize Int_t    rows [virtual]
 

Implements TSQLStatement.

Definition at line 1189 of file ODBCPreparedStatement.cxx.

References TSQL::fImp.

01190 {
01191    // Gives the driver a hint as to the number of rows that
01192    // should be fetched from the database when more rows are needed. 
01193    // The number of rows specified affects only result sets created 
01194    // using this statement. If the value specified is zero, then the
01195    // hint is ignored. The default value is zero.
01196    //
01197    // Parameters:
01198    //       rows - the number of rows to fetch
01199    // Throws:
01200    //       TSQLException - if a database access error occurs, or 
01201    //       the condition 0 <= rows <= GetMaxRows() is not satisfied.
01202    
01203    if(!fImp) { Destroyed(); return; }
01204 }

void ODBCPreparedStatement::SetFloat Int_t    parameterIndex,
Float_t    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 267 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setFloat(), and TSQL::Throw().

00268 {
00269    // Sets the designated parameter to a  float value. The
00270    // driver converts this to an SQL FLOAT value when it sends it
00271    // to the database.
00272    //
00273    //   Parameters:
00274    //         parameterIndex - the first parameter is 1, 
00275    //                          the second is 2, ...
00276    //         x - the parameter value
00277    //   Throws:
00278    //         TSQLException - if a database access error occurs
00279    
00280    if(!fImp) { Destroyed();   return; } 
00281    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00282    
00283    try {
00284       imp->setFloat(parameterIndex,x);
00285 
00286    } catch(odbc::SQLException& e) {
00287       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00288                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00289                                 e.getErrorCode()) );
00290    }
00291 }

void ODBCPreparedStatement::SetInt Int_t    parameterIndex,
Int_t    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 213 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setInt(), and TSQL::Throw().

00214 {
00215    // Sets the designated parameter to a  int value. The
00216    // driver converts this to an SQL INTEGER value when it sends
00217    // it to the database.
00218    //
00219    //   Parameters:
00220    //         parameterIndex - the first parameter is 1, 
00221    //                          the second is 2, ...
00222    //         x - the parameter value
00223    //   Throws:
00224    //         TSQLException - if a database access error occurs
00225    
00226    if(!fImp) { Destroyed();   return; } 
00227    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00228    
00229    try {
00230       imp->setInt(parameterIndex,x);
00231 
00232    } catch(odbc::SQLException& e) {
00233       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00234                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00235                                 e.getErrorCode()) );
00236    }
00237 }

void ODBCPreparedStatement::SetLong Int_t    parameterIndex,
Long_t    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 240 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setLong(), and TSQL::Throw().

00241 {
00242    // Sets the designated parameter to a  long value. The
00243    // driver converts this to an SQL BIGINT value when it sends it
00244    // to the database.
00245    //
00246    //   Parameters:
00247    //         parameterIndex - the first parameter is 1, 
00248    //                          the second is 2, ...
00249    //         x - the parameter value
00250    //   Throws:
00251    //         TSQLException - if a database access error occurs
00252    
00253    if(!fImp) { Destroyed();   return; } 
00254    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00255    
00256    try {
00257       imp->setLong(parameterIndex,x);
00258 
00259    } catch(odbc::SQLException& e) {
00260       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00261                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00262                                 e.getErrorCode()) );
00263    }
00264 }

void ODBCPreparedStatement::SetMaxFieldSize Int_t    max [virtual]
 

Implements TSQLStatement.

Definition at line 862 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::Statement::setMaxFieldSize(), and TSQL::Throw().

00863 {
00864    // Sets the limit for the maximum number of bytes in a column to 
00865    // the given number of bytes. This is the maximum number of bytes 
00866    // that can be returned for any column value. This limit applies 
00867    // only to kBINARY, kVARBINARY, kLONGVARBINARY, kCHAR, kVARCHAR,
00868    // and kLONGVARCHAR fields (see TSQLTypes.h) . If the limit is exceeded, 
00869    // the excess  data is silently discarded. For maximum portability, 
00870    // use values greater than 256.
00871    //
00872    // Parameters:
00873    //       max - the new max column size limit; zero means unlimited
00874    // Throws:
00875    //       TSQLException - if a database access error occurs
00876    
00877    if(!fImp) { Destroyed(); return; }
00878    odbc::Statement* stmt = (odbc::Statement*)fImp;
00879    
00880    try {
00881       stmt->setMaxFieldSize(max);   
00882    } catch(odbc::SQLException& e) {
00883       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00884                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00885                                 e.getErrorCode()) );
00886    }
00887 }

void ODBCPreparedStatement::SetMaxRows Int_t    max [virtual]
 

Implements TSQLStatement.

Definition at line 918 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::Statement::setMaxRows(), and TSQL::Throw().

00919 {
00920    // Sets the limit for the maximum number of rows that any 
00921    // TSQLResultSet can contain to the given number. If the limit is 
00922    // exceeded, the excess rows are silently dropped.
00923    //
00924    // Parameters:
00925    //       max - the new max rows limit; zero means unlimited
00926    // Throws:
00927    //       TSQLException - if a database access error occurs
00928    
00929    if(!fImp) { Destroyed(); return; }
00930    odbc::Statement* stmt = (odbc::Statement*)fImp;
00931    
00932    try {
00933       stmt->setMaxRows(max);  
00934    } catch(odbc::SQLException& e) {
00935       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00936                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00937                                 e.getErrorCode()) );
00938    }
00939 }

void ODBCPreparedStatement::SetNull Int_t    parameterIndex,
Int_t    sqlType
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 105 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setNull(), and TSQL::Throw().

00106 {
00107    // Sets the designated parameter to SQL NULL. 
00108    //
00109    //   Note: You must specify the parameter's SQL type.
00110    //
00111    //   Parameters:
00112    //          parameterIndex - the first parameter is 1, 
00113    //                           the second is 2, ...
00114    //          sqlType - the SQL type code defined in TSQLTypes
00115    //   Throws:
00116    //          TSQLException - if a database access error occurs
00117    
00118    if(!fImp) { Destroyed();   return; } 
00119    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00120      
00121    try {
00122       imp->setNull(parameterIndex,sqlType);
00123 
00124    } catch(odbc::SQLException& e) {
00125       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00126                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00127                                 e.getErrorCode()) );
00128    }
00129 }

void ODBCPreparedStatement::SetObject Int_t    parameterIndex,
TObject *    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 555 of file ODBCPreparedStatement.cxx.

References b, and SetBinaryStream().

00556 {
00557    // Sets the designated parameter to the given ROOT object
00558    //
00559    //   Parameters:
00560    //         parameterIndex - the first parameter is 1, 
00561    //                          the second is 2, ...
00562    //         x - the ROOT object
00563    //   Throws:
00564    //         TSQLException - if a database access error occurs
00565 
00566    TBuffer *b = new TBuffer(TBuffer::kWrite);
00567    b->WriteObject(x);
00568    SetBinaryStream(parameterIndex,b,b->BufferSize());
00569    b->DetachBuffer();
00570    delete b;
00571 }

void ODBCPreparedStatement::SetQueryTimeout Int_t    seconds [virtual]
 

Implements TSQLStatement.

Definition at line 1033 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::Statement::setQueryTimeout(), and TSQL::Throw().

01034 {
01035    // Sets the number of seconds the driver will wait for a 
01036    // ODBCStatement to execute to the given number of seconds. 
01037    // If the limit is exceeded, a TSQLException is thrown.
01038    //
01039    // Parameters:
01040    //          seconds - the new query timeout limit in seconds; 
01041    //          zero means unlimited
01042    // Throws:
01043    //          TSQLException - if a database access error occurs
01044    
01045    if(!fImp) { Destroyed(); return; }
01046    odbc::Statement* stmt = (odbc::Statement*)fImp;
01047    
01048    try {
01049       stmt->setQueryTimeout(seconds);
01050    } catch(odbc::SQLException& e) {
01051       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
01052                                 ODBCXX_STRING_CSTR(e.getSQLState()),
01053                                 e.getErrorCode()) );
01054    }
01055 }

void ODBCPreparedStatement::SetShort Int_t    parameterIndex,
Short_t    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 186 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setShort(), and TSQL::Throw().

00187 {
00188    // Sets the designated parameter to a  short value. The
00189    //   driver converts this to an SQL SMALLINT value when it sends
00190    //   it to the database.
00191    //
00192    //   Parameters:
00193    //         parameterIndex - the first parameter is 1, 
00194    //                            the second is 2, ...
00195    //         x - the parameter value
00196    //   Throws:
00197    //         TSQLException - if a database access error occurs
00198 
00199    if(!fImp) { Destroyed();   return; } 
00200    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00201    
00202    try {
00203       imp->setShort(parameterIndex,x);
00204 
00205    } catch(odbc::SQLException& e) {
00206       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00207                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00208                                 e.getErrorCode()) );
00209    }
00210 }

void ODBCPreparedStatement::SetString Int_t    parameterIndex,
const TString &    x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 321 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, ODBCXX_STRING_C, ODBCXX_STRING_CSTR, odbc::PreparedStatement::setString(), and TSQL::Throw().

00323 {
00324    //  Sets the designated parameter to a  TString value. The
00325    //  driver converts this to an SQL VARCHAR or LONGVARCHAR value
00326    //  (depending on the argument's size relative to the driver's
00327    //  limits on VARCHARs) when it sends it to the database.
00328    //
00329    //   Parameters:
00330    //         parameterIndex - the first parameter is 1, 
00331    //                          the second is 2, ...
00332    //         x - the parameter value
00333    //   Throws:
00334    //         TSQLException - if a database access error occurs
00335    
00336    if(!fImp) { Destroyed();   return; } 
00337    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00338    
00339    try {
00340       imp->setString( parameterIndex, ODBCXX_STRING_C(x.Data()) );
00341 
00342    } catch(odbc::SQLException& e) {
00343       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00344                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00345                                 e.getErrorCode()) );
00346    }
00347 }

void ODBCPreparedStatement::SetTime Int_t    parameterIndex,
const TSQLTime   x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 412 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, TSQLTime::GetHour(), TSQLTime::GetMinute(), TSQLTime::GetSecond(), ODBCXX_STRING_CSTR, odbc::PreparedStatement::setTime(), and TSQL::Throw().

00414 {
00415    // Sets the designated parameter to a TSQLTime value. The
00416    // driver converts this to an SQL TIME value when it sends it
00417    // to the database.
00418    //
00419    //   Parameters:
00420    //         parameterIndex - the first parameter is 1, 
00421    //                          the second is 2, ...
00422    //         x - the parameter value
00423    //   Throws:
00424    //         TSQLException - if a database access error occurs
00425    
00426    if(!fImp) { Destroyed();   return; } 
00427    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00428    
00429    try {
00430       odbc::Time tm( x.GetHour(),
00431                      x.GetMinute(),
00432                      x.GetSecond() );
00433 
00434       imp->setTime(parameterIndex,tm);
00435 
00436    } catch(odbc::SQLException& e) {
00437       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00438                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00439                                 e.getErrorCode()) );
00440    }
00441 }

void ODBCPreparedStatement::SetTimestamp Int_t    parameterIndex,
const TSQLTimestamp   x
[virtual]
 

Implements TSQLPreparedStatement.

Definition at line 444 of file ODBCPreparedStatement.cxx.

References TSQL::fImp, TSQLTimestamp::GetDay(), TSQLTimestamp::GetHour(), TSQLTimestamp::GetMinute(), TSQLTimestamp::GetMonth(), TSQLTimestamp::GetNanos(), TSQLTimestamp::GetSecond(), TSQLTimestamp::GetYear(), ODBCXX_STRING_CSTR, odbc::PreparedStatement::setTimestamp(), and TSQL::Throw().

00446 {
00447    // Sets the designated parameter to a TSQLTimestamp value.
00448    // The driver converts this to an SQL TIMESTAMP value when it
00449    // sends it to the database.
00450    //
00451    //   Parameters:
00452    //         parameterIndex - the first parameter is 1,
00453    //                          the second is 2, ...
00454    //         x - the parameter value
00455    //   Throws:
00456    //         TSQLException - if a database access error occurs
00457    
00458    if(!fImp) { Destroyed();   return; } 
00459    odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
00460    
00461    try {
00462       odbc::Timestamp tmstmp( x.GetYear(),
00463                               x.GetMonth(),
00464                               x.GetDay(),
00465                               x.GetHour(),
00466                               x.GetMinute(),
00467                               x.GetSecond(),
00468                               x.GetNanos() );
00469 
00470       imp->setTimestamp(parameterIndex,tmstmp);
00471 
00472    } catch(odbc::SQLException& e) {
00473       Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
00474                                 ODBCXX_STRING_CSTR(e.getSQLState()),
00475                                 e.getErrorCode()) );
00476    }
00477 }


Friends And Related Function Documentation

friend class ODBCConnection [friend]
 

Definition at line 17 of file ODBCPreparedStatement.h.


The documentation for this class was generated from the following files:
Generated on Wed Sep 4 19:23:21 2002 for loon by doxygen1.2.16