View on GitHub API Documentation
A small C++ wrapper for the native C ODBC API.
Classes | Functions
Free Functions

Convenience functions. More...

Classes

struct  nanodbc::driver
 Information on a configured ODBC driver. More...
 

Functions

std::list< drivernanodbc::list_drivers ()
 Returns a list of ODBC drivers on your system.
 
result nanodbc::execute (connection &conn, const string &query, long batch_operations=1, long timeout=0)
 Immediately opens, prepares, and executes the given query directly on the given connection. More...
 
void nanodbc::just_execute (connection &conn, const string &query, long batch_operations=1, long timeout=0)
 Opens, prepares, and executes query directly without creating result object. More...
 
result nanodbc::execute (statement &stmt, long batch_operations=1)
 Execute the previously prepared query now. More...
 
void nanodbc::just_execute (statement &stmt, long batch_operations=1)
 Execute the previously prepared query now and without creating result object. More...
 
result nanodbc::transact (statement &stmt, long batch_operations)
 Execute the previously prepared query now. More...
 
void nanodbc::just_transact (statement &stmt, long batch_operations)
 Execute the previously prepared query now and without creating result object. More...
 
void nanodbc::prepare (statement &stmt, const string &query, long timeout=0)
 Prepares the given statement to execute on it associated connection. More...
 

Detailed Description

Function Documentation

◆ execute() [1/2]

result nanodbc::execute ( connection conn,
const string query,
long  batch_operations = 1,
long  timeout = 0 
)
Parameters
connThe connection where the statement will be executed.
queryThe SQL query that will be executed.
batch_operationsNumbers of rows to fetch per rowset, or the number of batch parameters to process.
timeoutThe number in seconds before query timeout. Default is 0 indicating no timeout.
Returns
A result set object.
Attention
You will want to use transactions if you are doing batch operations because it will prevent auto commits from occurring after each individual operation is executed.
See also
open(), prepare(), execute(), result, transaction

◆ execute() [2/2]

result nanodbc::execute ( statement stmt,
long  batch_operations = 1 
)
Parameters
stmtThe prepared statement that will be executed.
batch_operationsRows to fetch per rowset, or the number of batch parameters to process.
Exceptions
database_error
Returns
A result set object.
Attention
You will want to use transactions if you are doing batch operations because it will prevent auto commits from occurring after each individual operation is executed.
See also
open(), prepare(), execute(), result

◆ just_execute() [1/2]

void nanodbc::just_execute ( connection conn,
const string query,
long  batch_operations = 1,
long  timeout = 0 
)
Parameters
connThe connection where the statement will be executed.
queryThe SQL query that will be executed.
batch_operationsRows to fetch per rowset, or number of batch parameters to process.
timeoutThe number in seconds before query timeout. Default is 0 indicating no timeout.
Returns
A result set object.
Attention
You will want to use transactions if you are doing batch operations because it will prevent auto commits from occurring after each individual operation is executed.
See also
open(), prepare(), execute(), result, transaction

◆ just_execute() [2/2]

void nanodbc::just_execute ( statement stmt,
long  batch_operations = 1 
)
Parameters
stmtThe prepared statement that will be executed.
batch_operationsRows to fetch per rowset, or the number of batch parameters to process.
Exceptions
database_error
Returns
A result set object.
Attention
You will want to use transactions if you are doing batch operations because it will prevent auto commits from occurring after each individual operation is executed.
See also
open(), prepare(), execute(), result

◆ just_transact()

void nanodbc::just_transact ( statement stmt,
long  batch_operations 
)

Executes within the context of a transaction object, commits directly after execution.

Parameters
stmtThe prepared statement that will be executed in batch.
batch_operationsRows to fetch per rowset, or the number of batch parameters to process.
Exceptions
database_error
Returns
A result set object.
See also
open(), prepare(), execute(), result, transaction

◆ prepare()

void nanodbc::prepare ( statement stmt,
const string query,
long  timeout = 0 
)

If the statement is not open throws programming_error.

Parameters
stmtThe prepared statement that will be executed in batch.
queryThe SQL query that will be executed.
timeoutThe number in seconds before query timeout. Default is 0 indicating no timeout.
See also
open()
Exceptions
database_error,programming_error

◆ transact()

result nanodbc::transact ( statement stmt,
long  batch_operations 
)

Executes within the context of a transaction object, commits directly after execution.

Parameters
stmtThe prepared statement that will be executed in batch.
batch_operationsRows to fetch per rowset, or the number of batch parameters to process.
Exceptions
database_error
Returns
A result set object.
See also
open(), prepare(), execute(), result, transaction