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 "vtkSQLQuery.h"
39 
40 class vtkODBCDatabase;
41 class vtkVariant;
42 class vtkVariantArray;
43 class vtkODBCInternals;
44 class vtkODBCQueryInternals;
45 
47 {
48 //BTX
49  friend class vtkODBCDatabase;
50 //ETX
51 
52 public:
53  vtkTypeMacro(vtkODBCQuery, vtkSQLQuery);
54  void PrintSelf(ostream& os, vtkIndent indent);
55  static vtkODBCQuery *New();
56 
59  bool Execute();
60 
62  int GetNumberOfFields();
63 
65  const char* GetFieldName(int i);
66 
69  int GetFieldType(int i);
70 
72  bool NextRow();
73 
75  bool HasError();
76 
79 
81  const char* GetLastErrorText();
82 
84 
85  bool BeginTransaction();
86  bool CommitTransaction();
87  bool RollbackTransaction();
89 
91 
94  bool SetQuery(const char *queryString);
95  const char *GetQuery();
97 
99 
105  bool BindParameter(int index, unsigned char value);
106  bool BindParameter(int index, signed char value);
107  bool BindParameter(int index, unsigned short value);
108  bool BindParameter(int index, signed short value);
109  bool BindParameter(int index, unsigned int value);
110 //ETX
111  bool BindParameter(int index, int value);
112 //BTX
113  bool BindParameter(int index, unsigned long value);
114  bool BindParameter(int index, signed long value);
115  bool BindParameter(int index, vtkTypeUInt64 value);
116  bool BindParameter(int index, vtkTypeInt64 value);
117 //ETX
118  bool BindParameter(int index, float value);
119  bool BindParameter(int index, double value);
120  // Description:
121  // Bind a string value -- string must be null-terminated
122  bool BindParameter(int index, const char *stringValue);
123  // Description:
124  // Bind a string value by specifying an array and a size
125  bool BindParameter(int index, const char *stringValue, size_t length);
126  bool BindParameter(int index, const vtkStdString &string);
127  // Description:
128  // Bind a blob value. Not all databases support blobs as a data
129  // type. Check vtkSQLDatabase::IsSupported(VTK_SQL_FEATURE_BLOB) to
130  // make sure.
131  bool BindParameter(int index, const void *data, size_t length);
132  bool ClearParameterBindings();
134 
135 protected:
136  vtkODBCQuery();
137  ~vtkODBCQuery();
138 
139  vtkSetStringMacro(LastErrorText);
140  vtkSetStringMacro(QueryText);
141  vtkGetStringMacro(QueryText);
142 
143  char *QueryText;
144 
145 private:
146  vtkODBCQuery(const vtkODBCQuery &); // Not implemented.
147  void operator=(const vtkODBCQuery &); // Not implemented.
148 
149  void ClearCurrentRow();
150  bool CacheCurrentRow();
151 
152  bool CacheTimeColumn(int column);
153  bool CacheIntervalColumn(int column);
154  bool CacheCharColumn(int column);
155  bool CacheLongLongColumn(int column);
156  bool CacheBinaryColumn(int column);
157  bool CacheBooleanColumn(int column);
158  bool CacheStringColumn(int column);
159  bool CacheWideStringColumn(int column);
160  bool CacheDecimalColumn(int column);
161  bool CacheNumericColumn(int column);
162  bool CacheIntColumn(int column);
163  bool CacheFloatColumn(int column);
164  bool CacheDoubleColumn(int column);
165 
166  vtkODBCQueryInternals *Internals;
167  bool InitialFetch;
168  char *LastErrorText;
169 };
170 
171 #endif // __vtkODBCQuery_h
172 
virtual bool SetQuery(const char *query)
Wrapper around vtkstd::string to keep symbols short.
Definition: vtkStdString.h:45
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:99
int vtkIdType
Definition: vtkType.h:255
void PrintSelf(ostream &os, vtkIndent indent)
A atomic type representing the union of many types.
Definition: vtkVariant.h:72
virtual bool HasError()=0
Simple class to hide ODBC structures.
a simple class to control print indentation
Definition: vtkIndent.h:37
maintain an ODBC connection to a SQL database
virtual int GetNumberOfFields()=0
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:100
virtual bool BeginTransaction()
Definition: vtkSQLQuery.h:98
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:72
virtual const char * GetLastErrorText()=0
#define VTK_IO_EXPORT
static vtkObject * New()
char * QueryText
Definition: vtkODBCQuery.h:141
vtkSQLQuery implementation for ODBC connections to databases
Definition: vtkODBCQuery.h:46