Databases Reference
In-Depth Information
/* 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);
}
/* Close the cursor */
rc = SQLFreeStmt ((SQLHSTMT)hstmt, SQL_CLOSE);
/* Whether a commit occurs after a SELECT statement
because auto-commit is on depends on the driver.
It's safest to assume a commit occurs here. */
Performance Tip
Because of the significant amount of disk I/O on the database server
required to commit every operation and the extra network round trips
that occur between the driver and the database server, it's a good idea to
turn off auto-commit mode in your application and use manual commits
instead. Using manual commits allows your application to control when
database work is committed, which provides dramatically better perfor-
mance. To turn off auto-commit mode, use the SQLSetConnectAttr func-
tion, for example, SQLSetConnectAttr(hstmt , SQL_ATTR_AUTOCOMMIT ,
SQL_AUTOCOMMIT_OFF ) .
Search WWH ::




Custom Search