dtl


DBStmt

Category: utilities Component type: type

Description

The DBStmt object manages a single ODBC statement, such as INSERT, SELECT, UPDATE or native SQL strings that need to be passed through to the database.

Definition

Defined in the DBStmt.h header file.

Refinement of

None.

Associated types

None.

Example: Executing a SQL Statement Directly via DBStmt

int main(int argc, char **argv)
{
  DBConnection::GetDefaultConnection().Connect("UID=example;PWD=example;DSN=example;");
  DBStmt("DELETE FROM DB_EXAMPLE").Execute();
  DBStmt("INSERT INTO DB_EXAMPLE SELECT * FROM DB_EXAMPLE_BACKUP").Execute();
}

Public Base Classes

ValidatedObject

Notation

X A type that is a model of DBStmt
a Object of type X

Expression semantics

Name Expression Precondition Semantics Postcondition
Constructor
X a(string query, 
DBConnection &connection = DBConnection::GetDefaultConnection())
  Creates an ODBC statement using the string in query and the DBConnection object specified by connection. If no connection object is passed in to the constructor, the default connection object is used. The SQL statement is SQLPrepared against the database at construction time so that Execute() can run quickly if it needs to be called multiple times.  
Execute a statement
Execute()
  Execute the SQL string held by the statement.  
Swap with another connection
void swap(X &other)
  Swap *this with other.  
Get next result set if one exists bool MoreResults()   Get the next result set for this statement if one exists. Return whether the statement actually grabbed another result set.  

Notes

See also

DBConnection, DBView, IndexedDBView, ValidatedObject


[DTL Home]

Copyright © 2002, Michael Gradman and Corwin Joy.

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Corwin Joy and Michael Gradman make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

This site written using the ORB. [The ORB]

1