File indexing completed on 2025-08-03 08:22:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 #include "ODBCPreparedStatement.h"
0062 #include "ODBCResultSet.h"
0063 #include <RDBC/odbc++/statement.h>
0064 #include <RDBC/odbc++/preparedstatement.h>
0065 #include <RDBC/odbc++/resultset.h>
0066 #include <iostream>
0067 #include <sstream>
0068 #include <TList.h>
0069
0070 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
0071 #include <TBufferFile.h>
0072 #endif
0073
0074 using namespace std;
0075 using namespace odbc;
0076
0077 ClassImpQ(ODBCPreparedStatement)
0078
0079
0080
0081 ODBCPreparedStatement::ODBCPreparedStatement(TSQLConnection* con,void* imp):
0082 TSQLPreparedStatement(con,imp)
0083
0084 {
0085
0086 }
0087
0088
0089 ODBCPreparedStatement::~ODBCPreparedStatement()
0090 {
0091
0092
0093 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0094
0095 try {
0096 if(imp) delete imp;
0097 } catch(odbc::SQLException& e) {
0098 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0099 ODBCXX_STRING_CSTR(e.getSQLState()),
0100 e.getErrorCode()) );
0101 }
0102
0103
0104 if(fCurrentResult) ((ODBCResultSet*)fCurrentResult)->fImp = 0;
0105 fImp = 0;
0106 }
0107
0108
0109 void ODBCPreparedStatement::SetNull( Int_t parameterIndex,Int_t sqlType )
0110 {
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122 if(!fImp) { Destroyed(); return; }
0123 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0124
0125 try {
0126 imp->setNull(parameterIndex,sqlType);
0127
0128 } catch(odbc::SQLException& e) {
0129 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0130 ODBCXX_STRING_CSTR(e.getSQLState()),
0131 e.getErrorCode()) );
0132 }
0133 }
0134
0135
0136 void ODBCPreparedStatement::SetBoolean( Int_t parameterIndex,Bool_t x )
0137 {
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 if(!fImp) { Destroyed(); return; }
0150 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0151
0152 try {
0153 imp->setBoolean(parameterIndex,x);
0154
0155 } catch(odbc::SQLException& e) {
0156 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0157 ODBCXX_STRING_CSTR(e.getSQLState()),
0158 e.getErrorCode()) );
0159 }
0160 }
0161
0162
0163 void ODBCPreparedStatement::SetByte( Int_t parameterIndex,Char_t x )
0164 {
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176 if(!fImp) { Destroyed(); return; }
0177 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0178
0179 try {
0180 imp->setByte(parameterIndex,x);
0181
0182 } catch(odbc::SQLException& e) {
0183 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0184 ODBCXX_STRING_CSTR(e.getSQLState()),
0185 e.getErrorCode()) );
0186 }
0187 }
0188
0189
0190 void ODBCPreparedStatement::SetShort( Int_t parameterIndex,Short_t x )
0191 {
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203 if(!fImp) { Destroyed(); return; }
0204 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0205
0206 try {
0207 imp->setShort(parameterIndex,x);
0208
0209 } catch(odbc::SQLException& e) {
0210 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0211 ODBCXX_STRING_CSTR(e.getSQLState()),
0212 e.getErrorCode()) );
0213 }
0214 }
0215
0216
0217 void ODBCPreparedStatement::SetInt( Int_t parameterIndex,Int_t x )
0218 {
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230 if(!fImp) { Destroyed(); return; }
0231 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0232
0233 try {
0234 imp->setInt(parameterIndex,x);
0235
0236 } catch(odbc::SQLException& e) {
0237 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0238 ODBCXX_STRING_CSTR(e.getSQLState()),
0239 e.getErrorCode()) );
0240 }
0241 }
0242
0243
0244 void ODBCPreparedStatement::SetLong( Int_t parameterIndex,Long_t x )
0245 {
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257 if(!fImp) { Destroyed(); return; }
0258 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0259
0260 try {
0261 imp->setLong(parameterIndex,x);
0262
0263 } catch(odbc::SQLException& e) {
0264 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0265 ODBCXX_STRING_CSTR(e.getSQLState()),
0266 e.getErrorCode()) );
0267 }
0268 }
0269
0270
0271 void ODBCPreparedStatement::SetFloat( Int_t parameterIndex,Float_t x )
0272 {
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284 if(!fImp) { Destroyed(); return; }
0285 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0286
0287 try {
0288 imp->setFloat(parameterIndex,x);
0289
0290 } catch(odbc::SQLException& e) {
0291 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0292 ODBCXX_STRING_CSTR(e.getSQLState()),
0293 e.getErrorCode()) );
0294 }
0295 }
0296
0297
0298 void ODBCPreparedStatement::SetDouble( Int_t parameterIndex,Double_t x )
0299 {
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311 if(!fImp) { Destroyed(); return; }
0312 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0313
0314 try {
0315 imp->setDouble(parameterIndex,x);
0316
0317 } catch(odbc::SQLException& e) {
0318 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0319 ODBCXX_STRING_CSTR(e.getSQLState()),
0320 e.getErrorCode()) );
0321 }
0322 }
0323
0324
0325 void ODBCPreparedStatement::SetString( Int_t parameterIndex,
0326 const TString& x )
0327 {
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340 if(!fImp) { Destroyed(); return; }
0341 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0342
0343 try {
0344 imp->setString( parameterIndex, ODBCXX_STRING_C(x.Data()) );
0345
0346 } catch(odbc::SQLException& e) {
0347 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0348 ODBCXX_STRING_CSTR(e.getSQLState()),
0349 e.getErrorCode()) );
0350 }
0351 }
0352
0353
0354 void ODBCPreparedStatement::SetBytes( Int_t parameterIndex,
0355 const TArrayC& x )
0356 {
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369 if(!fImp) { Destroyed(); return; }
0370 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0371
0372 try {
0373 imp->setBytes( parameterIndex,
0374 ODBCXX_BYTES_C(x.GetArray(),x.GetSize()) );
0375
0376 } catch(odbc::SQLException& e) {
0377 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0378 ODBCXX_STRING_CSTR(e.getSQLState()),
0379 e.getErrorCode()) );
0380 }
0381 }
0382
0383
0384 void ODBCPreparedStatement::SetDate( Int_t parameterIndex,
0385 const TSQLDate& x )
0386 {
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398 if(!fImp) { Destroyed(); return; }
0399 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0400
0401 try {
0402 odbc::Date dt( x.GetYear(),
0403 x.GetMonth(),
0404 x.GetDay() );
0405
0406 imp->setDate(parameterIndex,dt);
0407
0408 } catch(odbc::SQLException& e) {
0409 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0410 ODBCXX_STRING_CSTR(e.getSQLState()),
0411 e.getErrorCode()) );
0412 }
0413 }
0414
0415
0416 void ODBCPreparedStatement::SetTime( Int_t parameterIndex,
0417 const TSQLTime& x )
0418 {
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430 if(!fImp) { Destroyed(); return; }
0431 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0432
0433 try {
0434 odbc::Time tm( x.GetHour(),
0435 x.GetMinute(),
0436 x.GetSecond() );
0437
0438 imp->setTime(parameterIndex,tm);
0439
0440 } catch(odbc::SQLException& e) {
0441 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0442 ODBCXX_STRING_CSTR(e.getSQLState()),
0443 e.getErrorCode()) );
0444 }
0445 }
0446
0447
0448 void ODBCPreparedStatement::SetTimestamp( Int_t parameterIndex,
0449 const TSQLTimestamp& x )
0450 {
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462 if(!fImp) { Destroyed(); return; }
0463 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0464
0465 try {
0466 odbc::Timestamp tmstmp( x.GetYear(),
0467 x.GetMonth(),
0468 x.GetDay(),
0469 x.GetHour(),
0470 x.GetMinute(),
0471 x.GetSecond(),
0472 x.GetNanos() );
0473
0474 imp->setTimestamp(parameterIndex,tmstmp);
0475
0476 } catch(odbc::SQLException& e) {
0477 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0478 ODBCXX_STRING_CSTR(e.getSQLState()),
0479 e.getErrorCode()) );
0480 }
0481 }
0482
0483
0484 void ODBCPreparedStatement::SetAsciiStream( Int_t parameterIndex,
0485 TBuffer* x,
0486 Int_t length )
0487 {
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506 if(!fImp) { Destroyed(); return; }
0507 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0508
0509 try {
0510 Int_t xl = x->BufferSize()>length ? length : x->BufferSize();
0511 std::istringstream* s = new std::istringstream(x->Buffer());
0512 imp->setAsciiStream( parameterIndex,(std::istream*)s,xl );
0513
0514 } catch(odbc::SQLException& e) {
0515 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0516 ODBCXX_STRING_CSTR(e.getSQLState()),
0517 e.getErrorCode()) );
0518 }
0519 }
0520
0521
0522 void ODBCPreparedStatement::SetBinaryStream( Int_t parameterIndex,
0523 TBuffer* x,
0524 Int_t length )
0525 {
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543 if(!fImp) { Destroyed(); return; }
0544 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0545
0546 try {
0547 Int_t xl = x->BufferSize()>length ? length : x->BufferSize();
0548 std::string a(x->Buffer(),xl);
0549
0550 std::istream* s = new std::istringstream(a);
0551
0552 _vec_str_buf.push_back(boost::shared_ptr<std::istream>(s));
0553
0554 imp->setBinaryStream( parameterIndex,s,xl );
0555 } catch(odbc::SQLException& e) {
0556 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0557 ODBCXX_STRING_CSTR(e.getSQLState()),
0558 e.getErrorCode()) );
0559 }
0560 }
0561
0562
0563 void ODBCPreparedStatement::SetObject( Int_t parameterIndex,TObject* x )
0564 {
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
0575 TBuffer *b = new TBufferFile(TBuffer::kWrite);
0576 #else
0577 TBuffer *b = new TBuffer(TBuffer::kWrite);
0578 #endif
0579 b->WriteObject(x);
0580 SetBinaryStream(parameterIndex,b,b->BufferSize());
0581
0582 delete b;
0583 }
0584
0585
0586 void ODBCPreparedStatement::ClearParameters()
0587 {
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600 if(!fImp) { Destroyed(); return; }
0601 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0602
0603 try {
0604 imp->clearParameters();
0605
0606 } catch(odbc::SQLException& e) {
0607 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0608 ODBCXX_STRING_CSTR(e.getSQLState()),
0609 e.getErrorCode()) );
0610 }
0611 }
0612
0613
0614 TSQLResultSet* ODBCPreparedStatement::ExecuteQuery( const TString& sql )
0615 {
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627 if(!fImp) { Destroyed(); return 0; }
0628 odbc::Statement* stmt = (odbc::Statement*)fImp;
0629 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0630 odbc::ResultSet* rs = 0;
0631 ClearWarnings();
0632
0633 if(fCurrentResult) delete fCurrentResult;
0634
0635 try {
0636 if(!sql.IsNull()) {
0637 rs = stmt->executeQuery(ODBCXX_STRING_C(sql.Data()));
0638 } else {
0639 rs = imp->executeQuery();
0640 }
0641 } catch(odbc::SQLException& e) {
0642 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0643 ODBCXX_STRING_CSTR(e.getSQLState()),
0644 e.getErrorCode()) );
0645 if(rs) delete rs;
0646 fCurrentResult = 0;
0647 return 0;
0648 }
0649
0650 return fCurrentResult = new ODBCResultSet(this,(void*)rs);;
0651 }
0652
0653
0654 Bool_t ODBCPreparedStatement::Execute( const TString& sql )
0655 {
0656
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666
0667
0668
0669
0670
0671
0672
0673
0674
0675
0676
0677
0678
0679
0680 if(!fImp) { Destroyed(); return kFALSE; }
0681
0682 Bool_t return_value = kFALSE;
0683 ClearWarnings();
0684 odbc::Statement* stmt = (odbc::Statement*)fImp;
0685 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0686
0687 try {
0688 if(!sql.IsNull()) {
0689 return_value = (Bool_t)stmt->execute(ODBCXX_STRING_C(sql.Data()));
0690 } else {
0691 return_value = imp->execute();
0692 }
0693 } catch(odbc::SQLException& e) {
0694 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0695 ODBCXX_STRING_CSTR(e.getSQLState()),
0696 e.getErrorCode()) );
0697 return_value = kFALSE;
0698 }
0699 return return_value;
0700 }
0701
0702
0703 Int_t ODBCPreparedStatement::ExecuteUpdate( const TString& sql )
0704 {
0705
0706
0707
0708
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719 if(!fImp) { Destroyed(); return 0; }
0720
0721 Int_t return_value = 0;
0722 ClearWarnings();
0723 odbc::Statement* stmt = (odbc::Statement*)fImp;
0724 odbc::PreparedStatement* imp = (odbc::PreparedStatement*)fImp;
0725
0726 try {
0727 if(!sql.IsNull()) {
0728 return_value = stmt->executeUpdate(ODBCXX_STRING_C(sql.Data()));
0729 } else {
0730 return_value = imp->executeUpdate();
0731 }
0732 } catch(odbc::SQLException& e) {
0733 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0734 ODBCXX_STRING_CSTR(e.getSQLState()),
0735 e.getErrorCode()) );
0736 return_value = 0;
0737 }
0738 return return_value;
0739 }
0740
0741
0742 TSQLResultSet* ODBCPreparedStatement::GetResultSet()
0743 {
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757 if(!fImp) { Destroyed(); return 0; }
0758 odbc::ResultSet* rs;
0759 odbc::Statement* stmt = (odbc::Statement*)fImp;
0760
0761 if(fCurrentResult) delete fCurrentResult;
0762
0763 try {
0764 rs = stmt->getResultSet();
0765 } catch(odbc::SQLException& e) {
0766 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0767 ODBCXX_STRING_CSTR(e.getSQLState()),
0768 e.getErrorCode()) );
0769 if(rs) delete rs;
0770 fCurrentResult = 0;
0771 return 0;
0772 }
0773
0774 return fCurrentResult = new ODBCResultSet(this,(void*)rs);
0775 }
0776
0777
0778 Int_t ODBCPreparedStatement::GetUpdateCount()
0779 {
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789
0790
0791
0792 if(!fImp) { Destroyed(); return 0; }
0793
0794 Int_t return_value = 0;
0795 odbc::Statement* stmt = (odbc::Statement*)fImp;
0796
0797 try {
0798 return_value = stmt->getUpdateCount();
0799 } catch(odbc::SQLException& e) {
0800 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0801 ODBCXX_STRING_CSTR(e.getSQLState()),
0802 e.getErrorCode()) );
0803 return 0;
0804 }
0805 return return_value;
0806 }
0807
0808
0809 Bool_t ODBCPreparedStatement::GetMoreResults()
0810 {
0811
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826 Bool_t return_value = kFALSE;
0827
0828 if(!fImp) { Destroyed(); return return_value; }
0829 odbc::Statement* stmt = (odbc::Statement*)fImp;
0830
0831 try {
0832 return_value = (Bool_t)stmt->getMoreResults();
0833 } catch(odbc::SQLException& e) {
0834 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0835 ODBCXX_STRING_CSTR(e.getSQLState()),
0836 e.getErrorCode()) );
0837 return kFALSE;
0838 }
0839 return return_value;
0840 }
0841
0842
0843 Int_t ODBCPreparedStatement::GetMaxFieldSize()
0844 {
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857 if(!fImp) { Destroyed(); return 0; }
0858
0859 Int_t return_value = 0;
0860 odbc::Statement* stmt = (odbc::Statement*)fImp;
0861
0862 try {
0863 return_value = stmt->getMaxFieldSize();
0864 } catch(odbc::SQLException& e) {
0865 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0866 ODBCXX_STRING_CSTR(e.getSQLState()),
0867 e.getErrorCode()) );
0868 return 0;
0869 }
0870 return return_value;
0871 }
0872
0873
0874 void ODBCPreparedStatement::SetMaxFieldSize( Int_t max )
0875 {
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885
0886
0887
0888
0889 if(!fImp) { Destroyed(); return; }
0890 odbc::Statement* stmt = (odbc::Statement*)fImp;
0891
0892 try {
0893 stmt->setMaxFieldSize(max);
0894 } catch(odbc::SQLException& e) {
0895 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0896 ODBCXX_STRING_CSTR(e.getSQLState()),
0897 e.getErrorCode()) );
0898 }
0899 }
0900
0901
0902 Int_t ODBCPreparedStatement::GetMaxRows()
0903 {
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913 if(!fImp) { Destroyed(); return 0; }
0914
0915 Int_t return_value = 0;
0916 odbc::Statement* stmt = (odbc::Statement*)fImp;
0917
0918 try {
0919 return_value = stmt->getMaxRows();
0920 } catch(odbc::SQLException& e) {
0921 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0922 ODBCXX_STRING_CSTR(e.getSQLState()),
0923 e.getErrorCode()) );
0924 return 0;
0925 }
0926 return return_value;
0927 }
0928
0929
0930 void ODBCPreparedStatement::SetMaxRows( Int_t max )
0931 {
0932
0933
0934
0935
0936
0937
0938
0939
0940
0941 if(!fImp) { Destroyed(); return; }
0942 odbc::Statement* stmt = (odbc::Statement*)fImp;
0943
0944 try {
0945 stmt->setMaxRows(max);
0946 } catch(odbc::SQLException& e) {
0947 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0948 ODBCXX_STRING_CSTR(e.getSQLState()),
0949 e.getErrorCode()) );
0950 }
0951 }
0952
0953
0954 void ODBCPreparedStatement::SetEscapeProcessing( Bool_t enable )
0955 {
0956
0957
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967
0968
0969
0970 if(!fImp) { Destroyed(); return; }
0971 odbc::Statement* stmt = (odbc::Statement*)fImp;
0972
0973 try {
0974 stmt->setEscapeProcessing(enable);
0975 } catch(odbc::SQLException& e) {
0976 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
0977 ODBCXX_STRING_CSTR(e.getSQLState()),
0978 e.getErrorCode()) );
0979 }
0980 }
0981
0982
0983 Bool_t ODBCPreparedStatement::GetEscapeProcessing()
0984 {
0985
0986
0987
0988
0989
0990
0991
0992
0993
0994
0995
0996
0997
0998
0999 if(!fImp) { Destroyed(); return kFALSE; }
1000
1001 Bool_t return_value = kFALSE;
1002 odbc::Statement* stmt = (odbc::Statement*)fImp;
1003
1004 try {
1005 return_value = stmt->getEscapeProcessing();
1006 } catch(odbc::SQLException& e) {
1007 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
1008 ODBCXX_STRING_CSTR(e.getSQLState()),
1009 e.getErrorCode()) );
1010 return kFALSE;
1011 }
1012 return return_value;
1013 }
1014
1015
1016 Int_t ODBCPreparedStatement::GetQueryTimeout()
1017 {
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028 Int_t return_value = 0;
1029
1030 if(!fImp) { Destroyed(); return return_value; }
1031 odbc::Statement* stmt = (odbc::Statement*)fImp;
1032
1033 try {
1034 return_value = stmt->getQueryTimeout();
1035 } catch(odbc::SQLException& e) {
1036 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
1037 ODBCXX_STRING_CSTR(e.getSQLState()),
1038 e.getErrorCode()) );
1039 return 0;
1040 }
1041 return return_value;
1042 }
1043
1044
1045 void ODBCPreparedStatement::SetQueryTimeout( Int_t seconds )
1046 {
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057 if(!fImp) { Destroyed(); return; }
1058 odbc::Statement* stmt = (odbc::Statement*)fImp;
1059
1060 try {
1061 stmt->setQueryTimeout(seconds);
1062 } catch(odbc::SQLException& e) {
1063 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
1064 ODBCXX_STRING_CSTR(e.getSQLState()),
1065 e.getErrorCode()) );
1066 }
1067 }
1068
1069
1070 void ODBCPreparedStatement::Cancel()
1071 {
1072
1073
1074
1075
1076
1077
1078
1079
1080 if(!fImp) { Destroyed(); return; }
1081 odbc::Statement* stmt = (odbc::Statement*)fImp;
1082
1083 try {
1084 stmt->cancel();
1085 } catch(odbc::SQLException& e) {
1086 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
1087 ODBCXX_STRING_CSTR(e.getSQLState()),
1088 e.getErrorCode()) );
1089 }
1090 }
1091
1092
1093 void ODBCPreparedStatement::Close()
1094 {
1095
1096
1097
1098
1099
1100
1101
1102
1103 if(!fImp) { Destroyed(); return; }
1104
1105 try {
1106 if(fCurrentResult) {
1107 delete fCurrentResult;
1108 fCurrentResult = 0;
1109 }
1110 ClearBatch();
1111 SafeDelete(fBatches);
1112
1113 odbc::Statement* imp = (odbc::Statement*)fImp;
1114 if(imp) delete imp;
1115 } catch(odbc::SQLException& e) {
1116 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
1117 ODBCXX_STRING_CSTR(e.getSQLState()),
1118 e.getErrorCode()) );
1119 }
1120 fImp = 0;
1121 Destroyed();
1122 }
1123
1124
1125 void ODBCPreparedStatement::SetCursorName( const TString& name )
1126 {
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149 if(!fImp) { Destroyed(); return; }
1150 odbc::Statement* stmt = (odbc::Statement*)fImp;
1151
1152 try {
1153 stmt->setCursorName(ODBCXX_STRING_C(name.Data()));
1154 } catch(odbc::SQLException& e) {
1155 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
1156 ODBCXX_STRING_CSTR(e.getSQLState()),
1157 e.getErrorCode()) );
1158 }
1159 }
1160
1161
1162 void ODBCPreparedStatement::SetFetchDirection( Int_t )
1163 {
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179 if(!fImp) { Destroyed(); return; }
1180 }
1181
1182
1183 Int_t ODBCPreparedStatement::GetFetchDirection()
1184 {
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197 return 0;
1198 }
1199
1200
1201 void ODBCPreparedStatement::SetFetchSize( Int_t )
1202 {
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215 if(!fImp) { Destroyed(); return; }
1216 }
1217
1218
1219 Int_t ODBCPreparedStatement::GetFetchSize()
1220 {
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233 Int_t return_value = 0;
1234
1235 if(!fImp) { Destroyed(); return return_value; }
1236 odbc::Statement* stmt = (odbc::Statement*)fImp;
1237
1238 try {
1239 return_value = stmt->getFetchSize();
1240 } catch(odbc::SQLException& e) {
1241 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
1242 ODBCXX_STRING_CSTR(e.getSQLState()),
1243 e.getErrorCode()) );
1244 return 0;
1245 }
1246 return return_value;
1247 }
1248
1249
1250 Int_t ODBCPreparedStatement::GetResultSetConcurrency()
1251 {
1252
1253
1254
1255
1256
1257
1258
1259 Int_t return_value = 0;
1260
1261 if(!fImp) { Destroyed(); return return_value; }
1262 odbc::Statement* stmt = (odbc::Statement*)fImp;
1263
1264 try {
1265 return_value = stmt->getResultSetConcurrency();
1266 } catch(odbc::SQLException& e) {
1267 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
1268 ODBCXX_STRING_CSTR(e.getSQLState()),
1269 e.getErrorCode()) );
1270 return 0;
1271 }
1272 return return_value;
1273 }
1274
1275
1276 Int_t ODBCPreparedStatement::GetResultSetType()
1277 {
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287 Int_t return_value = 0;
1288
1289 if(!fImp) { Destroyed(); return return_value; }
1290 odbc::Statement* stmt = (odbc::Statement*)fImp;
1291
1292 try {
1293 return_value = stmt->getResultSetType();
1294 } catch(odbc::SQLException& e) {
1295 Throw( new TSQLException( ODBCXX_STRING_CSTR(e.getMessage()),
1296 ODBCXX_STRING_CSTR(e.getSQLState()),
1297 e.getErrorCode()) );
1298 return 0;
1299 }
1300 return return_value;
1301 }
1302
1303
1304 void ODBCPreparedStatement::AddBatch( const TString& )
1305 {
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316 }
1317
1318
1319 void ODBCPreparedStatement::ClearBatch()
1320 {
1321
1322
1323
1324
1325
1326
1327
1328 }
1329
1330
1331 Int_t* ODBCPreparedStatement::ExecuteBatch()
1332 {
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346 return 0;
1347 }