Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ODBCCallableStatement.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ODBCCallableStatement.cxx
1 // $Id: ODBCCallableStatement.cxx,v 1.2 2007/02/28 21:33:39 phnxbld Exp $
2 //*-- Author : Valeriy Onuchin 14/02/2000
3 //
4 
5 /**************************************************************************
6 
7  ROOT wrappers of libodbc++ library
8 
9  Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Library General Public
13  License as published by the Free Software Foundation; either
14  version 2 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Library General Public License for more details.
20 
21  You should have received a copy of the GNU Library General Public License
22  along with this library; see the file COPYING. If not, write to
23  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  Boston, MA 02111-1307, USA.
25 
26 **************************************************************************/
27 
29 //
30 // A TSQLCallableStatement extends the functionality of a
31 // TSQLPreparedStatement, by allowing output parameters.
32 //
33 // The ODBC escapes for calling stored procedures and functions
34 // should be used. A procedure call is prepared like this:
35 //
36 // TSQLCallableStatement* cstmt =
37 // con->PrepareCall("{call my_procedure(?,?,?)}");
38 //
39 //
40 // And for a function call (a procedure that returns a value), the
41 // following syntax should be used:
42 //
43 // TSQLCallableStatement* cstmt=
44 // con->PrepareCall("{?=call my_function(?,?)}");
45 //
46 // All parameters in a TSQLCallableStatement are treated
47 // as input/output parameters, unless they are registered as
48 // output-only parameters with registerOutParameter(). Note that
49 // output-only parameters must be registered with their proper
50 // SQL type prior to executing a TSQLCallableStatement.
51 //
52 // The interface used to execute SQL stored procedures. It provides a
53 // stored procedure SQL escape that allows stored procedures to be
54 // called in a standard way for all RDBMSs. This escape syntax has
55 // one form that includes a result parameter and one that does not.
56 // If used, the result parameter must be registered as an OUT parameter.
57 // The other parameters can be used for input, output or both.
59 // Parameters are referred to sequentially, by number.
60 // The first parameter is 1.
61 //
62 // {?= call ?procedure-name?[?arg1?,?arg2?, ...]}
63 // {call ?procedure-name?[?arg1?,?arg2?, ...]}
64 //
65 // IN parameter values are set using the set methods inherited from
66 // TSQLPreparedStatement. The type of all OUT parameters must be
67 // registered prior to executing the stored procedure; their values
68 // are retrieved after execution via the get methods provided here.
69 //
70 // A TSQLCallableStatement can return one TSQLResultSet or multiple
71 // TSQLResultSet objets. Multiple TSQLResultSet objects are handled
72 // using operations inherited from TSQLStatement.
73 //
74 // For maximum portability, a call's TSQLResultSet objects and update
75 // counts should be processed prior to getting the values of output
76 // parameters.
77 //
78 // See also:
79 // TSQLConnection::PrepareCall(TString), TSQLResultSet
80 // TSQLStatement TSQLPreparedStatement
81 //
82 // Note:
83 // - Callable statments not supported by MySQL.
84 // - I failed to use with OpenLink ODBC driver to Oracle
85 //
87 
88 #include <sstream>
89 #include "ODBCCallableStatement.h"
90 #include <RDBC/odbc++/statement.h>
93 #include <iostream>
94 #include "ODBCResultSet.h"
95 #include <RDBC/odbc++/resultset.h>
96 #include <TList.h>
97 
98 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
99 #include <TBufferFile.h>
100 #endif
101 
102 
103 using namespace odbc;
104 
106 
107 
108  //___________________________________________________________________
110  TSQLCallableStatement(con,imp)
111 
112 {
113  // ctor
114 }
115 
116 //___________________________________________________________________
118 {
119  // dtor
120 
122 
123  try {
124  if(imp) delete imp;
125  } catch(odbc::SQLException& e) {
128  e.getErrorCode()) );
129  }
130 
131  // implementation part of fCurrentResult is deleted with statement
132  if(fCurrentResult) ((ODBCResultSet*)fCurrentResult)->fImp = 0;
133  fImp = 0;
134 }
135 
136 //___________________________________________________________________
138  Int_t sqlType)
139 {
140  // Registers the OUT parameter in ordinal position parameterIndex to
141  // the type sqlType. All OUT parameters must be registered before
142  // a stored procedure is executed.
143  //
144  // The type specified by sqlType for an OUT parameter determines
145  // the type that must be used in the get method to read the value
146  // of that parameter.
147  //
148  // Parameters:
149  //
150  // parameterIndex - the first parameter is 1,
151  // the second is 2, and so on
152  // sqlType - the type code defined by ESQLTypes (see TSQLTypes.h)
153  // If the parameter is of type kNumeric,
154  // the version of registerOutParameter that
155  // accepts a scale value should be used.
156  // Throws:
157  // TSQLException - if a database access error occurs
158  // See Also:
159  // TSQLTypes.h
160  //
161  // enum ESQLTypes {
162  // kBIGINT = -5,
163  // kBINARY = -2,
164  // kBIT = -7,
165  // kCHAR = 1,
166  // #ifdef ODBC_VER_LESS_30
167  // kDATE = 9,
168  // kTIME = 10,
169  // kTIMESTAMP = 11,
170  // #endif
171  // kDATE = 91,
172  // kTIME = 92,
173  // kTIMESTAMP = 93,
174  // kSMALLINT = 5,
175  // kDECIMAL = 3,
176  // kDOUBLE = 8,
177  // kFLOAT = 6,
178  // kINTEGER = 4,
179  // kLONGVARBINARY = -4,
180  // kLONGVARCHAR = -1,
181  // kNUMERIC = 2,
182  // kREAL = 7,
183  // kTINYINT = -6,
184  // kVARBINARY = -3,
185  // kVARCHAR = 12
186  // };
187 
188  if(!fImp) { Destroyed(); return; }
190 
191  try {
192  stmt->registerOutParameter( parameterIndex,sqlType );
193 
194  } catch(odbc::SQLException& e) {
197  e.getErrorCode()) );
198  }
199 }
200 
201 //___________________________________________________________________
203  Int_t sqlType,
204  Int_t scale)
205 {
206  // Registers the parameter in ordinal position parameterIndex to be
207  // of type sqlType. This method must be called before a stored
208  // procedure is executed.
209  //
210  // The type specified by sqlType for an OUT parameter determines
211  // the type that must be used in the get method to read the value
212  // of that parameter.
213  //
214  // This version of registerOutParameter should be used when the
215  // parameter is of type kNUMERIC.
216  //
217  // Parameters:
218  // parameterIndex - the first parameter is 1,
219  // the second is 2, and so on
220  // sqlType - SQL type code defined in TSQLTypes.h
221  // scale - the desired number of digits to the right of the
222  // decimal point. It must be greater than or equal
223  // to zero.
224  // Throws:
225  // TSQLException - if a database access error occurs
226  // See Also:
227  // TSQLTypes.h
228  //
229  // enum ESQLTypes {
230  // kBIGINT = -5,
231  // kBINARY = -2,
232  // kBIT = -7,
233  // kCHAR = 1,
234  // #ifdef ODBC_VER_LESS_30
235  // kDATE = 9,
236  // kTIME = 10,
237  // kTIMESTAMP = 11,
238  // #endif
239  // kDATE = 91,
240  // kTIME = 92,
241  // kTIMESTAMP = 93,
242  // kSMALLINT = 5,
243  // kDECIMAL = 3,
244  // kDOUBLE = 8,
245  // kFLOAT = 6,
246  // kINTEGER = 4,
247  // kLONGVARBINARY = -4,
248  // kLONGVARCHAR = -1,
249  // kNUMERIC = 2,
250  // kREAL = 7,
251  // kTINYINT = -6,
252  // kVARBINARY = -3,
253  // kVARCHAR = 12
254  // };
255 
256  if(!fImp) { Destroyed(); return; }
258 
259  try {
260  stmt->registerOutParameter( parameterIndex,sqlType,scale );
261 
262  } catch(odbc::SQLException& e) {
265  e.getErrorCode()) );
266  }
267 }
268 
269 //___________________________________________________________________
271 {
272  // Indicates whether or not the last OUT parameter read had
273  // the value of SQL NULL. Note that this method should be
274  // called only after calling the get method; otherwise, there
275  // is no value to use in determining whether it is null or not.
276  //
277  // Returns:
278  // kTRUE if the last parameter read was SQL NULL;
279  // kFALSE otherwise.
280  // Throws:
281  // TSQLException - if a database access error occurs
282 
283  Bool_t return_value = kFALSE;
284 
285  if(!fImp) { Destroyed(); return return_value; }
287 
288  try {
289  return_value = stmt->wasNull();
290 
291  } catch(odbc::SQLException& e) {
294  e.getErrorCode()) );
295  return kFALSE;
296  }
297  return return_value;
298 }
299 
300 //___________________________________________________________________
301 TString ODBCCallableStatement::GetString( Int_t parameterIndex )
302 {
303  // Retrieves the value of a parameter as a TString.
304  //
305  // For the fixed-length type kCHAR, the TString object returned
306  // has exactly the same value the kCHAR value had in the database,
307  // including any padding added by the database.
308  //
309  // Parameters:
310  // parameterIndex - the first parameter is 1,
311  // the second is 2, and so on
312  // Returns:
313  // the parameter value. If the value is SQL NULL,
314  // the result is null.
315  // Throws:
316  // TSQLException - if a database access error occurs
317 
318  TString str;
319 
320  if(!fImp) { Destroyed(); return str; }
322 
323  try {
324  ODBCXX_STRING s = stmt->getString(parameterIndex);
325  str = ODBCXX_STRING_CSTR(s);
326 
327  } catch(odbc::SQLException& e) {
330  e.getErrorCode()) );
331  return "";
332  }
333  return str;
334 }
335 
336 //___________________________________________________________________
337 Bool_t ODBCCallableStatement::GetBoolean( Int_t parameterIndex )
338 {
339  // Gets the value of a parameter as a Bool_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 kFALSE.
347  // Throws:
348  // TSQLException - if a database access error occurs
349 
350  Bool_t return_value = kFALSE;
351 
352  if(!fImp) { Destroyed(); return return_value; }
354 
355  try {
356  return_value = stmt->getBoolean(parameterIndex);
357 
358  } catch(odbc::SQLException& e) {
361  e.getErrorCode()) );
362  return kFALSE;
363  }
364  return return_value;
365 }
366 
367 //___________________________________________________________________
368 Char_t ODBCCallableStatement::GetByte( Int_t parameterIndex )
369 {
370  // Gets the value of a parameter as a byte .
371  //
372  // Parameters:
373  // parameterIndex - the first parameter is 1,
374  // the second is 2, and so on
375  // Returns:
376  // the parameter value. If the value is SQL NULL,
377  // the result is 0.
378  // Throws:
379  // TSQLException - if a database access error occurs
380 
381  Char_t return_value = 0;
382 
383  if(!fImp) { Destroyed(); return return_value; }
385 
386  try {
387  return_value = stmt->getByte(parameterIndex);
388 
389  } catch(odbc::SQLException& e) {
392  e.getErrorCode()) );
393  return 0;
394  }
395  return return_value;
396 }
397 
398 //___________________________________________________________________
399 Short_t ODBCCallableStatement::GetShort( Int_t parameterIndex )
400 {
401  // Gets the value of a parameter as a Short_t .
402  //
403  // Parameters:
404  // parameterIndex - the first parameter is 1,
405  // the second is 2, and so on
406  // Returns:
407  // the parameter value. If the value is SQL NULL,
408  // the result is 0.
409  // Throws:
410  // TSQLException - if a database access error occurs
411 
412  Short_t return_value = 0;
413 
414  if(!fImp) { Destroyed(); return return_value; }
416 
417  try {
418  return_value = stmt->getShort(parameterIndex);
419 
420  } catch(odbc::SQLException& e) {
423  e.getErrorCode()) );
424  return 0;
425  }
426  return return_value;
427 }
428 
429 //___________________________________________________________________
430 Int_t ODBCCallableStatement::GetInt( Int_t parameterIndex )
431 {
432  // Gets the value of a parameter as an Int_t .
433  //
434  // Parameters:
435  // parameterIndex - the first parameter is 1, the second is 2,
436  // and so on
437  // Returns:
438  // the parameter value. If the value is SQL NULL,
439  // the result is 0.
440  // Throws:
441  // TSQLException - if a database access error occurs
442 
443  Int_t return_value = 0;
444 
445  if(!fImp) { Destroyed(); return return_value; }
447 
448  try {
449  return_value = stmt->getInt(parameterIndex);
450 
451  } catch(odbc::SQLException& e) {
454  e.getErrorCode()) );
455  return 0;
456  }
457  return return_value;
458 }
459 
460 //___________________________________________________________________
461 Long_t ODBCCallableStatement::GetLong( Int_t parameterIndex )
462 {
463  // Gets the value of a parameter as a Long_t .
464  //
465  // Parameters:
466  // parameterIndex - the first parameter is 1,
467  // the second is 2, and so on
468  // Returns:
469  // the parameter value. If the value is SQL NULL,
470  // the result is 0.
471  // Throws:
472  // TSQLException - if a database access error occurs
473 
474  Long_t return_value = 0;
475 
476  if(!fImp) { Destroyed(); return return_value; }
478 
479  try {
480  return_value = stmt->getLong(parameterIndex);
481 
482  } catch(odbc::SQLException& e) {
485  e.getErrorCode()) );
486  return 0;
487  }
488  return return_value;
489 }
490 
491 //___________________________________________________________________
492 Float_t ODBCCallableStatement::GetFloat( Int_t parameterIndex )
493 {
494  // Gets the value of a parameter as a Float_t .
495  //
496  // Parameters:
497  // parameterIndex - the first parameter is 1,
498  // the second is 2, and so on
499  // Returns:
500  // the parameter value. If the value is SQL NULL,
501  // the result is 0.
502  // Throws:
503  // TSQLException - if a database access error occurs
504 
505  Float_t return_value = 0;
506 
507  if(!fImp) { Destroyed(); return return_value; }
509 
510  try {
511  return_value = stmt->getFloat(parameterIndex);
512 
513  } catch(odbc::SQLException& e) {
516  e.getErrorCode()) );
517  return 0;
518  }
519  return return_value;
520 }
521 
522 //___________________________________________________________________
523 Double_t ODBCCallableStatement::GetDouble( Int_t parameterIndex )
524 {
525  // Gets the value of a parameter as a Double_t .
526  //
527  // Parameters:
528  // parameterIndex - the first parameter is 1,
529  // the second is 2, and so on
530  // Returns:
531  // the parameter value. If the value is SQL NULL,
532  // the result is 0.
533  // Throws:
534  // TSQLException - if a database access error occurs
535 
536  Double_t return_value = 0;
537 
538  if(!fImp) { Destroyed(); return return_value; }
540 
541  try {
542  return_value = stmt->getDouble(parameterIndex);
543 
544  } catch(odbc::SQLException& e) {
547  e.getErrorCode()) );
548  return 0;
549  }
550  return return_value;
551 }
552 
553 //___________________________________________________________________
554 TArrayC ODBCCallableStatement::GetBytes( Int_t parameterIndex )
555 {
556  // Gets the value of a parameter as an array of byte values.
557  //
558  // Parameters:
559  // parameterIndex - the first parameter is 1,
560  // the second is 2, and so on
561  // Returns:
562  // the parameter value. If the value is SQL NULL,
563  // the result is null.
564  // Throws:
565  // TSQLException - if a database access error occurs
566 
567  TArrayC array;
568 
569  if(!fImp) { Destroyed(); return array; }
571 
572  try {
573  ODBCXX_BYTES b = stmt->getBytes(parameterIndex);
574 
575  array.Set( (Int_t)ODBCXX_BYTES_SIZE(b),
576  (Char_t*)ODBCXX_BYTES_DATA(b) );
577 
578  } catch(odbc::SQLException& e) {
581  e.getErrorCode()) );
582  return TArrayC();
583  }
584  return array;
585 }
586 
587 //___________________________________________________________________
589 {
590  // Gets the value of a parameter as a TSQLDate object.
591  //
592  // Parameters:
593  // parameterIndex - the first parameter is 1,
594  // the second is 2, and so on
595  // Returns:
596  // the parameter value. If the value is SQL NULL,
597  // the result is null.
598  // Throws:
599  // TSQLException - if a database access error occurs
600 
601  TSQLDate return_value;
602 
603  if(!fImp) { Destroyed(); return return_value; }
605 
606  try {
607  odbc::Date dt = stmt->getDate(parameterIndex);
608 
609  return_value = TSQLDate( dt.getYear(),
610  dt.getMonth(),
611  dt.getDay() );
612 
613  } catch(odbc::SQLException& e) {
616  e.getErrorCode()) );
617  return TSQLDate();
618  }
619  return return_value;
620 }
621 
622 //___________________________________________________________________
624 {
625  // Get the value of a parameter as a TSQLTime object.
626  //
627  // Parameters:
628  // parameterIndex - the first parameter is 1,
629  // the second is 2, and so on
630  // Returns:
631  // the parameter value. If the value is SQL NULL,
632  // the result is null.
633  // Throws:
634  // TSQLException - if a database access error occurs
635 
636  TSQLTime return_value;
637 
638  if(!fImp) { Destroyed(); return return_value; }
640 
641  try {
642  odbc::Time tm = stmt->getTime(parameterIndex);
643 
644  return_value = TSQLTime( tm.getHour(),
645  tm.getMinute(),
646  tm.getSecond() );
647 
648  } catch(odbc::SQLException& e) {
651  e.getErrorCode()) );
652  return TSQLTime();
653  }
654  return return_value;
655 }
656 
657 //___________________________________________________________________
659 {
660  // Gets the value of a parameter as a TSQLTimestamp object.
661  //
662  // Parameters:
663  // parameterIndex - the first parameter is 1,
664  // the second is 2, and so on
665  // Returns:
666  // the parameter value. If the value is SQL NULL,
667  // the result is null.
668  // Throws:
669  // TSQLException - if a database access error occurs
670 
671  TSQLTimestamp return_value;
672 
673  if(!fImp) { Destroyed(); return return_value; }
675 
676  try {
677  odbc::Timestamp tmstmp = stmt->getTimestamp(parameterIndex);
678 
679  return_value = TSQLTimestamp( tmstmp.getYear(),
680  tmstmp.getMonth(),
681  tmstmp.getDay(),
682  tmstmp.getHour(),
683  tmstmp.getMinute(),
684  tmstmp.getSecond(),
685  tmstmp.getNanos() );
686 
687  } catch(odbc::SQLException& e) {
690  e.getErrorCode()) );
691  return TSQLTimestamp();
692  }
693  return return_value;
694 }
695 
697 //___________________________________________________________________
698 void ODBCCallableStatement::SetNull( Int_t parameterIndex,Int_t sqlType )
699 {
700  // Sets the designated parameter to SQL NULL.
701  //
702  // Note: You must specify the parameter's SQL type.
703  //
704  // Parameters:
705  // parameterIndex - the first parameter is 1,
706  // the second is 2, ...
707  // sqlType - the SQL type code defined in TSQLTypes
708  // Throws:
709  // TSQLException - if a database access error occurs
710 
711  if(!fImp) { Destroyed(); return; }
713 
714  try {
715  imp->setNull(parameterIndex,sqlType);
716 
717  } catch(odbc::SQLException& e) {
720  e.getErrorCode()) );
721  }
722 }
723 
724 //___________________________________________________________________
725 void ODBCCallableStatement::SetBoolean( Int_t parameterIndex,Bool_t x )
726 {
727  // Sets the designated parameter to a Bool_t value. The
728  // driver converts this to an SQL BIT value when it sends it to
729  // the database.
730  //
731  // Parameters:
732  // parameterIndex - the first parameter is 1,
733  // the second is 2, ...
734  // x - the parameter value
735  // Throws:
736  // TSQLException - if a database access error occurs
737 
738  if(!fImp) { Destroyed(); return; }
740 
741  try {
742  imp->setBoolean(parameterIndex,x);
743 
744  } catch(odbc::SQLException& e) {
747  e.getErrorCode()) );
748  }
749 }
750 
751 //___________________________________________________________________
752 void ODBCCallableStatement::SetByte( Int_t parameterIndex,Char_t x )
753 {
754  // Sets the designated parameter to a byte value. The
755  // driver converts this to an SQL TINYINT value when it sends
756  // it to the database.
757  //
758  // Parameters:
759  // parameterIndex - the first parameter is 1,
760  // the second is 2, ...
761  // x - the parameter value
762  // Throws:
763  // TSQLException - if a database access error occurs
764 
765  if(!fImp) { Destroyed(); return; }
767 
768  try {
769  imp->setByte(parameterIndex,x);
770 
771  } catch(odbc::SQLException& e) {
774  e.getErrorCode()) );
775  }
776 }
777 
778 //___________________________________________________________________
779 void ODBCCallableStatement::SetShort( Int_t parameterIndex,Short_t x )
780 {
781  // Sets the designated parameter to a short value. The
782  // driver converts this to an SQL SMALLINT value when it sends
783  // it to the database.
784  //
785  // Parameters:
786  // parameterIndex - the first parameter is 1,
787  // the second is 2, ...
788  // x - the parameter value
789  // Throws:
790  // TSQLException - if a database access error occurs
791 
792  if(!fImp) { Destroyed(); return; }
794 
795  try {
796  imp->setShort(parameterIndex,x);
797 
798  } catch(odbc::SQLException& e) {
801  e.getErrorCode()) );
802  }
803 }
804 
805 //___________________________________________________________________
806 void ODBCCallableStatement::SetInt( Int_t parameterIndex,Int_t x )
807 {
808  // Sets the designated parameter to a int value. The
809  // driver converts this to an SQL INTEGER value when it sends
810  // it to the database.
811  //
812  // Parameters:
813  // parameterIndex - the first parameter is 1,
814  // the second is 2, ...
815  // x - the parameter value
816  // Throws:
817  // TSQLException - if a database access error occurs
818 
819  if(!fImp) { Destroyed(); return; }
821 
822  try {
823  imp->setInt(parameterIndex,x);
824 
825  } catch(odbc::SQLException& e) {
828  e.getErrorCode()) );
829  }
830 }
831 
832 //___________________________________________________________________
833 void ODBCCallableStatement::SetLong( Int_t parameterIndex,Long_t x )
834 {
835  // Sets the designated parameter to a long value. The
836  // driver converts this to an SQL BIGINT value when it sends it
837  // to the database.
838  //
839  // Parameters:
840  // parameterIndex - the first parameter is 1,
841  // the second is 2, ...
842  // x - the parameter value
843  // Throws:
844  // TSQLException - if a database access error occurs
845 
846  if(!fImp) { Destroyed(); return; }
848 
849  try {
850  imp->setLong(parameterIndex,x);
851 
852  } catch(odbc::SQLException& e) {
855  e.getErrorCode()) );
856  }
857 }
858 
859 //___________________________________________________________________
860 void ODBCCallableStatement::SetFloat( Int_t parameterIndex,Float_t x )
861 {
862  // Sets the designated parameter to a float value. The
863  // driver converts this to an SQL FLOAT value when it sends it
864  // to the database.
865  //
866  // Parameters:
867  // parameterIndex - the first parameter is 1,
868  // the second is 2, ...
869  // x - the parameter value
870  // Throws:
871  // TSQLException - if a database access error occurs
872 
873  if(!fImp) { Destroyed(); return; }
875 
876  try {
877  imp->setFloat(parameterIndex,x);
878 
879  } catch(odbc::SQLException& e) {
882  e.getErrorCode()) );
883  }
884 }
885 
886 //___________________________________________________________________
887 void ODBCCallableStatement::SetDouble( Int_t parameterIndex,Double_t x )
888 {
889  // Sets the designated parameter to a double value. The
890  // driver converts this to an SQL DOUBLE value when it sends it
891  // to the database.
892  //
893  // Parameters:
894  // parameterIndex - the first parameter is 1,
895  // the second is 2, ...
896  // x - the parameter value
897  // Throws:
898  // TSQLException - if a database access error occurs
899 
900  if(!fImp) { Destroyed(); return; }
902 
903  try {
904  imp->setDouble(parameterIndex,x);
905 
906  } catch(odbc::SQLException& e) {
909  e.getErrorCode()) );
910  }
911 }
912 
913 //___________________________________________________________________
914 void ODBCCallableStatement::SetString( Int_t parameterIndex,
915  const TString& x )
916 {
917  // Sets the designated parameter to a TString value. The
918  // driver converts this to an SQL VARCHAR or LONGVARCHAR value
919  // (depending on the argument's size relative to the driver's
920  // limits on VARCHARs) when it sends it to the database.
921  //
922  // Parameters:
923  // parameterIndex - the first parameter is 1,
924  // the second is 2, ...
925  // x - the parameter value
926  // Throws:
927  // TSQLException - if a database access error occurs
928 
929  if(!fImp) { Destroyed(); return; }
931 
932  try {
933  imp->setString( parameterIndex, ODBCXX_STRING_C(x.Data()) );
934 
935  } catch(odbc::SQLException& e) {
938  e.getErrorCode()) );
939  }
940 }
941 
942 //___________________________________________________________________
943 void ODBCCallableStatement::SetBytes( Int_t parameterIndex,
944  const TArrayC& x )
945 {
946  // Sets the designated parameter to a array of bytes. The
947  // driver converts this to an SQL VARBINARY or LONGVARBINARY
948  // (depending on the argument's size relative to the driver's
949  // limits on VARBINARYs) when it sends it to the database.
950  //
951  // Parameters:
952  // parameterIndex - the first parameter is 1,
953  // the second is 2, ...
954  // x - the parameter value
955  // Throws:
956  // TSQLException - if a database access error occurs
957 
958  if(!fImp) { Destroyed(); return; }
960 
961  try {
962  imp->setBytes( parameterIndex,
963  ODBCXX_BYTES_C(x.GetArray(),x.GetSize()) );
964 
965  } catch(odbc::SQLException& e) {
968  e.getErrorCode()) );
969  }
970 }
971 
972 //___________________________________________________________________
973 void ODBCCallableStatement::SetDate( Int_t parameterIndex,
974  const TSQLDate& x )
975 {
976  // Sets the designated parameter to a TSQLDate value. The
977  // driver converts this to an SQL DATE value when it sends it
978  // to the database.
979  //
980  // Parameters:
981  // parameterIndex - the first parameter is 1,
982  // the second is 2, ...
983  // x - the parameter value
984  // Throws:
985  // TSQLException - if a database access error occurs
986 
987  if(!fImp) { Destroyed(); return; }
989 
990  try {
991  odbc::Date dt( x.GetYear(),
992  x.GetMonth(),
993  x.GetDay() );
994 
995  imp->setDate(parameterIndex,dt);
996 
997  } catch(odbc::SQLException& e) {
1000  e.getErrorCode()) );
1001  }
1002 }
1003 
1004 //___________________________________________________________________
1005 void ODBCCallableStatement::SetTime( Int_t parameterIndex,
1006  const TSQLTime& x )
1007 {
1008  // Sets the designated parameter to a TSQLTime value. The
1009  // driver converts this to an SQL TIME value when it sends it
1010  // to the database.
1011  //
1012  // Parameters:
1013  // parameterIndex - the first parameter is 1,
1014  // the second is 2, ...
1015  // x - the parameter value
1016  // Throws:
1017  // TSQLException - if a database access error occurs
1018 
1019  if(!fImp) { Destroyed(); return; }
1021 
1022  try {
1023  odbc::Time tm( x.GetHour(),
1024  x.GetMinute(),
1025  x.GetSecond() );
1026 
1027  imp->setTime(parameterIndex,tm);
1028 
1029  } catch(odbc::SQLException& e) {
1032  e.getErrorCode()) );
1033  }
1034 }
1035 
1036 //___________________________________________________________________
1037 void ODBCCallableStatement::SetTimestamp( Int_t parameterIndex,
1038  const TSQLTimestamp& x )
1039 {
1040  // Sets the designated parameter to a TSQLTimestamp value.
1041  // The driver converts this to an SQL TIMESTAMP value when it
1042  // sends it to the database.
1043  //
1044  // Parameters:
1045  // parameterIndex - the first parameter is 1,
1046  // the second is 2, ...
1047  // x - the parameter value
1048  // Throws:
1049  // TSQLException - if a database access error occurs
1050 
1051  if(!fImp) { Destroyed(); return; }
1053 
1054  try {
1055  odbc::Timestamp tmstmp( x.GetYear(),
1056  x.GetMonth(),
1057  x.GetDay(),
1058  x.GetHour(),
1059  x.GetMinute(),
1060  x.GetSecond(),
1061  x.GetNanos() );
1062 
1063  imp->setTimestamp(parameterIndex,tmstmp);
1064 
1065  } catch(odbc::SQLException& e) {
1068  e.getErrorCode()) );
1069  }
1070 }
1071 
1072 //___________________________________________________________________
1073 void ODBCCallableStatement::SetAsciiStream( Int_t parameterIndex,
1074  TBuffer* x,
1075  Int_t length )
1076 {
1077  // Sets the designated parameter to the given input stream,
1078  // which will have the specified number of bytes. When a very
1079  // large ASCII value is input to a LONGVARCHAR parameter, it
1080  // may be more practical to send it via a TBuffer
1081  // will read the data from the stream as needed, until it
1082  // reaches end-of-file. The driver will do any necessary
1083  // conversion from ASCII to the database char format.
1084  //
1085  // Parameters:
1086  // parameterIndex - the first parameter is 1,
1087  // the second is 2, ...
1088  // x - the input stream that contains the ASCII
1089  // parameter value
1090  // length - the number of bytes in the stream,
1091  // total size of buffer is by default.
1092  // Throws:
1093  // TSQLException - if a database access error occurs
1094 
1095  if(!fImp) { Destroyed(); return; }
1097 
1098  try {
1099  Int_t xl = x->BufferSize()>length ? length : x->BufferSize();
1100  std::istringstream* s = new std::istringstream( x->Buffer() );
1101  imp->setAsciiStream( parameterIndex,(std::istream*)s,xl );
1102 
1103  } catch(odbc::SQLException& e) {
1106  e.getErrorCode()) );
1107  }
1108 }
1109 
1110 //___________________________________________________________________
1111 void ODBCCallableStatement::SetBinaryStream( Int_t parameterIndex,
1112  TBuffer* x,
1113  Int_t length )
1114 {
1115  // Sets the designated parameter to the given input stream,
1116  // which will have the specified number of bytes. When a very
1117  // large binary value is input to a LONGVARBINARY parameter, it
1118  // may be more practical to send it via a TBuffer.
1119  // will read the data from the stream as needed, until it
1120  // reaches end-of-file.
1121  //
1122  // Parameters:
1123  // parameterIndex - the first parameter is 1,
1124  // the second is 2, ...
1125  // x - the input tream which contains the binary
1126  // parameter value
1127  // length - the number of bytes in the stream
1128  // total size of buffer is by default.
1129  // Throws:
1130  // TSQLException - if a database access error occurs
1131 
1132  if(!fImp) { Destroyed(); return; }
1134 
1135  try {
1136  Int_t xl = x->BufferSize()>length ? length : x->BufferSize();
1137  std::string a(x->Buffer(),xl);
1138  std::istream* s = new std::istringstream(a);
1139  imp->setBinaryStream( parameterIndex,s,xl );
1140 
1141  } catch(odbc::SQLException& e) {
1144  e.getErrorCode()) );
1145  }
1146 }
1147 
1148 //___________________________________________________________________
1149 void ODBCCallableStatement::SetObject( Int_t parameterIndex,TObject* x )
1150 {
1151  // Sets the designated parameter to the given ROOT object
1152  //
1153  // Parameters:
1154  // parameterIndex - the first parameter is 1,
1155  // the second is 2, ...
1156  // x - the ROOT object
1157  // Throws:
1158  // TSQLException - if a database access error occurs
1159 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
1160  TBuffer *b = new TBufferFile(TBuffer::kWrite);
1161 #else
1162  TBuffer *b = new TBuffer(TBuffer::kWrite);
1163 #endif
1164  b->WriteObject(x);
1165  SetBinaryStream(parameterIndex,b,b->BufferSize());
1166  b->DetachBuffer();
1167  delete b;
1168 }
1169 
1170 //___________________________________________________________________
1172 {
1173  // Clears the current parameter values immediately.
1174  //
1175  // In general, parameter values remain in force for repeated
1176  // use of a TSQLStatement. Setting a parameter value
1177  // automatically clears its previous value. However, in some
1178  // cases it is useful to immediately release the resources used
1179  // by the current parameter values; this can be done by calling
1180  // ClearParameters().
1181  //
1182  // Throws:
1183  // TSQLException - if a database access error occurs
1184 
1185  if(!fImp) { Destroyed(); return; }
1187 
1188  try {
1189  imp->clearParameters();
1190 
1191  } catch(odbc::SQLException& e) {
1194  e.getErrorCode()) );
1195  }
1196 }
1197 
1199 //___________________________________________________________________
1201 {
1202  // Executes a SQL statement that returns a single TSQLResultSet
1203  //
1204  // This method also implicitly closes current TSQLResultSet
1205  //
1206  // Returns:
1207  // a TSLResultSet that contains the data produced by the query;
1208  // NULL - in case of error
1209  //
1210  // Throws:
1211  // TSQLException - if a database access error occurs
1212 
1213  if(!fImp) { Destroyed(); return 0; }
1216  odbc::ResultSet* rs = 0;
1217  ClearWarnings();
1218 
1219  if(fCurrentResult) delete fCurrentResult;
1220 
1221  try {
1222  if(!sql.IsNull()) {
1223  rs = stmt->executeQuery(ODBCXX_STRING_C(sql.Data()));
1224  } else {
1225  rs = imp->executeQuery();
1226  }
1227  } catch(odbc::SQLException& e) {
1230  e.getErrorCode()) );
1231  if(rs) delete rs;
1232  fCurrentResult = 0;
1233  return 0;
1234  }
1235 
1236  return fCurrentResult = new ODBCResultSet(this,(void*)rs);;
1237 }
1238 
1239 //___________________________________________________________________
1240 Bool_t ODBCCallableStatement::Execute( const TString& sql )
1241 {
1242  // Executes a SQL statement that may return multiple results.
1243  // Under some (uncommon) situations a single SQL statement may
1244  // return multiple result sets and/or update counts. Normally you
1245  // can ignore this unless you are (1) executing a stored
1246  // procedure that you know may return multiple results or (2) you
1247  // are dynamically executing an unknown SQL string. The methods
1248  // execute, GetMoreResults(), GetResultSet(), and GetUpdateCount()
1249  // let you navigate through multiple results.
1250  // The execute method executes a SQL statement and indicates the
1251  // form of the first result. You can then use GetResultSet() or
1252  // GetUpdateCount() to retrieve the result, and GetMoreResults()
1253  // to move to any subsequent result(s).
1254  //
1255  // Parameters:
1256  // sql - any SQL statement
1257  // Returns:
1258  // kTRUE if the next result is a TSQLResultSet;
1259  // kFALSE if it is an update count or there are no more
1260  // results
1261  // Throws:
1262  // TSQLException - if a database access error occurs
1263  // See Also:
1264  // GetResultSet(), GetUpdateCount(), GetMoreResults()
1265 
1266  if(!fImp) { Destroyed(); return kFALSE; }
1267 
1268  Bool_t return_value = kFALSE;
1269  ClearWarnings();
1272 
1273  try {
1274  if(!sql.IsNull()) {
1275  return_value = (Bool_t)stmt->execute(ODBCXX_STRING_C(sql.Data()));
1276  } else {
1277  return_value = (Bool_t)imp->execute();
1278  }
1279  } catch(odbc::SQLException& e) {
1282  e.getErrorCode()) );
1283  return_value = kFALSE;
1284  }
1285  return return_value;
1286 }
1287 
1288 //___________________________________________________________________
1289 Int_t ODBCCallableStatement::ExecuteUpdate( const TString& sql )
1290 {
1291  // Executes an SQL INSERT, UPDATE or DELETE statement.
1292  // In addition, SQL statements that return nothing,
1293  // such as SQL DDL statements, can be executed.
1294  //
1295  // Parameters:
1296  // sql - a SQL INSERT, UPDATE or DELETE statement or
1297  // a SQL statement that returns nothing
1298  //
1299  // Returns:
1300  // either the row count for INSERT, UPDATE or DELETE or
1301  // 0 for SQL statements that return nothing
1302  // Throws:
1303  // TSQLException - if a database access error occurs
1304 
1305  if(!fImp) { Destroyed(); return 0; }
1306 
1307  Int_t return_value = 0;
1308  ClearWarnings();
1311 
1312  try {
1313  if(!sql.IsNull()) {
1314  return_value = (Bool_t)stmt->executeUpdate(ODBCXX_STRING_C(sql.Data()));
1315  } else {
1316  return_value = (Bool_t)imp->executeUpdate();
1317  }
1318  } catch(odbc::SQLException& e) {
1321  e.getErrorCode()) );
1322  return_value = 0;
1323  }
1324  return return_value;
1325 }
1326 
1327 //___________________________________________________________________
1329 {
1330  // Returns the current result as a TSQLResultSet object.
1331  // This method should be called only once per result.
1332  //
1333  // This method also implicitly closes any current TSQLResultSet
1334  //
1335  // Returns:
1336  // the current result as a TSQLResultSet; null if the result
1337  // is an update count or there are no more results
1338  // Throws:
1339  // TSQLException - if a database access error occurs
1340  // See Also:
1341  // Execute(const TString&)
1342 
1343  if(!fImp) { Destroyed(); return 0; }
1344  odbc::ResultSet* rs = 0;
1346 
1347  if(fCurrentResult) delete fCurrentResult;
1348 
1349  try {
1350  rs = stmt->getResultSet();
1351  } catch(odbc::SQLException& e) {
1354  e.getErrorCode()) );
1355  if(rs) delete rs;
1356  fCurrentResult = 0;
1357  return 0;
1358  }
1359 
1360  return fCurrentResult = new ODBCResultSet(this,(void*)rs);
1361 }
1362 
1363 //___________________________________________________________________
1365 {
1366  // Returns the current result as an update count;
1367  // if there are no more results, -1 is returned.
1368  // This method should be called only once per result.
1369  //
1370  // Returns:
1371  // the current result as an update count; -1 if it is a
1372  // TSQLResultSet or there are no more results
1373  // Throws:
1374  // TSQLException - if a database access error occurs
1375  // See Also:
1376  // Execute(const TString&)
1377 
1378  if(!fImp) { Destroyed(); return 0; }
1379 
1380  Int_t return_value = 0;
1382 
1383  try {
1384  return_value = stmt->getUpdateCount();
1385  } catch(odbc::SQLException& e) {
1388  e.getErrorCode()) );
1389  return 0;
1390  }
1391  return return_value;
1392 }
1393 
1394 //___________________________________________________________________
1396 {
1397  // Moves to a ODBCStatement's next result. It returns kTRUE if
1398  // this result is a TSQLResultSet.
1399  //
1400  // There are no more results when
1401  // (!GetMoreResults() && (GetUpdateCount() == -1)
1402  //
1403  // Returns:
1404  // kTRUE if the next result is a TSQLResultSet;
1405  // kFALSE if it is an update count or there are no more results
1406  //
1407  // Throws:
1408  // TSQLException - if a database access error occurs
1409  // See Also:
1410  // Execute(const TString&)
1411 
1412  Bool_t return_value = kFALSE;
1413 
1414  if(!fImp) { Destroyed(); return return_value; }
1416 
1417  try {
1418  return_value = (Bool_t)stmt->getMoreResults();
1419  } catch(odbc::SQLException& e) {
1422  e.getErrorCode()) );
1423  return kFALSE;
1424  }
1425  return return_value;
1426 }
1427 
1428 //___________________________________________________________________
1430 {
1431  // Returns the maximum number of bytes allowed for any column
1432  // value. This limit is the maximum number of bytes that can be
1433  // returned for any column value. The limit applies only to
1434  // kBINARY, kVARBINARY, kLONGVARBINARY, kCHAR, kVARCHAR, and
1435  // kLONGVARCHAR columns (see TSQLTypes.h). If the limit is exceeded,
1436  // the excess data is silently discarded.
1437  //
1438  // Returns:
1439  // the current max column size limit; zero means unlimited
1440  // Throws:
1441  // TSQLException - if a database access error occurs
1442 
1443  if(!fImp) { Destroyed(); return 0; }
1444 
1445  Int_t return_value = 0;
1447 
1448  try {
1449  return_value = stmt->getMaxFieldSize();
1450  } catch(odbc::SQLException& e) {
1453  e.getErrorCode()) );
1454  return 0;
1455  }
1456  return return_value;
1457 }
1458 
1459 //___________________________________________________________________
1461 {
1462  // Sets the limit for the maximum number of bytes in a column to
1463  // the given number of bytes. This is the maximum number of bytes
1464  // that can be returned for any column value. This limit applies
1465  // only to kBINARY, kVARBINARY, kLONGVARBINARY, kCHAR, kVARCHAR,
1466  // and kLONGVARCHAR fields (see TSQLTypes.h) . If the limit is exceeded,
1467  // the excess data is silently discarded. For maximum portability,
1468  // use values greater than 256.
1469  //
1470  // Parameters:
1471  // max - the new max column size limit; zero means unlimited
1472  // Throws:
1473  // TSQLException - if a database access error occurs
1474 
1475  if(!fImp) { Destroyed(); return; }
1477 
1478  try {
1479  stmt->setMaxFieldSize(max);
1480  } catch(odbc::SQLException& e) {
1483  e.getErrorCode()) );
1484  }
1485 }
1486 
1487 //___________________________________________________________________
1489 {
1490  // Retrieves the maximum number of rows that a TSQLResultSet can
1491  // contain. If the limit is exceeded, the excess rows are silently
1492  // dropped.
1493  //
1494  // Returns:
1495  // the current max row limit; zero means unlimited
1496  // Throws:
1497  // TSQLException - if a database access error occurs
1498 
1499  if(!fImp) { Destroyed(); return 0; }
1500 
1501  Int_t return_value = 0;
1503 
1504  try {
1505  return_value = stmt->getMaxRows();
1506  } catch(odbc::SQLException& e) {
1509  e.getErrorCode()) );
1510  return 0;
1511  }
1512  return return_value;
1513 }
1514 
1515 //___________________________________________________________________
1517 {
1518  // Sets the limit for the maximum number of rows that any
1519  // TSQLResultSet can contain to the given number. If the limit is
1520  // exceeded, the excess rows are silently dropped.
1521  //
1522  // Parameters:
1523  // max - the new max rows limit; zero means unlimited
1524  // Throws:
1525  // TSQLException - if a database access error occurs
1526 
1527  if(!fImp) { Destroyed(); return; }
1529 
1530  try {
1531  stmt->setMaxRows(max);
1532  } catch(odbc::SQLException& e) {
1535  e.getErrorCode()) );
1536  }
1537 }
1538 
1539 //___________________________________________________________________
1541 {
1542  // Sets escape processing on or off. If escape scanning is on
1543  // (the default), the driver will do escape substitution before
1544  // sending the SQL to the database.
1545  //
1546  // Note:
1547  // Since prepared statements have usually been parsed prior to
1548  // making this call, disabling escape processing for prepared
1549  // statements will have no effect.
1550  //
1551  // Parameters:
1552  // enable - kTRUE to enable; kFALSE to disable
1553  // Throws:
1554  // TSQLException - if a database access error occurs
1555 
1556  if(!fImp) { Destroyed(); return; }
1558 
1559  try {
1560  stmt->setEscapeProcessing(enable);
1561  } catch(odbc::SQLException& e) {
1564  e.getErrorCode()) );
1565  }
1566 }
1567 
1568 //___________________________________________________________________
1570 {
1571  // Returns if escape processing is on or off.
1572  // If escape scanning is on (the default), the driver will do escape
1573  // substitution before sending the SQL to the database.
1574  //
1575  // Note:
1576  // Since prepared statements have usually been parsed prior to
1577  // making this call, disabling escape processing for prepared
1578  // statements will have no effect.
1579  //
1580  // Parameters:
1581  // enable - kTRUE to enable; kFALSE to disable
1582  // Throws:
1583  // TSQLException - if a database access error occurs
1584 
1585  if(!fImp) { Destroyed(); return kFALSE; }
1586 
1587  Bool_t return_value = kFALSE;
1589 
1590  try {
1591  return_value = stmt->getEscapeProcessing();
1592  } catch(odbc::SQLException& e) {
1595  e.getErrorCode()) );
1596  return kFALSE;
1597  }
1598  return return_value;
1599 }
1600 
1601 //___________________________________________________________________
1603 {
1604  // Retrieves the number of seconds the driver will wait for a
1605  // ODBCStatement to execute. If the limit is exceeded, a
1606  // TSQLException is thrown.
1607  //
1608  // Returns:
1609  // the current query timeout limit in seconds; zero means
1610  // unlimited
1611  // Throws:
1612  // TSQLException - if a database access error occurs
1613 
1614  Int_t return_value = 0;
1615 
1616  if(!fImp) { Destroyed(); return return_value; }
1618 
1619  try {
1620  return_value = stmt->getQueryTimeout();
1621  } catch(odbc::SQLException& e) {
1624  e.getErrorCode()) );
1625  return 0;
1626  }
1627  return return_value;
1628 }
1629 
1630 //___________________________________________________________________
1632 {
1633  // Sets the number of seconds the driver will wait for a
1634  // ODBCStatement to execute to the given number of seconds.
1635  // If the limit is exceeded, a TSQLException is thrown.
1636  //
1637  // Parameters:
1638  // seconds - the new query timeout limit in seconds;
1639  // zero means unlimited
1640  // Throws:
1641  // TSQLException - if a database access error occurs
1642 
1643  if(!fImp) { Destroyed(); return; }
1645 
1646  try {
1647  stmt->setQueryTimeout(seconds);
1648  } catch(odbc::SQLException& e) {
1651  e.getErrorCode()) );
1652  }
1653 }
1654 
1655 //___________________________________________________________________
1657 {
1658  // Cancels this statement object if both the DBMS and driver
1659  // support aborting an SQL statement. This method can be used by
1660  // one thread to cancel a statement that is being executed by
1661  // another thread.
1662  //
1663  // Throws:
1664  // TSQLException - if a database access error occurs
1665 
1666  if(!fImp) { Destroyed(); return; }
1668 
1669  try {
1670  stmt->cancel();
1671  } catch(odbc::SQLException& e) {
1674  e.getErrorCode()) );
1675  }
1676 }
1677 
1678 //___________________________________________________________________
1680 {
1681  // Avoid using this method. Use delete ODBCStatement instead.
1682  //
1683  // Note: When a ODBCStatement is closed, its current
1684  // TSQLResultSet, if one exists, is also closed.
1685  //
1686  // Throws:
1687  // TSQLException - if a database access error occurs
1688 
1689  if(!fImp) { Destroyed(); return; }
1690 
1691  try {
1692  if(fCurrentResult) {
1693  delete fCurrentResult;
1694  fCurrentResult = 0;
1695  }
1696  ClearBatch();
1697  SafeDelete(fBatches);
1698 
1700  if(imp) delete imp;
1701  } catch(odbc::SQLException& e) {
1704  e.getErrorCode()) );
1705  }
1706  fImp = 0;
1707  Destroyed();
1708 }
1709 
1710 //___________________________________________________________________
1712 {
1713  // Defines the SQL cursor name that will be used by subsequent
1714  // ODBCStatement execute methods. This name can then be used in
1715  // SQL positioned update/delete statements to identify the
1716  // current row in the TSQLResultSet generated by this statement.
1717  // If the database doesn't support positioned update/delete,
1718  // this method is a noop. To insure that a cursor has the proper
1719  // isolation level to support updates, the cursor's SELECT
1720  // statement should be of the form 'SELECT FOR UPDATE ...'. If
1721  // the 'FOR UPDATE' phrase is omitted, positioned updates may
1722  // fail.
1723  //
1724  // Note: By definition, positioned update/delete execution must
1725  // be done by a different ODBCStatement than the one which
1726  // generated the TSQLResultSet being used for positioning.
1727  // Also, cursor names must be unique within a connection.
1728  //
1729  // Parameters:
1730  // name - the new cursor name, which must be unique within
1731  // a connection
1732  // Throws:
1733  // TSQLException - if a database access error occurs
1734 
1735  if(!fImp) { Destroyed(); return; }
1737 
1738  try {
1739  stmt->setCursorName(ODBCXX_STRING_C(name.Data()));
1740  } catch(odbc::SQLException& e) {
1743  e.getErrorCode()) );
1744  }
1745 }
1746 
1747 //___________________________________________________________________
1748 void ODBCCallableStatement::SetFetchDirection( Int_t /* direction */ )
1749 {
1750  // Gives the driver a hint as to the direction in which the
1751  // rows in a result set will be processed. The hint applies only
1752  // to result sets created using this statement object.
1753  // The default value is TSQLResultSet::kTYPE_FORWARD_ONLY
1754  //
1755  // Note that this method sets the default fetch direction for
1756  // result sets generated by this statement object.
1757  //
1758  // Parameters:
1759  // direction - the initial direction for processing rows
1760  // Throws:
1761  // TSQLException - if a database access error occurs or the
1762  // given direction is not one of
1763  //
1764 
1765  if(!fImp) { Destroyed(); return; }
1766 }
1767 
1768 //___________________________________________________________________
1770 {
1771  // Retrieves the direction for fetching rows from database
1772  // tables that is the default for result sets generated from this
1773  // statement object. If this statement object has not set
1774  // a fetch direction by calling the method SetFetchDirection(),
1775  // the return value is implementation-specific.
1776  //
1777  // Returns:
1778  // the default fetch direction for result sets generated
1779  // from this statement object
1780  // Throws:
1781  // TSQLException - if a database access error occurs
1782 
1783  return 0;
1784 }
1785 
1786 //___________________________________________________________________
1787 void ODBCCallableStatement::SetFetchSize( Int_t /* rows */ )
1788 {
1789  // Gives the driver a hint as to the number of rows that
1790  // should be fetched from the database when more rows are needed.
1791  // The number of rows specified affects only result sets created
1792  // using this statement. If the value specified is zero, then the
1793  // hint is ignored. The default value is zero.
1794  //
1795  // Parameters:
1796  // rows - the number of rows to fetch
1797  // Throws:
1798  // TSQLException - if a database access error occurs, or
1799  // the condition 0 <= rows <= GetMaxRows() is not satisfied.
1800 
1801  if(!fImp) { Destroyed(); return; }
1802 }
1803 
1804 //___________________________________________________________________
1806 {
1807  // Retrieves the number of result set rows that is the default
1808  // fetch size for result sets generated from this ODBCStatement
1809  // object. If this statement object has not set a fetch size
1810  // by calling the method SetFetchSize(), the return value is
1811  // implementation-specific.
1812  //
1813  // Returns:
1814  // the default fetch size for result sets generated from
1815  // this statement object
1816  // Throws:
1817  // TSQLException - if a database access error occurs
1818 
1819  Int_t return_value = 0;
1820 
1821  if(!fImp) { Destroyed(); return return_value; }
1823 
1824  try {
1825  return_value = stmt->getFetchSize();
1826  } catch(odbc::SQLException& e) {
1829  e.getErrorCode()) );
1830  return 0;
1831  }
1832  return return_value;
1833 }
1834 
1835 //___________________________________________________________________
1837 {
1838  // Retrieves the result set concurrency.
1839  //
1840  // enum EResultSetConcurrency{
1841  // kCONCUR_READ_ONLY,
1842  // kCONCUR_UPDATABLE
1843  // };
1844 
1845  Int_t return_value = 0;
1846 
1847  if(!fImp) { Destroyed(); return return_value; }
1849 
1850  try {
1851  return_value = stmt->getResultSetConcurrency();
1852  } catch(odbc::SQLException& e) {
1855  e.getErrorCode()) );
1856  return 0;
1857  }
1858  return return_value;
1859 }
1860 
1861 //___________________________________________________________________
1863 {
1864  // Determine the result set type.
1865  //
1866  // enum EResultSetType{
1867  // kTYPE_FORWARD_ONLY,
1868  // kTYPE_SCROLL_INSENSITIVE,
1869  // kTYPE_SCROLL_SENSITIVE
1870  // };
1871  //
1872 
1873  Int_t return_value = 0;
1874 
1875  if(!fImp) { Destroyed(); return return_value; }
1877 
1878  try {
1879  return_value = stmt->getResultSetType();
1880  } catch(odbc::SQLException& e) {
1883  e.getErrorCode()) );
1884  return 0;
1885  }
1886  return return_value;
1887 }
1888 
1889 //___________________________________________________________________
1890 void ODBCCallableStatement::AddBatch( const TString& /* sql */ )
1891 {
1892  // Adds a SQL command to the current batch of commmands for
1893  // the statement. This method is optional.
1894  //
1895  // Parameters:
1896  // sql - typically this is a static SQL INSERT or UPDATE
1897  // statement
1898  // Throws:
1899  // TSQLException - if a database access error occurs, or
1900  // the driver does not support batch statements
1901 
1902 }
1903 
1904 //___________________________________________________________________
1906 {
1907  // Makes the set of commands in the current batch empty. This
1908  // method is optional.
1909  //
1910  // Throws:
1911  // TSQLException - if a database access error occurs or
1912  // the driver does not support batch statements
1913 
1914 }
1915 
1916 //___________________________________________________________________
1918 {
1919  // Submits a batch of commands to the database for execution.
1920  // This method is optional.
1921  //
1922  // Returns:
1923  // an array of update counts containing one element for
1924  // each command in the batch. The array is ordered
1925  // according to the order in which commands were inserted
1926  // into the batch.
1927  //
1928  // Throws:
1929  // TSQLException - if a database access error occurs or
1930  // the driver does not support batch statements
1931 
1932  return 0;
1933 }