Databases Reference
In-Depth Information
Example 4-33 Using SQLConnect() & SQLDisconnect()
SQLConnect(conn_handle, "sample", SQL_NTS, NULL, SQL_NTS, NULL,
SQL_NTS);
SQLDisconnect(conn_handle);
4.5.5 Processing SQL statements
After connecting to the database, we need to allocate a statement handle to
manage our SQL statement. Once this is done, we can execute an SQL
statement by either preparing the statement or executing the statement directly.
Figure 4-2 illustrates this process.
SQLPrepare()
SQLBindParameter()
SQLBindParameter()
SQLExecDirect()
SQLExecute()
Prepare and execute
Execute directly
Figure 4-2 Processing SQL statements
In either case, if parameter markers exist in the SQL statement,
SQLBindParameter() must be called to associate each parameter marker to an
application buffer or a LOB locator. If a SELECT statement is run and a result set
expected, a cursor is automatically opened. So, unlike embedded SQL, cursors
neither have to be declared nor opened. To fetch the results, SQLBindCol() is
first called to bind the columns of a result set to application variables, then
SQLFetch() is called to fetch the rows.
Search WWH ::




Custom Search