Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TODBCStatement.h
Go to the documentation of this file.
1// @(#)root/odbc:$Id$
2// Author: Sergey Linev 6/02/2006
3
4/*************************************************************************
5 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TODBCStatement
13#define ROOT_TODBCStatement
14
15#include "TSQLStatement.h"
16
17
18#ifdef __CLING__
19typedef void * SQLHSTMT;
20typedef UShort_t SQLUSMALLINT;
21typedef UInt_t SQLUINTEGER;
22typedef Short_t SQLSMALLINT;
23typedef Short_t SQLRETURN;
24#else
25#ifdef WIN32
26#include "windows.h"
27#endif
28#include <sql.h>
29#endif
30
32
33protected:
34 #ifdef __CLING__
35 struct ODBCBufferRec_t;
36 #else
41 void *fBbuffer;
43 SQLLEN *fBlenarray;
46 };
47 #endif
48
49protected:
50 SQLHSTMT fHstmt;
54 Int_t fBufferLength{0}; // number of entries for each parameter/column
55 Int_t fBufferCounter{0}; // used to indicate position in buffers
56 SQLUSMALLINT *fStatusBuffer{nullptr};
57 Int_t fWorkingMode{0}; // 1 - setting parameters, 2 - reading results, 0 - unknown
58 SQLUINTEGER fNumParsProcessed{0}; // contains number of parameters, affected by last operation
59 SQLUINTEGER fNumRowsFetched{0}; // indicates number of fetched rows
60 ULong64_t fLastResultRow{0}; // stores values of row number after last fetch operation
61
62 void *GetParAddr(Int_t npar, Int_t roottype = 0, Int_t length = 0);
63 long double ConvertToNumeric(Int_t npar);
64 const char *ConvertToString(Int_t npar);
65
66 Bool_t BindColumn(Int_t ncol, SQLSMALLINT sqltype, SQLUINTEGER size);
68
69 Bool_t ExtractErrors(SQLRETURN retcode, const char* method);
70
71 void SetNumBuffers(Int_t isize, Int_t ilen);
72 void FreeBuffers();
73
74 Bool_t IsParSettMode() const { return fWorkingMode==1; }
75 Bool_t IsResultSet() const { return fWorkingMode==2; }
76
77public:
78 TODBCStatement(SQLHSTMT stmt, Int_t rowarrsize, Bool_t errout = kTRUE);
79 virtual ~TODBCStatement();
80
81 virtual void Close(Option_t * = "") final;
82
83 Int_t GetBufferLength() const final { return fBufferLength; }
84 Int_t GetNumParameters() final;
85
86 Bool_t SetNull(Int_t npar) final;
87 Bool_t SetInt(Int_t npar, Int_t value) final;
88 Bool_t SetUInt(Int_t npar, UInt_t value) final;
89 Bool_t SetLong(Int_t npar, Long_t value) final;
90 Bool_t SetLong64(Int_t npar, Long64_t value) final;
91 Bool_t SetULong64(Int_t npar, ULong64_t value) final;
92 Bool_t SetDouble(Int_t npar, Double_t value) final;
93 Bool_t SetString(Int_t npar, const char* value, Int_t maxsize = 256) final;
94 Bool_t SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000) final;
95 Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final;
96 Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final;
97 Bool_t SetDatime(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec) final;
99 Bool_t SetTimestamp(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec, Int_t frac = 0) final;
100
101 Bool_t NextIteration() final;
102
103 Bool_t Process() final;
105
106 Bool_t StoreResult() final;
107 Int_t GetNumFields() final;
108 const char *GetFieldName(Int_t nfield) final;
109 Bool_t NextResultRow() final;
110
111 Bool_t IsNull(Int_t) final;
112 Int_t GetInt(Int_t npar) final;
113 UInt_t GetUInt(Int_t npar) final;
114 Long_t GetLong(Int_t npar) final;
115 Long64_t GetLong64(Int_t npar) final;
116 ULong64_t GetULong64(Int_t npar) final;
117 Double_t GetDouble(Int_t npar) final;
118 const char *GetString(Int_t npar) final;
119 Bool_t GetBinary(Int_t npar, void* &mem, Long_t& size) final;
120 Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day) final;
121 Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec) final;
122 Bool_t GetDatime(Int_t npar, Int_t& year, Int_t& month, Int_t& day, Int_t& hour, Int_t& min, Int_t& sec) final;
124 Bool_t GetTimestamp(Int_t npar, Int_t& year, Int_t& month, Int_t& day, Int_t& hour, Int_t& min, Int_t& sec, Int_t&) final;
125
126 ClassDefOverride(TODBCStatement, 0); //ODBC implementation of TSQLStatement
127};
128
129#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned short UShort_t
Definition RtypesCore.h:40
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
short Short_t
Definition RtypesCore.h:39
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
unsigned long long ULong64_t
Definition RtypesCore.h:81
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:329
int type
Definition TGX11.cxx:121
void SetNumBuffers(Int_t isize, Int_t ilen)
set number of buffers
Bool_t GetBinary(Int_t npar, void *&mem, Long_t &size) final
return parameter as binary data
Bool_t Process() final
process statement
void FreeBuffers()
Free allocated buffers.
Bool_t GetTimestamp(Int_t npar, Int_t &year, Int_t &month, Int_t &day, Int_t &hour, Int_t &min, Int_t &sec, Int_t &) final
return field value as time stamp
Bool_t BindParam(Int_t n, Int_t type, Int_t size=1024)
Bind query parameter with buffer. Creates buffer of appropriate type.
Long64_t GetLong64(Int_t npar) final
get parameter as Long64_t
const char * GetString(Int_t npar) final
get parameter as string
Bool_t IsNull(Int_t) final
Verifies if field value is NULL.
Double_t GetDouble(Int_t npar) final
get parameter as Double_t
Bool_t IsParSettMode() const
const char * ConvertToString(Int_t npar)
convert to string
Long_t GetLong(Int_t npar) final
get parameter as Long_t
ULong64_t fLastResultRow
long double ConvertToNumeric(Int_t npar)
convert to numeric type
virtual ~TODBCStatement()
destructor
ULong64_t GetULong64(Int_t npar) final
get parameter as ULong64_t
Int_t GetInt(Int_t npar) final
get parameter as integer
Int_t GetNumFields() final
return number of fields
void * GetParAddr(Int_t npar, Int_t roottype=0, Int_t length=0)
Get parameter address.
Bool_t GetDatime(Int_t npar, Int_t &year, Int_t &month, Int_t &day, Int_t &hour, Int_t &min, Int_t &sec) final
return field value as date & time
Int_t fBufferPreferredSize
Bool_t SetTimestamp(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec, Int_t frac=0) final
set parameter value as timestamp
Int_t GetNumAffectedRows() final
get number of affected rows
Bool_t NextIteration() final
run next iteration
SQLUSMALLINT * fStatusBuffer
Bool_t GetTime(Int_t npar, Int_t &hour, Int_t &min, Int_t &sec) final
return field value as time
Bool_t SetLong64(Int_t npar, Long64_t value) final
set parameter as Long64_t
Bool_t GetDate(Int_t npar, Int_t &year, Int_t &month, Int_t &day) final
return field value as date
UInt_t GetUInt(Int_t npar) final
get parameter as unsigned integer
Bool_t SetBinary(Int_t npar, void *mem, Long_t size, Long_t maxsize=0x1000) final
set parameter value as binary data
Bool_t SetDatime(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec) final
set parameter value as date & time
Bool_t SetULong64(Int_t npar, ULong64_t value) final
set parameter as ULong64_t
Int_t GetBufferLength() const final
SQLUINTEGER fNumRowsFetched
Bool_t SetNull(Int_t npar) final
Set NULL as parameter value If NULL should be set for statement parameter during first iteration,...
Bool_t BindColumn(Int_t ncol, SQLSMALLINT sqltype, SQLUINTEGER size)
Bind result column to buffer. Allocate buffer of appropriate type.
Bool_t StoreResult() final
Store result of statement processing.
Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final
set parameter value as date
Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256) final
set parameter as string
SQLUINTEGER fNumParsProcessed
Bool_t SetLong(Int_t npar, Long_t value) final
set parameter as Long_t
Bool_t ExtractErrors(SQLRETURN retcode, const char *method)
Extract errors, produced by last ODBC function call.
Bool_t IsResultSet() const
virtual void Close(Option_t *="") final
Close statement.
Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final
set parameter value as time
Bool_t NextResultRow() final
next result row
Bool_t SetUInt(Int_t npar, UInt_t value) final
set parameter as UInt_t
Bool_t SetDouble(Int_t npar, Double_t value) final
set parameter as Double_t
ODBCBufferRec_t * fBuffer
const char * GetFieldName(Int_t nfield) final
return field name
Int_t GetNumParameters() final
return number of parameters
Bool_t SetInt(Int_t npar, Int_t value) final
set parameter as Int_t
const Int_t n
Definition legend1.C:16