VTK
vtkODBCQuery.h
Go to the documentation of this file.
1 /* -*- Mode: C++; -*- */
2 /*=========================================================================
3 
4  Program: Visualization Toolkit
5  Module: vtkODBCQuery.h
6 
7  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
8  All rights reserved.
9  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notice for more information.
14 
15 =========================================================================*/
16 /*-------------------------------------------------------------------------
17  Copyright 2008 Sandia Corporation.
18  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
19  the U.S. Government retains certain rights in this software.
20 -------------------------------------------------------------------------*/
21 
35 #ifndef vtkODBCQuery_h
36 #define vtkODBCQuery_h
37 
38 #include "vtkIOODBCModule.h" // For export macro
39 #include "vtkSQLQuery.h"
40 
41 class vtkODBCDatabase;
42 class vtkVariant;
43 class vtkVariantArray;
44 class vtkODBCInternals;
45 class vtkODBCQueryInternals;
46 
47 class VTKIOODBC_EXPORT vtkODBCQuery : public vtkSQLQuery
48 {
49 //BTX
50  friend class vtkODBCDatabase;
51 //ETX
52 
53 public:
54  vtkTypeMacro(vtkODBCQuery, vtkSQLQuery);
55  void PrintSelf(ostream& os, vtkIndent indent);
56  static vtkODBCQuery *New();
57 
60  bool Execute();
61 
63  int GetNumberOfFields();
64 
66  const char* GetFieldName(int i);
67 
70  int GetFieldType(int i);
71 
73  bool NextRow();
74 
76  bool HasError();
77 
80 
82  const char* GetLastErrorText();
83 
85 
86  bool BeginTransaction();
87  bool CommitTransaction();
88  bool RollbackTransaction();
90 
92 
95  bool SetQuery(const char *queryString);
96  const char *GetQuery();
98 
100 
106  bool BindParameter(int index, unsigned char value);
107  bool BindParameter(int index, signed char value);
108  bool BindParameter(int index, unsigned short value);
109  bool BindParameter(int index, signed short value);
110  bool BindParameter(int index, unsigned int value);
111 //ETX
112  bool BindParameter(int index, int value);
113 //BTX
114  bool BindParameter(int index, unsigned long value);
115  bool BindParameter(int index, signed long value);
116  bool BindParameter(int index, vtkTypeUInt64 value);
117  bool BindParameter(int index, vtkTypeInt64 value);
118 //ETX
119  bool BindParameter(int index, float value);
120  bool BindParameter(int index, double value);
122 
123  bool BindParameter(int index, const char *stringValue);
125 
126  bool BindParameter(int index, const char *stringValue, size_t length);
127  bool BindParameter(int index, const vtkStdString &string);
129 
130 
132  bool BindParameter(int index, const void *data, size_t length);
133  bool ClearParameterBindings();
135 
136 protected:
137  vtkODBCQuery();
138  ~vtkODBCQuery();
139 
140  vtkSetStringMacro(LastErrorText);
141  vtkSetStringMacro(QueryText);
142  vtkGetStringMacro(QueryText);
143 
144  char *QueryText;
145 
146 private:
147  vtkODBCQuery(const vtkODBCQuery &); // Not implemented.
148  void operator=(const vtkODBCQuery &); // Not implemented.
149 
150  void ClearCurrentRow();
151  bool CacheCurrentRow();
152 
153  bool CacheTimeColumn(int column);
154  bool CacheIntervalColumn(int column);
155  bool CacheCharColumn(int column);
156  bool CacheLongLongColumn(int column);
157  bool CacheBinaryColumn(int column);
158  bool CacheBooleanColumn(int column);
159  bool CacheStringColumn(int column);
160  bool CacheWideStringColumn(int column);
161  bool CacheDecimalColumn(int column);
162  bool CacheNumericColumn(int column);
163  bool CacheIntColumn(int column);
164  bool CacheFloatColumn(int column);
165  bool CacheDoubleColumn(int column);
166 
167  vtkODBCQueryInternals *Internals;
168  bool InitialFetch;
169  char *LastErrorText;
170 };
171 
172 #endif // vtkODBCQuery_h
173 
virtual bool SetQuery(const char *query)
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
virtual bool NextRow()=0
An array holding vtkVariants.
virtual const char * GetFieldName(int i)=0
virtual const char * GetQuery()
virtual bool BindParameter(int index, unsigned char value)
friend class vtkODBCQuery
virtual bool CommitTransaction()
Definition: vtkSQLQuery.h:100
int vtkIdType
Definition: vtkType.h:247
void PrintSelf(ostream &os, vtkIndent indent)
A atomic type representing the union of many types.
Definition: vtkVariant.h:78
virtual bool HasError()=0
Simple class to hide ODBC structures.
a simple class to control print indentation
Definition: vtkIndent.h:38
maintain an ODBC connection to a SQL database
virtual int GetNumberOfFields()=0
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:101
virtual bool BeginTransaction()
Definition: vtkSQLQuery.h:99
virtual int GetFieldType(int i)=0
virtual bool Execute()=0
virtual bool ClearParameterBindings()
virtual vtkVariant DataValue(vtkIdType c)=0
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:73
virtual const char * GetLastErrorText()=0
static vtkObject * New()
char * QueryText
Definition: vtkODBCQuery.h:142
vtkSQLQuery implementation for ODBC connections to databases
Definition: vtkODBCQuery.h:47