Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
virtual P6R::P6ERR P6R::p6IDBC::prepare ( const P6WCHAR pSql,
p6IDBCStmt **  pStatement 
)
pure virtual

Prepare an SQL query to be run against the database.

The SQL statement can contain variables that need to be bound to values before the query is to be run. For example,

* p6IDBC *pDB;
* p6IDBCStmt *pStmt;
*
* // here the SQL statement is complete
* pDB->prepare( P6TEXT("INSERT INTO test1(ID, email) VALUES( 88, 'henry@p6r.com' );"), &pStmt );
*
* // in SQLite, here the SQL statement has 2 variables marked by '?' that need to be bound to values via the pStmt object
* pDB->prepare( P6TEXT("INSERT INTO test1(ID, email) VALUES( ?, ? );"), &pStmt );
*
* // in Postgres, here the SQL statement has 3 variables marked by '$' that need to be bound to values
* pDB->prepare( P6TEXT("INSERT INTO test2(ID, event, sku) VALUES( $1, $2, $3 );"), &pStmt );
*
Parameters
pSql[ in ] String containing a valid SQL statement
pStatement[ out ] A p6IDBCStmt component that can be used to bind parameters to the SQL statement and to execute the query against the openned database.
Returns
SuccessP6R::eOk 
FailureP6R::eNoMemoryInsuffficient memory to properly initialize the component
P6R::eNotInitializedA call to initialize() has not been made.
P6R::eInvalidArgOne of the paramters is NULL.