Retrieve data from a database using SQL statements.
When an application frees the statement using SQLFreeStmt with SQL_CLOSE option, it closes the cursor.
If you use SQLBindCol, values are automatically retrieved on each fetch.
If you use SQLGetData, you must call it for each column after each fetch.
SQLGetData is used to fetch values in pieces for columns such as LONG VARCHAR or LONG BINARY.
This code fragment from the simple sample opens a cursor on a query and retrieves data through the cursor. Error checking has been omitted to make the example easier to read.
SQLExecDirect( stmt, "select au_fname from authors", SQL_NTS ) ; retcode = SQLBindCol( stmt, 1, SQL_C_CHAR, aufName, sizeof(aufName), &aufNameLen); while(retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { retcode = SQLFetch( stmt ); }