Databases Reference
In-Depth Information
/* Close the cursor */
rc = SQLFreeStmt ((SQLHSTMT)hstmt, SQL_CLOSE);
strcpy (sqlStatement,
"UPDATE employees SET salary = salary * 1.05" +
"WHERE id = ?");
/* Prepare the UPDATE statement for multiple executions */
rc = SQLPrepare ((SQLHSTMT)hstmt, sqlStatement, SQL_NTS);
/* Bind parameter */
rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
SQL_C_SLONG, SQL_INTEGER, 10, 0,
&index, sizeof(index), NULL);
for (index = 0; index < 10; index++) {
/* Execute the UPDATE statement for each
value of index between 0 and 9 */
rc = SQLExecute (hstmt);
}
/* Manual commit */
rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT);
/* Reset parameter bindings */
rc = SQLFreeStmt ((SQLHSTMT)hstmt, SQL_RESET_PARAMS);
/* Execute a SELECT statement. A prepare is unnecessary
because it's only executed once. */
strcpy(sqlStatement, "SELECT id, name, salary" +
"FROM employees");
rc = SQLExecDirect ((SQLHSTMT)hstmt, sqlStatement, SQL_NTS);
Search WWH ::




Custom Search