Databases Reference
In-Depth Information
salary = 150000;
rc = SQLExecute(hstmt);
/* Reset parameter bindings */
rc = SQLFreeStmt(hstmt, SQL_RESET_PARAMS);
/* Manual commit */
rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT);
/* 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);
/* Fetch the first row */
rc = SQLFetch(hstmt);
while (rc != SQL_NO_DATA_FOUND) {
/* All rows are returned when fetch
returns SQL_NO_DATA_FOUND */
/* Get the data for each column in the result set row */
rc = SQLGetData (hstmt, 1, SQL_INTEGER, &id,
sizeof(id), NULL);
rc = SQLGetData (hstmt, 2, SQL_VARCHAR, &name,
sizeof(name), NULL);
rc = SQLGetData (hstmt, 3, SQL_INTEGER, &salary,
sizeof(salary), NULL);
printf("\nID: %d Name: %s Salary: %d", id, name, salary);
/* Fetch the next row of data */
rc = SQLFetch(hstmt);
}
Search WWH ::




Custom Search