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 
36 #ifndef vtkODBCQuery_h
37 #define vtkODBCQuery_h
38 
39 #include "vtkIOODBCModule.h" // For export macro
40 #include "vtkSQLQuery.h"
41 
42 class vtkODBCDatabase;
43 class vtkVariant;
44 class vtkVariantArray;
45 class vtkODBCInternals;
46 class vtkODBCQueryInternals;
47 
48 class VTKIOODBC_EXPORT vtkODBCQuery : public vtkSQLQuery
49 {
50 
51  friend class vtkODBCDatabase;
52 
53 public:
54  vtkTypeMacro(vtkODBCQuery, vtkSQLQuery);
55  void PrintSelf(ostream& os, vtkIndent indent);
56  static vtkODBCQuery *New();
57 
63  bool Execute();
64 
68  int GetNumberOfFields();
69 
73  const char* GetFieldName(int i);
74 
78  int GetFieldType(int i);
79 
83  bool NextRow();
84 
88  bool HasError();
89 
94 
98  const char* GetLastErrorText();
99 
101 
104  bool BeginTransaction();
105  bool CommitTransaction();
106  bool RollbackTransaction();
108 
110 
115  bool SetQuery(const char *queryString);
116  const char *GetQuery();
118 
128  bool BindParameter(int index, unsigned char value);
129  bool BindParameter(int index, signed char value);
130  bool BindParameter(int index, unsigned short value);
131  bool BindParameter(int index, signed short value);
132  bool BindParameter(int index, unsigned int value);
133 
134  bool BindParameter(int index, int value);
135 
136  bool BindParameter(int index, unsigned long value);
137  bool BindParameter(int index, signed long value);
138  bool BindParameter(int index, unsigned long long value);
139  bool BindParameter(int index, long long value);
140 
141  bool BindParameter(int index, float value);
142  bool BindParameter(int index, double value);
146  bool BindParameter(int index, const char *stringValue);
148 
151  bool BindParameter(int index, const char *stringValue, size_t length);
152  bool BindParameter(int index, const vtkStdString &string);
154 
155 
160  bool BindParameter(int index, const void *data, size_t length);
161  bool ClearParameterBindings();
163 
164 protected:
165  vtkODBCQuery();
166  ~vtkODBCQuery();
167 
168  vtkSetStringMacro(LastErrorText);
169  vtkSetStringMacro(QueryText);
170  vtkGetStringMacro(QueryText);
171 
172  char *QueryText;
173 
174 private:
175  vtkODBCQuery(const vtkODBCQuery &) VTK_DELETE_FUNCTION;
176  void operator=(const vtkODBCQuery &) VTK_DELETE_FUNCTION;
177 
178  void ClearCurrentRow();
179  bool CacheCurrentRow();
180 
181  bool CacheTimeColumn(int column);
182  bool CacheIntervalColumn(int column);
183  bool CacheCharColumn(int column);
184  bool CacheLongLongColumn(int column);
185  bool CacheBinaryColumn(int column);
186  bool CacheBooleanColumn(int column);
187  bool CacheStringColumn(int column);
188  bool CacheWideStringColumn(int column);
189  bool CacheDecimalColumn(int column);
190  bool CacheNumericColumn(int column);
191  bool CacheIntColumn(int column);
192  bool CacheFloatColumn(int column);
193  bool CacheDoubleColumn(int column);
194 
195  vtkODBCQueryInternals *Internals;
196  bool InitialFetch;
197  char *LastErrorText;
198 };
199 
200 #endif // vtkODBCQuery_h
201 
virtual bool SetQuery(const char *query)
The query string to be executed.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
virtual bool NextRow()=0
Advance row, return false if past end.
An array holding vtkVariants.
virtual const char * GetFieldName(int i)=0
Return the name of the specified query field.
virtual const char * GetQuery()
The query string to be executed.
virtual bool BindParameter(int index, unsigned char value)
Bind a parameter to a placeholder in a query.
friend class vtkODBCQuery
virtual bool CommitTransaction()
Definition: vtkSQLQuery.h:110
int vtkIdType
Definition: vtkType.h:287
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
A atomic type representing the union of many types.
Definition: vtkVariant.h:75
virtual bool HasError()=0
Returns true if an error is set, otherwise false.
Simple class to hide ODBC structures.
a simple class to control print indentation
Definition: vtkIndent.h:39
maintain an ODBC connection to a SQL database
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
virtual int GetNumberOfFields()=0
The number of fields in the query result.
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:111
virtual bool BeginTransaction()
Begin, commit, or roll back a transaction.
Definition: vtkSQLQuery.h:109
virtual int GetFieldType(int i)=0
Return the type of the field, using the constants defined in vtkType.h.
virtual bool Execute()=0
Execute the query.
virtual bool ClearParameterBindings()
Reset all parameter bindings to NULL.
virtual vtkVariant DataValue(vtkIdType c)=0
Return data in current row, field c.
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:74
virtual const char * GetLastErrorText()=0
Get the last error text from the query.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
char * QueryText
Definition: vtkODBCQuery.h:170
vtkSQLQuery implementation for ODBC connections to databases
Definition: vtkODBCQuery.h:48