Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MySQLCallableStatement.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MySQLCallableStatement.cxx
1 // $Id: MySQLCallableStatement.cxx,v 1.1.1.1 2004/02/18 20:58:02 dave Exp $
2 //*-- Author : Valeriy Onuchin 04/03/2001
3 //
4 
6 //
7 // A TSQLCallableStatement extends the functionality of a
8 // TSQLPreparedStatement, by allowing output parameters.
9 //
10 // The ODBC escapes for calling stored procedures and functions
11 // should be used. A procedure call is prepared like this:
12 //
13 // TSQLCallableStatement* cstmt =
14 // con->PrepareCall("{call my_procedure(?,?,?)}");
15 //
16 //
17 // And for a function call (a procedure that returns a value), the
18 // following syntax should be used:
19 //
20 // TSQLCallableStatement* cstmt=
21 // con->PrepareCall("{?=call my_function(?,?)}");
22 //
23 // All parameters in a TSQLCallableStatement are treated
24 // as input/output parameters, unless they are registered as
25 // output-only parameters with registerOutParameter(). Note that
26 // output-only parameters must be registered with their proper
27 // SQL type prior to executing a TSQLCallableStatement.
28 //
29 // The interface used to execute SQL stored procedures. It provides a
30 // stored procedure SQL escape that allows stored procedures to be
31 // called in a standard way for all RDBMSs. This escape syntax has
32 // one form that includes a result parameter and one that does not.
33 // If used, the result parameter must be registered as an OUT parameter.
34 // The other parameters can be used for input, output or both.
36 // Parameters are referred to sequentially, by number.
37 // The first parameter is 1.
38 //
39 // {?= call ?procedure-name?[?arg1?,?arg2?, ...]}
40 // {call ?procedure-name?[?arg1?,?arg2?, ...]}
41 //
42 // IN parameter values are set using the set methods inherited from
43 // TSQLPreparedStatement. The type of all OUT parameters must be
44 // registered prior to executing the stored procedure; their values
45 // are retrieved after execution via the get methods provided here.
46 //
47 // A TSQLCallableStatement can return one TSQLResultSet or multiple
48 // TSQLResultSet objets. Multiple TSQLResultSet objects are handled
49 // using operations inherited from TSQLStatement.
50 //
51 // For maximum portability, a call's TSQLResultSet objects and update
52 // counts should be processed prior to getting the values of output
53 // parameters.
54 //
55 // See also:
56 // TSQLConnection::PrepareCall(TString), TSQLResultSet
57 // TSQLStatement TSQLPreparedStatement
58 //
59 // Note:
60 // - Callable statments not supported by MySQL.
61 //
63 
65 
67 
68 
69 //___________________________________________________________________
71  TSQLPreparedStatement(con,imp)
72 
73 {
74 
75 }
76 
77 //___________________________________________________________________
79  Int_t sqlType)
80 {
81  // Registers the OUT parameter in ordinal position parameterIndex to
82  // the type sqlType. All OUT parameters must be registered before
83  // a stored procedure is executed.
84  //
85  // The type specified by sqlType for an OUT parameter determines
86  // the type that must be used in the get method to read the value
87  // of that parameter.
88  //
89  // Parameters:
90  //
91  // parameterIndex - the first parameter is 1,
92  // the second is 2, and so on
93  // sqlType - the type code defined by ESQLTypes (see TSQLTypes.h)
94  // If the parameter is of type kNumeric,
95  // the version of registerOutParameter that
96  // accepts a scale value should be used.
97  // Throws:
98  // TSQLException - if a database access error occurs
99  // See Also:
100  // TSQLTypes.h
101  //
102  // enum ESQLTypes {
103  // kBIGINT = -5,
104  // kBINARY = -2,
105  // kBIT = -7,
106  // kCHAR = 1,
107  // #ifdef ODBC_VER_LESS_30
108  // kDATE = 9,
109  // kTIME = 10,
110  // kTIMESTAMP = 11,
111  // #endif
112  // kDATE = 91,
113  // kTIME = 92,
114  // kTIMESTAMP = 93,
115  // kSMALLINT = 5,
116  // kDECIMAL = 3,
117  // kDOUBLE = 8,
118  // kFLOAT = 6,
119  // kINTEGER = 4,
120  // kLONGVARBINARY = -4,
121  // kLONGVARCHAR = -1,
122  // kNUMERIC = 2,
123  // kREAL = 7,
124  // kTINYINT = -6,
125  // kVARBINARY = -3,
126  // kVARCHAR = 12
127  // };
128 
129 }
130 
131 //___________________________________________________________________
133  Int_t sqlType,
134  Int_t scale)
135 {
136  // Registers the parameter in ordinal position parameterIndex to be
137  // of type sqlType. This method must be called before a stored
138  // procedure is executed.
139  //
140  // The type specified by sqlType for an OUT parameter determines
141  // the type that must be used in the get method to read the value
142  // of that parameter.
143  //
144  // This version of registerOutParameter should be used when the
145  // parameter is of type kNUMERIC.
146  //
147  // Parameters:
148  // parameterIndex - the first parameter is 1,
149  // the second is 2, and so on
150  // sqlType - SQL type code defined in TSQLTypes.h
151  // scale - the desired number of digits to the right of the
152  // decimal point. It must be greater than or equal
153  // to zero.
154  // Throws:
155  // TSQLException - if a database access error occurs
156  // See Also:
157  // TSQLTypes.h
158  //
159  // enum ESQLTypes {
160  // kBIGINT = -5,
161  // kBINARY = -2,
162  // kBIT = -7,
163  // kCHAR = 1,
164  // #ifdef ODBC_VER_LESS_30
165  // kDATE = 9,
166  // kTIME = 10,
167  // kTIMESTAMP = 11,
168  // #endif
169  // kDATE = 91,
170  // kTIME = 92,
171  // kTIMESTAMP = 93,
172  // kSMALLINT = 5,
173  // kDECIMAL = 3,
174  // kDOUBLE = 8,
175  // kFLOAT = 6,
176  // kINTEGER = 4,
177  // kLONGVARBINARY = -4,
178  // kLONGVARCHAR = -1,
179  // kNUMERIC = 2,
180  // kREAL = 7,
181  // kTINYINT = -6,
182  // kVARBINARY = -3,
183  // kVARCHAR = 12
184  // };
185 
186 }
187 
188 //___________________________________________________________________
190 {
191  // Indicates whether or not the last OUT parameter read had
192  // the value of SQL NULL. Note that this method should be
193  // called only after calling the get method; otherwise, there
194  // is no value to use in determining whether it is null or not.
195  //
196  // Returns:
197  // kTRUE if the last parameter read was SQL NULL;
198  // kFALSE otherwise.
199  // Throws:
200  // TSQLException - if a database access error occurs
201 
202  Bool_t return_value = kFALSE;
203  return return_value;
204 }
205 
206 //___________________________________________________________________
207 TString TSQLCallableStatement::GetString( Int_t parameterIndex )
208 {
209  // Retrieves the value of a parameter as a TString.
210  //
211  // For the fixed-length type kCHAR, the TString object returned
212  // has exactly the same value the kCHAR value had in the database,
213  // including any padding added by the database.
214  //
215  // Parameters:
216  // parameterIndex - the first parameter is 1,
217  // the second is 2, and so on
218  // Returns:
219  // the parameter value. If the value is SQL NULL,
220  // the result is null.
221  // Throws:
222  // TSQLException - if a database access error occurs
223 
224  TString str;
225  return str;
226 }
227 
228 //___________________________________________________________________
229 Bool_t TSQLCallableStatement::GetBoolean( Int_t parameterIndex )
230 {
231  // Gets the value of a parameter as a Bool_t
232  //
233  // Parameters:
234  // parameterIndex - the first parameter is 1,
235  // the second is 2, and so on
236  // Returns:
237  // the parameter value. If the value is SQL NULL,
238  // the result is kFALSE.
239  // Throws:
240  // TSQLException - if a database access error occurs
241 
242  Bool_t return_value = kFALSE;
243  return return_value;
244 }
245 
246 //___________________________________________________________________
247 Char_t TSQLCallableStatement::GetByte( Int_t parameterIndex )
248 {
249  // Gets the value of a parameter as a byte .
250  //
251  // Parameters:
252  // parameterIndex - the first parameter is 1,
253  // the second is 2, and so on
254  // Returns:
255  // the parameter value. If the value is SQL NULL,
256  // the result is 0.
257  // Throws:
258  // TSQLException - if a database access error occurs
259 
260  Char_t return_value = 0;
261  return return_value;
262 }
263 
264 //___________________________________________________________________
265 Short_t TSQLCallableStatement::GetShort( Int_t parameterIndex )
266 {
267  // Gets the value of a parameter as a Short_t .
268  //
269  // Parameters:
270  // parameterIndex - the first parameter is 1,
271  // the second is 2, and so on
272  // Returns:
273  // the parameter value. If the value is SQL NULL,
274  // the result is 0.
275  // Throws:
276  // TSQLException - if a database access error occurs
277 
278  Short_t return_value = 0;
279  return return_value;
280 }
281 
282 //___________________________________________________________________
283 Int_t TSQLCallableStatement::GetInt( Int_t parameterIndex )
284 {
285  // Gets the value of a parameter as an Int_t .
286  //
287  // Parameters:
288  // parameterIndex - the first parameter is 1, the second is 2,
289  // and so on
290  // Returns:
291  // the parameter value. If the value is SQL NULL,
292  // the result is 0.
293  // Throws:
294  // TSQLException - if a database access error occurs
295 
296  Int_t return_value = 0;
297  return return_value;
298 }
299 
300 //___________________________________________________________________
301 Long_t TSQLCallableStatement::GetLong( Int_t parameterIndex )
302 {
303  // Gets the value of a parameter as a Long_t .
304  //
305  // Parameters:
306  // parameterIndex - the first parameter is 1,
307  // the second is 2, and so on
308  // Returns:
309  // the parameter value. If the value is SQL NULL,
310  // the result is 0.
311  // Throws:
312  // TSQLException - if a database access error occurs
313 
314  Long_t return_value = 0;
315  return return_value;
316 }
317 
318 //___________________________________________________________________
319 Float_t TSQLCallableStatement::GetFloat( Int_t parameterIndex )
320 {
321  // Gets the value of a parameter as a Float_t .
322  //
323  // Parameters:
324  // parameterIndex - the first parameter is 1,
325  // the second is 2, and so on
326  // Returns:
327  // the parameter value. If the value is SQL NULL,
328  // the result is 0.
329  // Throws:
330  // TSQLException - if a database access error occurs
331 
332  Float_t return_value = 0;
333  return return_value;
334 }
335 
336 //___________________________________________________________________
337 Double_t TSQLCallableStatement::GetDouble( Int_t parameterIndex )
338 {
339  // Gets the value of a parameter as a Double_t .
340  //
341  // Parameters:
342  // parameterIndex - the first parameter is 1,
343  // the second is 2, and so on
344  // Returns:
345  // the parameter value. If the value is SQL NULL,
346  // the result is 0.
347  // Throws:
348  // TSQLException - if a database access error occurs
349 
350  Double_t return_value = 0;
351  return return_value;
352 }
353 
354 //___________________________________________________________________
355 TArrayC TSQLCallableStatement::GetBytes( Int_t parameterIndex )
356 {
357  // Gets the value of a parameter as an array of byte values.
358  //
359  // Parameters:
360  // parameterIndex - the first parameter is 1,
361  // the second is 2, and so on
362  // Returns:
363  // the parameter value. If the value is SQL NULL,
364  // the result is null.
365  // Throws:
366  // TSQLException - if a database access error occurs
367 
368  TArrayC array;
369  return array;
370 }
371 
372 //___________________________________________________________________
374 {
375  // Gets the value of a parameter as a TSQLDate object.
376  //
377  // Parameters:
378  // parameterIndex - the first parameter is 1,
379  // the second is 2, and so on
380  // Returns:
381  // the parameter value. If the value is SQL NULL,
382  // the result is null.
383  // Throws:
384  // TSQLException - if a database access error occurs
385 
386  TSQLDate return_value;
387  return return_value;
388 }
389 
390 //___________________________________________________________________
392 {
393  // Get the value of a parameter as a TSQLTime object.
394  //
395  // Parameters:
396  // parameterIndex - the first parameter is 1,
397  // the second is 2, and so on
398  // Returns:
399  // the parameter value. If the value is SQL NULL,
400  // the result is null.
401  // Throws:
402  // TSQLException - if a database access error occurs
403 
404  TSQLTime return_value;
405  return return_value;
406 }
407 
408 //___________________________________________________________________
410 {
411  // Gets the value of a parameter as a TSQLTimestamp object.
412  //
413  // Parameters:
414  // parameterIndex - the first parameter is 1,
415  // the second is 2, and so on
416  // Returns:
417  // the parameter value. If the value is SQL NULL,
418  // the result is null.
419  // Throws:
420  // TSQLException - if a database access error occurs
421 
422  TSQLTimestamp return_value;
423  return return_value;
424 }