vtkSQLQuery Class Reference

#include <vtkSQLQuery.h>

Inheritance diagram for vtkSQLQuery:

Inheritance graph
[legend]
Collaboration diagram for vtkSQLQuery:

Collaboration graph
[legend]

List of all members.


Detailed Description

executes an sql query and retrieves results

The abstract superclass of SQL query classes. Instances of subclasses of vtkSQLQuery are created using the GetQueryInstance() function in vtkSQLDatabase. To implement a query connection for a new database type, subclass both vtkSQLDatabase and vtkSQLQuery, and implement the required functions. For the query class, this involves the following:

Execute() - Execute the query on the database. No results need to be retrieved at this point, unless you are performing caching.

GetNumberOfFields() - After Execute() is performed, returns the number of fields in the query results.

GetFieldName() - The name of the field at an index.

GetFieldType() - The data type of the field at an index.

NextRow() - Advances the query results by one row, and returns whether there are more rows left in the query.

DataValue() - Extract a single data value from the current row.

Begin/Rollback/CommitTransaction() - These methods are optional but recommended if the database supports transactions.

Thanks:
Thanks to Andrew Wilson from Sandia National Laboratories for his work on the database classes.
See also:
vtkSQLDatabase
Tests:
vtkSQLQuery (Tests)

Definition at line 69 of file vtkSQLQuery.h.


Public Types

typedef vtkRowQuery Superclass

Public Member Functions

virtual const char * GetClassName ()
virtual int IsA (const char *type)
void PrintSelf (ostream &os, vtkIndent indent)
bool IsActive ()
virtual bool Execute ()=0
char * EscapeString (const char *src, bool addSurroundingQuotes)
virtual char * GetQuery ()
virtual void SetQuery (const char *)
virtual bool BeginTransaction ()
virtual bool CommitTransaction ()
virtual bool RollbackTransaction ()
virtual vtkSQLDatabaseGetDatabase ()
virtual vtkStdString EscapeString (vtkStdString s, bool addSurroundingQuotes=true)

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkSQLQuerySafeDownCast (vtkObject *o)

Protected Member Functions

 vtkSQLQuery ()
 ~vtkSQLQuery ()
void SetDatabase (vtkSQLDatabase *db)

Protected Attributes

char * Query
vtkSQLDatabaseDatabase
bool Active

Member Typedef Documentation

Reimplemented from vtkRowQuery.

Reimplemented in vtkMySQLQuery, vtkPostgreSQLQuery, and vtkSQLiteQuery.

Definition at line 72 of file vtkSQLQuery.h.


Constructor & Destructor Documentation

vtkSQLQuery::vtkSQLQuery (  )  [protected]

vtkSQLQuery::~vtkSQLQuery (  )  [protected]


Member Function Documentation

virtual const char* vtkSQLQuery::GetClassName (  )  [virtual]

Reimplemented from vtkRowQuery.

Reimplemented in vtkMySQLQuery, vtkPostgreSQLQuery, and vtkSQLiteQuery.

static int vtkSQLQuery::IsTypeOf ( const char *  name  )  [static]

Return 1 if this class type is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeRevisionMacro found in vtkSetGet.h.

Reimplemented from vtkRowQuery.

Reimplemented in vtkMySQLQuery, vtkPostgreSQLQuery, and vtkSQLiteQuery.

virtual int vtkSQLQuery::IsA ( const char *  name  )  [virtual]

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeRevisionMacro found in vtkSetGet.h.

Reimplemented from vtkRowQuery.

Reimplemented in vtkMySQLQuery, vtkPostgreSQLQuery, and vtkSQLiteQuery.

static vtkSQLQuery* vtkSQLQuery::SafeDownCast ( vtkObject o  )  [static]

Reimplemented from vtkRowQuery.

Reimplemented in vtkMySQLQuery, vtkPostgreSQLQuery, and vtkSQLiteQuery.

void vtkSQLQuery::PrintSelf ( ostream &  os,
vtkIndent  indent 
) [virtual]

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkRowQuery.

Reimplemented in vtkMySQLQuery, vtkPostgreSQLQuery, and vtkSQLiteQuery.

virtual char* vtkSQLQuery::GetQuery (  )  [virtual]

The query string to be executed.

virtual void vtkSQLQuery::SetQuery ( const char *   )  [virtual]

The query string to be executed.

bool vtkSQLQuery::IsActive (  )  [inline, virtual]

Return true if the query is active (i.e. execution was successful and results are ready to be fetched). Returns false on error or inactive query.

Implements vtkRowQuery.

Definition at line 84 of file vtkSQLQuery.h.

virtual bool vtkSQLQuery::Execute (  )  [pure virtual]

Execute the query. This must be performed before any field name or data access functions are used.

Implements vtkRowQuery.

Implemented in vtkMySQLQuery, vtkPostgreSQLQuery, and vtkSQLiteQuery.

virtual bool vtkSQLQuery::BeginTransaction (  )  [inline, virtual]

Begin, commit, or roll back a transaction. If the underlying database does not support transactions these calls will do nothing.

Reimplemented in vtkPostgreSQLQuery, and vtkSQLiteQuery.

Definition at line 93 of file vtkSQLQuery.h.

virtual bool vtkSQLQuery::CommitTransaction (  )  [inline, virtual]

Begin, commit, or roll back a transaction. If the underlying database does not support transactions these calls will do nothing.

Reimplemented in vtkPostgreSQLQuery, and vtkSQLiteQuery.

Definition at line 94 of file vtkSQLQuery.h.

virtual bool vtkSQLQuery::RollbackTransaction (  )  [inline, virtual]

Begin, commit, or roll back a transaction. If the underlying database does not support transactions these calls will do nothing.

Reimplemented in vtkPostgreSQLQuery, and vtkSQLiteQuery.

Definition at line 95 of file vtkSQLQuery.h.

virtual vtkSQLDatabase* vtkSQLQuery::GetDatabase (  )  [virtual]

Return the database associated with the query.

virtual vtkStdString vtkSQLQuery::EscapeString ( vtkStdString  s,
bool  addSurroundingQuotes = true 
) [virtual]

Escape a string for inclusion into an SQL query. If addSurroundingQuotes is true, then quotation marks appropriate to the backend database will be added to enclose the escaped string. This argument defaults to true. A default, simple-minded implementation is provided for database backends that do not provde a way to escape strings for use inside queries.

Reimplemented in vtkMySQLQuery, and vtkPostgreSQLQuery.

char* vtkSQLQuery::EscapeString ( const char *  src,
bool  addSurroundingQuotes 
)

Escape a string for inclusion into an SQL query. This method exists to provide a wrappable version of the method that takes and returns vtkStdString objects. You are responsible for calling delete [] on the character array returned by this method. This method simply calls the vtkStdString variant and thus need not be re-implemented by subclasses.

void vtkSQLQuery::SetDatabase ( vtkSQLDatabase db  )  [protected]

Set the database associated with the query. This is only to be called by the corresponding database class on creation of the query in GetQueryInstance().


Member Data Documentation

char* vtkSQLQuery::Query [protected]

Definition at line 132 of file vtkSQLQuery.h.

Definition at line 133 of file vtkSQLQuery.h.

bool vtkSQLQuery::Active [protected]

Definition at line 134 of file vtkSQLQuery.h.


The documentation for this class was generated from the following file:

Generated on Sat Dec 27 13:51:15 2008 for VTK by  doxygen 1.5.6