ROOT
Version master
master
v6.34
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
v6.04
Reference Guide
▼
ROOT
ROOT Reference Documentation
Tutorials
►
Functional Parts
►
Namespaces
►
All Classes
▼
Files
▼
File List
►
bindings
►
core
►
documentation
►
geom
►
graf2d
►
graf3d
►
gui
►
hist
►
io
►
main
►
master
►
math
►
montecarlo
►
net
►
proof
►
roofit
▼
sql
►
mysql
▼
odbc
►
inc
▼
src
►
TODBCResult.cxx
►
TODBCRow.cxx
►
TODBCServer.cxx
►
TODBCStatement.cxx
►
pgsql
►
sqlite
►
tmva
►
tree
►
tutorials
►
File Members
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
TODBCResult.cxx
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
#include "
TODBCResult.h
"
13
#include "
TODBCRow.h
"
14
15
16
ClassImp
(
TODBCResult
);
17
18
////////////////////////////////////////////////////////////////////////////////
19
/// Constructor
20
21
TODBCResult::TODBCResult
(SQLHSTMT
stmt
)
22
{
23
fHstmt
=
stmt
;
24
fFieldCount
= 0;
25
26
SQLSMALLINT
columnCount
;
27
28
SQLRETURN
retcode
=
SQLNumResultCols
(
fHstmt
, &
columnCount
);
29
30
if
(
retcode
==
SQL_SUCCESS
||
retcode
==
SQL_SUCCESS_WITH_INFO
)
31
fFieldCount
=
columnCount
;
32
}
33
34
////////////////////////////////////////////////////////////////////////////////
35
/// Cleanup ODBC query result.
36
37
TODBCResult::~TODBCResult
()
38
{
39
Close
();
40
}
41
42
////////////////////////////////////////////////////////////////////////////////
43
/// Close (cleanup) ODBC result object. Deletes statement
44
45
void
TODBCResult::Close
(
Option_t
*)
46
{
47
SQLFreeHandle
(
SQL_HANDLE_STMT
,
fHstmt
);
48
fHstmt
=
nullptr
;
49
}
50
51
////////////////////////////////////////////////////////////////////////////////
52
/// Get name of specified field.
53
54
const
char
*
TODBCResult::GetFieldName
(
Int_t
field
)
55
{
56
SQLCHAR
columnName
[1024];
57
58
SQLSMALLINT
nameLength
;
59
SQLSMALLINT
dataType
;
60
SQLULEN
columnSize
;
61
SQLSMALLINT
decimalDigits
;
62
SQLSMALLINT
nullable
;
63
64
SQLRETURN
retcode
=
65
SQLDescribeCol
(
fHstmt
,
field
+1,
columnName
, 1024,
66
&
nameLength
, &
dataType
,
67
&
columnSize
, &
decimalDigits
, &
nullable
);
68
69
if
(
retcode
!=
SQL_SUCCESS
&&
retcode
!=
SQL_SUCCESS_WITH_INFO
)
return
nullptr
;
70
71
fNameBuffer
= (
const
char
*)
columnName
;
72
73
return
fNameBuffer
;
74
}
75
76
////////////////////////////////////////////////////////////////////////////////
77
/// Get next query result row. The returned object must be
78
/// deleted by the user.
79
80
TSQLRow
*
TODBCResult::Next
()
81
{
82
if
(!
fHstmt
)
return
nullptr
;
83
84
SQLRETURN
retcode
=
SQLFetch
(
fHstmt
);
85
86
if
(
retcode
==
SQL_SUCCESS
||
retcode
==
SQL_SUCCESS_WITH_INFO
)
87
return
new
TODBCRow
(
fHstmt
,
fFieldCount
);
88
89
return
nullptr
;
90
}
Option_t
const char Option_t
Definition
RtypesCore.h:66
ClassImp
#define ClassImp(name)
Definition
Rtypes.h:374
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TODBCResult.h
TODBCRow.h
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TODBCResult
Definition
TODBCResult.h:30
TODBCResult::Next
TSQLRow * Next() final
Get next query result row.
Definition
TODBCResult.cxx:80
TODBCResult::~TODBCResult
virtual ~TODBCResult()
Cleanup ODBC query result.
Definition
TODBCResult.cxx:37
TODBCResult::GetFieldName
const char * GetFieldName(Int_t field) final
Get name of specified field.
Definition
TODBCResult.cxx:54
TODBCResult::fNameBuffer
TString fNameBuffer
Definition
TODBCResult.h:35
TODBCResult::fFieldCount
Int_t fFieldCount
Definition
TODBCResult.h:34
TODBCResult::Close
void Close(Option_t *opt="") final
Close (cleanup) ODBC result object. Deletes statement.
Definition
TODBCResult.cxx:45
TODBCResult::TODBCResult
TODBCResult(SQLHSTMT stmt)
Constructor.
Definition
TODBCResult.cxx:21
TODBCResult::fHstmt
SQLHSTMT fHstmt
Definition
TODBCResult.h:33
TODBCRow
Definition
TODBCRow.h:28
TSQLRow
Definition
TSQLRow.h:30
int
sql
odbc
src
TODBCResult.cxx
ROOT master - Reference Guide Generated on Mon Mar 3 2025 04:37:50 (GVA Time) using Doxygen 1.10.0