Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:22:03

0001 // $Id: MySQLStatement.cxx,v 1.1.1.1 2004/02/18 20:58:02 dave Exp $
0002 //*-- Author : Valeriy Onuchin 24/02/2001 
0003 //
0004 // RDBC driver to MySQL database implemented with MySQL C API.
0005 //
0006 
0007 /////////////////////////////////////////////////////////////////////
0008 //
0009 // The object used for executing a static SQL statement and 
0010 // obtaining the results produced by it. 
0011 // 
0012 // Only one TSQLResultSet per TSQLStatement can be open at any point 
0013 // in time. Therefore, if the reading of one TSQLResultSet is
0014 // interleaved with the reading of another, each must have been 
0015 // generated by different TSQLStatements. All statement execute 
0016 // methods  implicitly close a statment's current TSQLResultSet if 
0017 // an open  one exists. 
0018 //
0019 // See also: 
0020 //    TSQLConnection::CreateStatement(), TSQLResultSet 
0021 //    TSQLCallableStatement TSQLPreparedStatement
0022 //Begin_Html
0023 /*
0024 <P>
0025    The <TT>TSQLStatement</TT> class encapsulates SQL queries to your database. 
0026 Using several methods, these calls return objects that contain the 
0027 results of your SQL query. When you execute an SQL query, the data 
0028 that is returned to you is commonly called the result set. You can 
0029 choose from several result sets, depending on your needs:
0030 <UL>
0031 <LI><TT>TSQLResultSet* ExecuteQuery( const TString& sqlStatement)<BR></TT>
0032 This method sends the SQL query contained in <TT>sqlStatement</TT>
0033 and returns a single set of results. This method is best used 
0034 in sending  <TT>SELECT</TT> statements. These statements typically 
0035 return a result set. This method implicitly deletes previous resultset.
0036 
0037 <LI><TT>Int_t ExecuteUpdate( const TString& sqlStatement )<BR></TT>
0038 This method sends the SQL query contained in <TT>sqlStatement</TT> 
0039 and returns an integer. This method is useful when you send SQL 
0040 <TT>INSERT</TT>s,  <TT>DELETE</TT>s, and <TT>UPDATE</TT>s.  These commands return 
0041 a count of rows  that were affected  by your query. This statement 
0042 should not be used for queries that  return result sets.
0043 
0044 <LI><TT>Bool_t Execute( const TString& sqlStatement )<BR></TT>
0045 This method sends the <TT>sqlStatement</TT> to the database and returns 
0046 <TT>kTRUE</TT> if the statement returns a result set or <TT>kFALSE</TT> if the 
0047 statement returns an integer. This method is best used when multiple 
0048 result sets can be returned.
0049 </UL>
0050 <P>
0051 Use the following methods to easily navigate the results a query returns:
0052 <UL>
0053 <LI><TT>Bool_t GetMoreResults()<BR> </TT>
0054 This moves to the next result set in the <TT>TSQLStatement</TT>. This, 
0055 like the <TT>Execute()</TT> method, returns <TT>kTRUE</TT> if the  next 
0056 result is a result set or <TT>kFALSE</TT> if it is an  integer.  
0057 If you have  already retrieved a <TT>TSQLResultSet</TT> from  the  
0058 <TT>TSQLStatement</TT>, this method will close it before returning.
0059 
0060 <LI><TT>TSQLResultSet* GetResultSet()<BR></TT>
0061 This method returns to you a result set in a <TT>TSQLResultSet</TT> 
0062 object. This result set is the current result set.
0063 
0064 <LI><TT>Int_t GetUpdateCount()<BR></TT>
0065 This method returns to you the integer result that an 
0066 <TT>Execute()</TT> method returned.
0067 </UL>
0068 <P>
0069 */
0070 //End_Html
0071 /////////////////////////////////////////////////////////////////////
0072 
0073 #include <RDBC/TSQLStatement.h>
0074 #include <RDBC/TSQLResultSet.h>
0075 #include <RDBC/TSQLConnection.h>
0076 #include <TList.h>
0077 #include "MySQLStatementPrivate.h"
0078 
0079 
0080 ClassImpQ(TSQLStatement)
0081 
0082 /////////////////////////////////////////////////////////////////////
0083 //___________________________________________________________________
0084 TSQLStatement::TSQLStatement( TSQLConnection* con, 
0085                               void* imp ):TSQL(imp)
0086 {
0087    // ctor
0088  
0089    fBatches = new TList();
0090    fConnection = con;
0091    fCurrentResult = 0;
0092    fImp = new MySQLStatementPrivate();
0093 }
0094 
0095 //___________________________________________________________________
0096 TSQLStatement::~TSQLStatement( )
0097 {
0098    // Destructor.
0099    //
0100    //  Note: When a TSQLStatement is closed, its current 
0101    //       TSQLResultSet,  if one exists, is also closed.
0102    // 
0103 
0104    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0105    delete imp;  
0106 
0107    ClearBatch();
0108    SafeDelete(fBatches);
0109 
0110    fConnection->GetListOfStatements()->Remove(this);
0111    if(fCurrentResult) delete fCurrentResult;
0112    Destroyed();
0113 }
0114 
0115 //___________________________________________________________________
0116 TSQLResultSet* TSQLStatement::ExecuteQuery( const TString& sql )
0117 {
0118    // Executes a SQL statement that returns a single TSQLResultSet
0119    //
0120    // This method also implicitly closes current TSQLResultSet 
0121    //
0122    // Returns:
0123    //       a TSLResultSet that contains the data produced by the query; 
0124    //       NULL - in case of error
0125    //
0126    //   Throws:
0127    //       TSQLException - if a database access error occurs
0128 
0129    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0130    MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp;
0131 
0132    imp->fQuery = sql;
0133 
0134    ClearWarnings();
0135 
0136    if(fCurrentResult)  fCurrentResult->Close();
0137    else fCurrentResult = new TSQLResultSet(this,new MySQLResultSetPrivate());
0138 
0139    MySQLResultSetPrivate* result = (MySQLResultSetPrivate*)fCurrentResultSet->fImp;
0140 
0141    TString oldCatalog;
0142 
0143    if( fConnection->GetCatalog() != imp->fCatalog ) {
0144       oldCatalog = fConnection->GetCatalog();
0145       fConnection->SetCatalog(imp->fCatalog);
0146    }
0147 
0148    if( imp->fMaxRows && imp->fMaxRows != (Ulong_t)~0L ) {
0149       if( !imp->fQuery.Contains("LIMIT",TString::kIgnoreCase) ) {
0150          Int_t pos = imp->fQuery.Index("select",0,TString::kIgnoreCase);
0151          imp->fQuery.Insert(pos+6,Form(" limit %lu",imp->fMaxRows));
0152       }
0153    }
0154  
0155    if( con->CheckIfServerIsAlive() || mysql_query(con->fMYSQL,imp->fQuery)) {
0156       Throw(new TSQLException(mysql_error(con->fMYSQL),"S1000",mysql_errno(con->fMYSQL)) );
0157       if( !oldCatalog.IsNull() ) fConnection->SetCatalog(oldCatalog);
0158       return 0;
0159    }
0160 
0161 #ifdef NOT_USED
0162   if( imp->fCursorType == kCURSOR_FORWARD_ONLY &&
0163       !(con->fMYSQL->flag & FLAG_SAFE))
0164     result->fMYSQL_RES = mysql_use_result(con->fMYSQL);
0165   else
0166 #endif
0167 
0168    result->fMYSQL_RES = mysql_store_result(con->fMYSQL);  
0169    
0170    if( !oldCatalog.IsNull() ) fConnection->SetCatalog(oldCatalog);
0171 
0172    if( !result->fMYSQL_RES ) {
0173       if( !mysql_field_count(con->fMYSQL) ) { 
0174          stmt->state = ST_EXECUTED;
0175          stmt->affected_rows = mysql_affected_rows(con->fMYSQL);
0176          result->fReallyResult = kFALSE;  // no result set
0177          return fCurrentResult;
0178       }
0179  
0180       Throw(new TSQLException(mysql_error(con->fMYSQL),"S1000",mysql_errno(con->fMYSQL)));
0181       return 0;
0182    }
0183 
0184    result->fCurrentRow = 0;
0185    result->fReallyResult = kTRUE;  
0186    imp->fLastInsertId = fCurrenResult->GetUpdateID();
0187 
0188    return fCurrentResult;
0189 }
0190 
0191 //___________________________________________________________________
0192 Bool_t TSQLStatement::Execute( const TString& sql )
0193 {
0194    // Executes a SQL statement that may return multiple results.
0195    // Under some (uncommon) situations a single SQL statement may 
0196    // return multiple result sets and/or update counts. Normally you 
0197    // can ignore this unless you are (1) executing a stored
0198    // procedure that you know may return multiple results or (2) you 
0199    // are dynamically executing an unknown SQL string. The methods 
0200    // execute, GetMoreResults(), GetResultSet(), and GetUpdateCount()
0201    // let you navigate through multiple results.
0202    //  The execute method executes a SQL statement and indicates the 
0203    // form of the first result. You can then use GetResultSet() or
0204    // GetUpdateCount() to retrieve the result, and GetMoreResults() 
0205    // to move to any subsequent result(s).
0206    //
0207    // Parameters:
0208    //          sql - any SQL statement
0209    // Returns:
0210    //          kTRUE if the next result is a TSQLResultSet; 
0211    //          kFALSE if it is an update count or there are no more
0212    //          results
0213    // Throws:
0214    //            TSQLException - if a database access error occurs
0215    // See Also: 
0216    //       GetResultSet(), GetUpdateCount(), GetMoreResults()
0217   
0218 
0219    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0220    MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp;
0221 
0222    imp->fQuery = sql;
0223    ClearWarnings();
0224 
0225    if(fCurrentResult)  fCurrentResult->Close();
0226    else fCurrentResult = new TSQLResultSet(this,new MySQLResultSetPrivate());
0227 
0228    MySQLResultSetPrivate* result = (MySQLResultSetPrivate*)fCurrentResultSet->fImp;
0229 
0230    TString oldCatalog;
0231 
0232    if( fConnection->GetCatalog() != imp->fCatalog ) {
0233       oldCatalog = fConnection->GetCatalog();
0234       fConnection->SetCatalog(imp->fCatalog);
0235    }
0236 
0237    if( imp->fMaxRows && imp->fMaxRows != (Ulong_t)~0L ) {
0238       if( !imp->fQuery.Contains("LIMIT",TString::kIgnoreCase) ) {
0239          Int_t pos = imp->fQuery.Index("select",0,TString::kIgnoreCase);
0240          imp->fQuery.Insert(pos+6,Form(" limit %lu",imp->fMaxRows));
0241       }
0242    }
0243  
0244    if( con->CheckIfServerIsAlive() || mysql_query(con->fMYSQL,imp->fQuery)) {
0245       Throw(new TSQLException(mysql_error(con->fMYSQL),"S1000",mysql_errno(con->fMYSQL)) );
0246       if( !oldCatalog.IsNull() ) fConnection->SetCatalog(oldCatalog);
0247       return 0;
0248    }
0249 
0250 #ifdef NOT_USED
0251   if( imp->fCursorType == kCURSOR_FORWARD_ONLY &&
0252       !(con->fMYSQL->flag & FLAG_SAFE))
0253     result->fMYSQL_RES = mysql_use_result(con->fMYSQL);
0254   else
0255 #endif
0256 
0257    result->fMYSQL_RES = mysql_store_result(con->fMYSQL);  
0258    
0259    if( !oldCatalog.IsNull() ) fConnection->SetCatalog(oldCatalog);
0260 
0261    if( !result->fMYSQL_RES ) {
0262       if( !mysql_field_count(con->fMYSQL) ) { 
0263          stmt->state = ST_EXECUTED;
0264          stmt->affected_rows = mysql_affected_rows(con->fMYSQL);
0265          result->fReallyResult = kFALSE;  // no result set
0266          return kFALSE;
0267       }
0268  
0269       Throw(new TSQLException(mysql_error(con->fMYSQL),"S1000",mysql_errno(con->fMYSQL)));
0270       return kFALSE;
0271    }
0272 
0273    result->fCurrentRow = 0;
0274    result->fReallyResult = kTRUE;  
0275    imp->fLastInsertId = fCurrenResult->GetUpdateID();
0276 
0277    return kTRUE; 
0278 }
0279 
0280 //___________________________________________________________________
0281 Int_t TSQLStatement::ExecuteUpdate( const TString& sql )
0282 {
0283    // Executes an SQL INSERT, UPDATE or DELETE statement. 
0284    // In addition, SQL statements that return nothing, 
0285    // such as SQL DDL statements, can be executed.
0286    //
0287    //  Parameters:
0288    //      sql - a SQL INSERT, UPDATE or DELETE statement or 
0289    //            a SQL statement that  returns nothing
0290    //
0291    //  Returns:
0292    //      either the row count for INSERT, UPDATE or DELETE or 
0293    //      0 for SQL statements that return nothing
0294    //  Throws:
0295    //      TSQLException - if a database access error occurs
0296  
0297    return return_value;
0298 }
0299 
0300 //___________________________________________________________________
0301 TSQLResultSet* TSQLStatement::GetResultSet()
0302 {
0303    // Returns the current result as a TSQLResultSet object. 
0304    // This method should be called only once per result.
0305    //
0306    // This method also implicitly closes any current TSQLResultSet 
0307    //   
0308    // Returns:
0309    //       the current result as a TSQLResultSet; null if the result 
0310    //       is an update count or there are no more results
0311    // Throws:
0312    //       TSQLException - if a database access error occurs
0313    // See Also: 
0314    //       Execute(const TString&)
0315 
0316 }   
0317 
0318 //___________________________________________________________________
0319 Int_t TSQLStatement::GetUpdateCount()
0320 {
0321    // Returns the current result as an update count; 
0322    // if there are no more results, -1 is returned.
0323    // This method should be called only once per result.
0324    //
0325    // Returns:
0326    //       the current result as an update count; -1 if it is a 
0327    //       TSQLResultSet or there are no more results
0328    // Throws:
0329    //       TSQLException - if a database access error occurs
0330    // See Also: 
0331    //       Execute(const TString&)
0332  
0333    return return_value;
0334 }
0335 
0336 //___________________________________________________________________
0337 Bool_t TSQLStatement::GetMoreResults()
0338 {
0339    // Moves to a TSQLStatement's next result. It returns kTRUE if 
0340    // this result is a TSQLResultSet. 
0341    // 
0342    // There are no more results when 
0343    //       (!GetMoreResults() && (GetUpdateCount() == -1)
0344    //
0345    // Returns:
0346    //    kTRUE if the next result is a TSQLResultSet; 
0347    //    kFALSE if it is an update count or there are no more results
0348    //
0349    // Throws:
0350    //       TSQLException - if a database access error occurs
0351    // See Also: 
0352    //       Execute(const TString&)
0353 
0354    return return_value;
0355 }
0356 
0357 //___________________________________________________________________
0358 Int_t TSQLStatement::GetMaxFieldSize()
0359 {
0360    // Returns the maximum number of bytes allowed for any column 
0361    // value. This limit is the maximum number of bytes that can be
0362    // returned for any column value. The limit applies only to 
0363    // kBINARY, kVARBINARY, kLONGVARBINARY, kCHAR, kVARCHAR, and 
0364    // kLONGVARCHAR columns (see TSQLTypes.h). If the limit is exceeded, 
0365    // the excess data  is silently discarded.
0366    //
0367    // Returns:
0368    //    the current max column size limit; zero means unlimited
0369    // Throws:
0370    //    TSQLException - if a database access error occurs
0371 
0372    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0373    reutrn imp->fMaxFieldSize;
0374 }
0375 
0376 //___________________________________________________________________
0377 void TSQLStatement::SetMaxFieldSize( Int_t max )
0378 {
0379    // Sets the limit for the maximum number of bytes in a column to 
0380    // the given number of bytes. This is the maximum number of bytes 
0381    // that can be returned for any column value. This limit applies 
0382    // only to kBINARY, kVARBINARY, kLONGVARBINARY, kCHAR, kVARCHAR,
0383    // and kLONGVARCHAR fields (see TSQLTypes.h) . If the limit is exceeded, 
0384    // the excess  data is silently discarded. For maximum portability, 
0385    // use values greater than 256.
0386    //
0387    // Parameters:
0388    //       max - the new max column size limit; zero means unlimited
0389    // Throws:
0390    //       TSQLException - if a database access error occurs
0391    
0392    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0393 
0394    if( max > MysqlIO.MAXBUF )
0395             throw new java.sql.SQLException("Attempt to set max field size > " + MysqlIO.MAXBUF + " (compile time default)", "S1009");
0396    else
0397       imp->fMaxFieldSize = max; 
0398 }
0399 
0400 //___________________________________________________________________
0401 Int_t TSQLStatement::GetMaxRows()
0402 {
0403    // Retrieves the maximum number of rows that a TSQLResultSet can 
0404    // contain. If the limit is exceeded, the excess rows are silently 
0405    // dropped.
0406    //
0407    // Returns:
0408    //       the current max row limit; zero means unlimited
0409    // Throws:
0410    //       TSQLException - if a database access error occurs
0411 
0412    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0413    return imp->fMaxRows <=0 ? 0 : imp->fMaxRows;
0414 }
0415 
0416 //___________________________________________________________________
0417 void TSQLStatement::SetMaxRows( Int_t max )
0418 {
0419    // Sets the limit for the maximum number of rows that any 
0420    // TSQLResultSet can contain to the given number. If the limit is 
0421    // exceeded, the excess rows are silently dropped.
0422    //
0423    // Parameters:
0424    //       max - the new max rows limit; zero means unlimited
0425    // Throws:
0426    //       TSQLException - if a database access error occurs
0427    
0428    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0429 
0430        if (max > MysqlDefs.MAX_ROWS) {
0431             throw new java.sql.SQLException("setMaxRows() out of range. " + max + " > " + MysqlDefs.MAX_ROWS + ".", "S1009");
0432         }
0433 
0434         if (max == 0) {
0435             max = -1;
0436         }
0437 
0438         _max_rows = max;
0439 
0440         // Most people don't use setMaxRows()
0441         // so don't penalize them
0442         // with the extra query it takes
0443         // to do it efficiently unless we need
0444         // to.
0445 
0446         _Conn.maxRowsChanged();
0447 }
0448 
0449 //___________________________________________________________________
0450 void TSQLStatement::SetEscapeProcessing( Bool_t enable )
0451 {
0452    // Sets escape processing on or off. If escape scanning is on 
0453    // (the default), the driver will do escape substitution before 
0454    // sending the SQL to the database.
0455    // 
0456    // Note:
0457    //    Since prepared statements have usually been parsed prior to 
0458    //    making this call, disabling escape processing for prepared 
0459    //    statements will have no effect.
0460    //
0461    // Parameters:
0462    //       enable - kTRUE to enable; kFALSE to disable
0463    // Throws:
0464    //       TSQLException - if a database access error occurs
0465    
0466    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0467    imp->fEscapeProcessing = enable;
0468 }
0469 
0470 //___________________________________________________________________
0471 Bool_t TSQLStatement::GetEscapeProcessing()
0472 {
0473    //  Returns if escape processing is on or off. 
0474    // If escape scanning is on (the default), the driver will do escape 
0475    // substitution before  sending the SQL to the database.
0476    // 
0477    // Note:
0478    //    Since prepared statements have usually been parsed prior to 
0479    //    making this call, disabling escape processing for prepared 
0480    //    statements will have no effect.
0481    //
0482    // Parameters:
0483    //       enable - kTRUE to enable; kFALSE to disable
0484    // Throws:
0485    //       TSQLException - if a database access error occurs
0486    
0487    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0488    return imp->fEscapeProcessing;
0489 }
0490 
0491 //___________________________________________________________________
0492 Int_t TSQLStatement::GetQueryTimeout()
0493 {
0494    // Retrieves the number of seconds the driver will wait for a
0495    // TSQLStatement to execute. If the limit is exceeded, a 
0496    // TSQLException is thrown.
0497    //
0498    // Returns:
0499    //    the current query timeout limit in seconds; zero means
0500    //    unlimited
0501    // Throws:
0502    //    TSQLException - if a database access error occurs
0503    
0504    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0505    return imp->fQueryTimeout;
0506 }
0507 
0508 //___________________________________________________________________
0509 void TSQLStatement::SetQueryTimeout( Int_t seconds )
0510 {
0511    // Sets the number of seconds the driver will wait for a 
0512    // TSQLStatement to execute to the given number of seconds. 
0513    // If the limit is exceeded, a TSQLException is thrown.
0514    //
0515    // Parameters:
0516    //          seconds - the new query timeout limit in seconds; 
0517    //          zero means unlimited
0518    // Throws:
0519    //          TSQLException - if a database access error occurs 
0520 
0521    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0522    imp->fQueryTimeout = 0; // not imlemented  yet
0523 }
0524 
0525 //___________________________________________________________________
0526 void TSQLStatement::Cancel() 
0527 {
0528    // Cancels this statement object if both the DBMS and driver 
0529    // support aborting an SQL statement. This method can be used by 
0530    // one thread to cancel a statement that is being executed by 
0531    // another thread.
0532    //
0533    // Throws:
0534    //       TSQLException - if a database access error occurs
0535    
0536 }
0537 
0538 //___________________________________________________________________
0539 void TSQLStatement::Close()
0540 {
0541    // Avoid using this method. Use delete TSQLStatement instead.
0542    //
0543    //  Note: When a TSQLStatement is closed, its current 
0544    //       TSQLResultSet,  if one exists, is also closed.
0545    //
0546    //     Throws:
0547    //      TSQLException - if a database access error occurs
0548 
0549    fImp = 0;
0550    Destroyed();
0551 }
0552 
0553 //___________________________________________________________________
0554 void TSQLStatement::SetCursorName( const TString& name )
0555 {
0556    // Defines the SQL cursor name that will be used by subsequent
0557    // TSQLStatement execute methods. This name can then be used in 
0558    // SQL positioned update/delete statements to identify the 
0559    // current row in the TSQLResultSet generated by this statement. 
0560    // If the database doesn't support positioned update/delete, 
0561    // this method is a noop. To insure that a cursor has the proper 
0562    // isolation level to support updates, the cursor's SELECT 
0563    // statement should be of the form 'SELECT FOR UPDATE ...'. If
0564    // the 'FOR UPDATE' phrase is omitted, positioned updates may 
0565    // fail. 
0566    //
0567    // Note: By definition, positioned update/delete execution must 
0568    //    be done by a different TSQLStatement than the one which 
0569    //    generated the TSQLResultSet being used for positioning.
0570    //    Also, cursor names must be unique within a connection.
0571    //
0572    // Parameters:
0573    //       name - the new cursor name, which must be unique within
0574    //       a connection
0575    // Throws:
0576    //       TSQLException - if a database access error occurs
0577    //
0578    //  This MySQL driver does not support cursors.
0579 }
0580 
0581 //___________________________________________________________________
0582 void TSQLStatement::SetFetchDirection( Int_t direction )
0583 {
0584    // Gives the driver a hint as to the direction in which the
0585    // rows in a result set will be processed. The hint applies only 
0586    // to result sets created using this TSQLStatement object. 
0587    // The default value is TSQLResultSet::kTYPE_FORWARD_ONLY
0588    //
0589    // Note that this method sets the default fetch direction for 
0590    // result sets generated by this TSQLStatement object.
0591    //
0592    // Parameters:
0593    //    direction - the initial direction for processing rows
0594    // Throws:
0595    //    TSQLException - if a database access error occurs or the 
0596    //                   given direction is not one of 
0597    // 
0598 }
0599 
0600 //___________________________________________________________________
0601 Int_t TSQLStatement::GetFetchDirection()
0602 {
0603    // Retrieves the direction for fetching rows from database
0604    // tables that is the default for result sets generated from this 
0605    // TSQLStatement object. If this TSQLStatement object has not set 
0606    // a fetch direction by calling the method SetFetchDirection(), 
0607    // the return value is implementation-specific.
0608    //
0609    // Returns:
0610    //       the default fetch direction for result sets generated 
0611    //       from this TSQLStatement object
0612    // Throws:
0613    //       TSQLException - if a database access error occurs
0614 
0615    Int_t return_value = 0;
0616    return return_value;
0617 }
0618 
0619 //___________________________________________________________________
0620 void TSQLStatement::SetFetchSize( Int_t rows )
0621 {
0622    // Gives the driver a hint as to the number of rows that
0623    // should be fetched from the database when more rows are needed. 
0624    // The number of rows specified affects only result sets created 
0625    // using this statement. If the value specified is zero, then the
0626    // hint is ignored. The default value is zero.
0627    //
0628    // Parameters:
0629    //       rows - the number of rows to fetch
0630    // Throws:
0631    //       TSQLException - if a database access error occurs, or 
0632    //       the condition 0 <= rows <= GetMaxRows() is not satisfied.
0633 
0634 }
0635 
0636 //___________________________________________________________________
0637 Int_t TSQLStatement::GetFetchSize()
0638 {
0639    // Retrieves the number of result set rows that is the default 
0640    // fetch size for result sets generated from this TSQLStatement 
0641    // object. If this TSQLStatement object has not set a fetch size
0642    // by calling the method SetFetchSize(), the return value is
0643    // implementation-specific.
0644    //
0645    // Returns:
0646    //       the default fetch size for result sets generated from 
0647    //       this TSQLStatement object
0648    // Throws:
0649    //       TSQLException - if a database access error occurs
0650    
0651    Int_t return_value = 0;
0652    return return_value;
0653 }
0654 
0655 //___________________________________________________________________
0656 Int_t TSQLStatement::GetResultSetConcurrency()
0657 {
0658    // Retrieves the result set concurrency.
0659    //
0660    // enum EResultSetConcurrency{
0661    //       kCONCUR_READ_ONLY,
0662    //       kCONCUR_UPDATABLE
0663    // };
0664 
0665    return kCONCUR_UPDATABLE;  // MyODBC says "Anything goes" 
0666 }
0667 
0668 //___________________________________________________________________
0669 Int_t TSQLStatement::GetResultSetType()
0670 {
0671    // Determine the result set type.
0672    //
0673    // enum EResultSetType{
0674    //       kTYPE_FORWARD_ONLY,
0675    //       kTYPE_SCROLL_INSENSITIVE,
0676    //       kTYPE_SCROLL_SENSITIVE
0677    // };
0678    //
0679      
0680    MySQLStatementPrivate* imp = (MySQLStatementPrivate*)fImp;
0681    return imp->fCursorType;
0682 }
0683 
0684 //___________________________________________________________________
0685 void TSQLStatement::AddBatch( const TString& sql )
0686 {
0687    // Adds a SQL command to the current batch of commmands for
0688    // the statement. This method is optional.
0689    //
0690    // Parameters:
0691    //       sql - typically this is a static SQL INSERT or UPDATE 
0692    //       statement
0693    // Throws:
0694    //       TSQLException - if a database access error occurs, or 
0695    //       the  driver does not support batch statements
0696 
0697 }
0698 
0699 //___________________________________________________________________
0700 void TSQLStatement::ClearBatch()
0701 {
0702    // Makes the set of commands in the current batch empty. This
0703    // method is optional.
0704    //
0705    // Throws:
0706    //       TSQLException - if a database access error occurs or 
0707    //       the driver does not support batch statements
0708 
0709 }
0710 
0711 //___________________________________________________________________
0712 Int_t* TSQLStatement::ExecuteBatch()
0713 {
0714    // Submits a batch of commands to the database for execution.
0715    // This method is optional.
0716    //
0717    // Returns:
0718    //       an array of update counts containing one element for 
0719    //       each command in the batch. The array is ordered 
0720    //       according  to the order in which commands were inserted 
0721    //       into the  batch.
0722    //
0723    // Throws:
0724    //       TSQLException - if a database access error occurs or 
0725    //       the driver  does not support batch statements
0726 
0727    return 0;
0728 }