nanodbc
A small C++ wrapper for the native C ODBC API
Loading...
Searching...
No Matches
Free Functions

Convenience functions. More...

Classes

struct  nanodbc::driver
 Information on a configured ODBC driver. More...
 
struct  nanodbc::datasource
 A data source name registered with the driver manager. More...
 

Functions

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

Detailed Description

Convenience functions.

Function Documentation

◆ execute() [1/2]

result nanodbc::execute ( connection conn,
string const &  query,
long  batch_operations = 1,
long  timeout = 0 
)

Immediately opens, prepares, and executes the given query directly on the given connection.

Parameters
connThe connection where the statement will be executed.
queryThe SQL query that will be executed.
batch_operationsNumbers of rows to fetch per rowset.
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() [1/2]

void nanodbc::just_execute ( connection conn,
string const &  query,
long  batch_operations = 1,
long  timeout = 0 
)

Opens, prepares, and executes query directly without creating result object.

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.
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 
)

Execute the previously prepared query now.

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() [2/2]

void nanodbc::just_execute ( statement stmt,
long  batch_operations = 1 
)

Execute the previously prepared query now and without creating result object.

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
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

◆ transact()

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

Execute the previously prepared query now.

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

◆ just_transact()

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

Execute the previously prepared query now and without creating result object.

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
See also
open(), prepare(), execute(), result, transaction

◆ prepare()

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

Prepares the given statement to execute on it associated connection.

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