Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // $Id: MySQLCallableStatement.cxx,v 1.1.1.1 2004/02/18 20:58:02 dave Exp $
0002 //*-- Author : Valeriy Onuchin 04/03/2001
0003 //
0004 
0005 /////////////////////////////////////////////////////////////////////
0006 //
0007 // A TSQLCallableStatement extends the functionality of a 
0008 // TSQLPreparedStatement, by allowing output parameters.
0009 //
0010 // The ODBC escapes for calling stored procedures and functions 
0011 // should be used. A procedure call is prepared like this:
0012 //
0013 // TSQLCallableStatement* cstmt = 
0014 //             con->PrepareCall("{call my_procedure(?,?,?)}");
0015 //
0016 // 
0017 // And for a function call (a procedure that returns a value), the
0018 // following syntax should be used:
0019 //
0020 // TSQLCallableStatement* cstmt=
0021 //                   con->PrepareCall("{?=call my_function(?,?)}"); 
0022 // 
0023 // All parameters in a TSQLCallableStatement  are treated
0024 // as input/output parameters, unless they are registered as
0025 // output-only parameters with registerOutParameter(). Note that
0026 // output-only parameters must be registered with their proper
0027 // SQL type prior to executing a TSQLCallableStatement.
0028 //
0029 // The interface used to execute SQL stored procedures. It provides a
0030 // stored procedure SQL escape that allows stored procedures to be 
0031 // called in a standard way for all RDBMSs. This escape syntax has 
0032 // one form that includes a result parameter and one that does not. 
0033 // If used, the result parameter must be registered as an OUT parameter.
0034 //  The other parameters can be used for input, output or both. 
0035 ///
0036 // Parameters are referred to sequentially, by number. 
0037 // The first parameter is 1. 
0038 //
0039 //        {?= call ?procedure-name?[?arg1?,?arg2?, ...]}
0040 //        {call ?procedure-name?[?arg1?,?arg2?, ...]}
0041 //      
0042 // IN parameter values are set using the set methods inherited from
0043 // TSQLPreparedStatement. The type of all OUT parameters must be 
0044 // registered prior to executing the stored procedure; their values
0045 // are retrieved after execution via the get methods provided here. 
0046 //
0047 // A TSQLCallableStatement can return one TSQLResultSet or multiple 
0048 // TSQLResultSet objets. Multiple TSQLResultSet objects are handled 
0049 // using operations inherited from TSQLStatement. 
0050 //
0051 // For maximum portability, a call's TSQLResultSet objects and update 
0052 // counts should be processed prior to getting the values of output 
0053 // parameters. 
0054 //
0055 // See also: 
0056 //     TSQLConnection::PrepareCall(TString), TSQLResultSet
0057 //     TSQLStatement TSQLPreparedStatement 
0058 //
0059 // Note: 
0060 //       - Callable statments not supported by MySQL.
0061 //
0062 /////////////////////////////////////////////////////////////////////
0063 
0064 #include <RDBC/TSQLCallableStatement.h>
0065 
0066 ClassImpQ(TSQLCallableStatement)
0067 
0068 /////////////////////////////////////////////////////////////////////
0069 //___________________________________________________________________
0070 TSQLCallableStatement::TSQLCallableStatement(TSQLConnection* con,void* imp):
0071                         TSQLPreparedStatement(con,imp)
0072    
0073 {
0074 
0075 }
0076 
0077 //___________________________________________________________________
0078 void TSQLCallableStatement::RegisterOutParameter(Int_t parameterIndex,
0079                                                  Int_t sqlType)
0080 {
0081    //  Registers the OUT parameter in ordinal position parameterIndex to
0082    //  the type sqlType. All OUT parameters must be registered before
0083    //  a stored procedure is executed. 
0084    //
0085    //  The type specified by sqlType for an OUT parameter determines
0086    //  the  type that must be used in the get method to read the value
0087    //  of that parameter. 
0088    //
0089    //  Parameters:
0090    //
0091    //      parameterIndex - the first parameter is 1, 
0092    //                       the second is 2, and so on
0093    //      sqlType - the type code defined by ESQLTypes (see TSQLTypes.h)
0094    //                If the parameter is of type kNumeric, 
0095    //                the version of registerOutParameter that 
0096    //                accepts a scale value should be used.
0097    //  Throws:
0098    //      TSQLException - if a database access error occurs
0099    //  See Also: 
0100    //      TSQLTypes.h 
0101    //
0102    // enum ESQLTypes { 
0103    //       kBIGINT = -5,
0104    //       kBINARY = -2,
0105    //       kBIT = -7,
0106    //       kCHAR = 1,
0107    // #ifdef ODBC_VER_LESS_30 
0108    //       kDATE = 9,
0109    //       kTIME = 10,
0110    //       kTIMESTAMP = 11,
0111    // #endif     
0112    //       kDATE = 91,
0113    //       kTIME = 92,
0114    //       kTIMESTAMP = 93,
0115    //       kSMALLINT = 5,
0116    //       kDECIMAL = 3,
0117    //       kDOUBLE = 8,
0118    //       kFLOAT = 6,
0119    //       kINTEGER = 4,
0120    //       kLONGVARBINARY = -4,
0121    //       kLONGVARCHAR = -1,
0122    //       kNUMERIC = 2,
0123    //       kREAL = 7,
0124    //       kTINYINT = -6,
0125    //       kVARBINARY = -3,
0126    //       kVARCHAR  = 12 
0127    // };
0128 
0129 }
0130 
0131 //___________________________________________________________________
0132 void TSQLCallableStatement::RegisterOutParameter(Int_t parameterIndex,
0133                                                  Int_t sqlType,
0134                                                  Int_t scale)
0135 {
0136    //  Registers the parameter in ordinal position parameterIndex to be
0137    //  of type sqlType. This method must be called before a stored
0138    //  procedure is executed. 
0139    //
0140    //  The type specified by sqlType for an OUT parameter determines
0141    //  the  type that must be used in the get method to read the value
0142    //  of that parameter. 
0143    //
0144    //  This version of registerOutParameter should be used when the
0145    //  parameter is of type kNUMERIC.
0146    //  
0147    //  Parameters:
0148    //     parameterIndex -  the first parameter is 1, 
0149    //                       the second is 2, and so on
0150    //     sqlType -  SQL type code defined in TSQLTypes.h
0151    //     scale -    the desired number of digits to the right of the
0152    //                decimal point. It must be greater than or equal 
0153    //                to zero.
0154    //  Throws:
0155    //      TSQLException - if a database access error occurs
0156    //  See Also: 
0157    //      TSQLTypes.h
0158    //
0159    // enum ESQLTypes { 
0160    //       kBIGINT = -5,
0161    //       kBINARY = -2,
0162    //       kBIT = -7,
0163    //       kCHAR = 1,
0164    // #ifdef ODBC_VER_LESS_30 
0165    //       kDATE = 9,
0166    //       kTIME = 10,
0167    //       kTIMESTAMP = 11,
0168    // #endif     
0169    //       kDATE = 91,
0170    //       kTIME = 92,
0171    //       kTIMESTAMP = 93,
0172    //       kSMALLINT = 5,
0173    //       kDECIMAL = 3,
0174    //       kDOUBLE = 8,
0175    //       kFLOAT = 6,
0176    //       kINTEGER = 4,
0177    //       kLONGVARBINARY = -4,
0178    //       kLONGVARCHAR = -1,
0179    //       kNUMERIC = 2,
0180    //       kREAL = 7,
0181    //       kTINYINT = -6,
0182    //       kVARBINARY = -3,
0183    //       kVARCHAR  = 12 
0184    // };
0185 
0186 }
0187 
0188 //___________________________________________________________________
0189 Bool_t TSQLCallableStatement::WasNull()
0190 {
0191    // Indicates whether or not the last OUT parameter read had 
0192    // the value of SQL NULL. Note that this method should be 
0193    // called only after calling the get method; otherwise, there 
0194    // is no value to use in determining whether it is null or not.
0195    //  
0196    //  Returns:
0197    //      kTRUE if the last parameter read was SQL NULL; 
0198    //      kFALSE otherwise.
0199    //  Throws:
0200    //      TSQLException - if a database access error occurs
0201 
0202    Bool_t return_value = kFALSE;
0203    return return_value;
0204 }
0205 
0206 //___________________________________________________________________
0207 TString TSQLCallableStatement::GetString( Int_t parameterIndex )
0208 {
0209    // Retrieves the value of a  parameter as a TString. 
0210    //
0211    // For the fixed-length type kCHAR, the TString object returned 
0212    // has exactly the same value the kCHAR value had in the database,
0213    // including any padding added by the database.
0214    //
0215    //  Parameters:
0216    //      parameterIndex - the first parameter is 1, 
0217    //                       the second is 2,  and so on
0218    //  Returns:
0219    //      the parameter value. If the value is SQL NULL, 
0220    //                           the result is null.
0221    //  Throws:
0222    //      TSQLException - if a database access error occurs
0223    
0224    TString str;
0225    return str;
0226 }
0227 
0228 //___________________________________________________________________
0229 Bool_t TSQLCallableStatement::GetBoolean( Int_t parameterIndex )
0230 {
0231    //  Gets the value of a parameter as a Bool_t 
0232    //  
0233    //  Parameters:
0234    //       parameterIndex -  the first parameter is 1, 
0235    //                         the second is 2, and so on
0236    //  Returns:
0237    //       the parameter value. If the value is SQL NULL, 
0238    //       the result is kFALSE.
0239    //  Throws:
0240    //      TSQLException - if a database access error occurs
0241 
0242    Bool_t return_value = kFALSE;
0243    return return_value;
0244 }
0245 
0246 //___________________________________________________________________
0247 Char_t TSQLCallableStatement::GetByte( Int_t parameterIndex )
0248 {
0249    // Gets the value of a parameter as a byte .
0250    //
0251    //  Parameters:
0252    //      parameterIndex - the first parameter is 1, 
0253    //                       the second is 2, and so on
0254    //  Returns:
0255    //      the parameter value. If the value is SQL NULL, 
0256    //      the result is 0.
0257    //  Throws:
0258    //      TSQLException - if a database access error occurs
0259    
0260    Char_t return_value = 0;
0261    return return_value;
0262 }
0263 
0264 //___________________________________________________________________
0265 Short_t TSQLCallableStatement::GetShort( Int_t parameterIndex )
0266 {
0267    // Gets the value of a parameter as a Short_t .
0268    //  
0269    //  Parameters:
0270    //       parameterIndex - the first parameter is 1, 
0271    //                        the second is 2, and so on
0272    //  Returns:
0273    //       the parameter value. If the value is SQL NULL, 
0274    //       the result is 0.
0275    //   Throws:
0276    //       TSQLException - if a database access error occurs
0277 
0278    Short_t return_value = 0;
0279    return return_value;
0280 }
0281 
0282 //___________________________________________________________________
0283 Int_t TSQLCallableStatement::GetInt( Int_t parameterIndex )
0284 {
0285    // Gets the value of a parameter as an Int_t .
0286    //
0287    //  Parameters:
0288    //       parameterIndex -  the first parameter is 1, the second is 2,
0289    //                         and so on
0290    //  Returns:
0291    //       the parameter value. If the value is SQL NULL, 
0292    //       the result is 0.
0293    //  Throws:
0294    //       TSQLException - if a database access error occurs
0295 
0296    Int_t return_value = 0;
0297    return return_value;
0298 }
0299 
0300 //___________________________________________________________________
0301 Long_t TSQLCallableStatement::GetLong( Int_t parameterIndex )
0302 {
0303    // Gets the value of a parameter as a Long_t .
0304    //
0305    //  Parameters:
0306    //       parameterIndex - the first parameter is 1, 
0307    //                       the second is 2, and so on
0308    //  Returns:
0309    //       the parameter value. If the value is SQL NULL, 
0310    //       the result is 0.
0311    //  Throws:
0312    //       TSQLException - if a database access error occurs
0313 
0314    Long_t return_value = 0;
0315    return return_value;
0316 }
0317 
0318 //___________________________________________________________________
0319 Float_t TSQLCallableStatement::GetFloat( Int_t parameterIndex )
0320 {
0321    // Gets the value of a parameter as a Float_t .
0322    //
0323    // Parameters:
0324    //       parameterIndex - the first parameter is 1, 
0325    //                       the second is 2, and so on
0326    //  Returns:
0327    //       the parameter value. If the value is SQL NULL, 
0328    //       the result is 0.
0329    //  Throws:
0330    //       TSQLException - if a database access error occurs
0331 
0332    Float_t return_value = 0;
0333    return return_value;
0334 }
0335 
0336 //___________________________________________________________________
0337 Double_t TSQLCallableStatement::GetDouble( Int_t parameterIndex )
0338 {
0339    // Gets the value of a parameter as a Double_t .
0340    //
0341    //  Parameters:
0342    //       parameterIndex - the first parameter is 1, 
0343    //                       the second is 2, and so on
0344    //  Returns:
0345    //       the parameter value. If the value is SQL NULL, 
0346    //       the result is 0.
0347    //  Throws:
0348    //       TSQLException - if a database access error occurs
0349 
0350    Double_t return_value = 0;
0351    return return_value;
0352 }
0353 
0354 //___________________________________________________________________
0355 TArrayC TSQLCallableStatement::GetBytes( Int_t parameterIndex )
0356 {
0357    // Gets the value of a parameter as an array of byte values.
0358    //
0359    //  Parameters:
0360    //       parameterIndex -  the first parameter is 1, 
0361    //                         the second is 2, and so on
0362    //  Returns:
0363    //       the parameter value. If the value is SQL NULL, 
0364    //       the result is null.
0365    //  Throws:
0366    //       TSQLException - if a database access error occurs
0367 
0368    TArrayC array;
0369    return array;
0370 }
0371 
0372 //___________________________________________________________________
0373 TSQLDate TSQLCallableStatement::GetDate( Int_t parameterIndex )
0374 {
0375    //  Gets the value of a parameter as a TSQLDate object.
0376    //
0377    //  Parameters:
0378    //       parameterIndex -  the first parameter is 1, 
0379    //                         the second is 2, and so on
0380    //  Returns:
0381    //       the parameter value. If the value is SQL NULL, 
0382    //       the result is null.
0383    //  Throws:
0384    //       TSQLException - if a database access error occurs
0385 
0386    TSQLDate return_value;
0387    return return_value;
0388 }
0389 
0390 //___________________________________________________________________
0391 TSQLTime TSQLCallableStatement::GetTime( Int_t parameterIndex )
0392 {
0393     // Get the value of a parameter as a TSQLTime object.
0394     // 
0395     // Parameters:
0396     //      parameterIndex -  the first parameter is 1, 
0397     //                        the second is 2, and so on
0398     // Returns:
0399     //      the parameter value. If the value is SQL NULL, 
0400     //      the result is null.
0401     // Throws:
0402     //      TSQLException - if a database access error occurs
0403 
0404    TSQLTime return_value;
0405    return return_value;
0406 }
0407 
0408 //___________________________________________________________________
0409 TSQLTimestamp TSQLCallableStatement::GetTimestamp( Int_t parameterIndex )
0410 {
0411     // Gets the value of a parameter as a TSQLTimestamp object.
0412     //  
0413     // Parameters:
0414     //      parameterIndex -  the first parameter is 1, 
0415     //                        the second is 2, and so on
0416     // Returns:
0417     //      the parameter value. If the value is SQL NULL, 
0418     //      the result is null.
0419     // Throws:
0420     //      TSQLException - if a database access error occurs
0421    
0422    TSQLTimestamp return_value;
0423    return return_value;
0424 }