Example: lrd_fetch

In the following example, a SELECT statement retrieves all of the database records in the employee table. lrd_exec executes the statement and lrd_bind_col binds all the host variables to columns. The lrd_fetch function gets the data and prepares it for display in a grid.

 /* Set up and execute the SQL statement.*/
lr_think_time(76);
lrd_stmt(Csr1, "select ename from employee where (sal>=1000)\n", -1, 1, 1, 0);
lrd_bind_col(Csr1, 1, &D21_ENAME, 0);
lrd_exec(Csr1, 0, 0, 0, 0);
lrd_fetch(Csr1, -3, 1, 0, PrintRow24, 0);
 /* All three rows of the result set were fetched */

In the following example, nRowsFetched contains the number of rows fetched.

int nRowsFetch = 0;
lrd_stmt(Csr1, "select * from CustomNames", -1, 1, 0 /*None*/, 0);
lrd_bind_cols(Csr1, BCInfo_D3, 0)
lrd_fetch(Csr1, -34, 1, &nRowsFetched, PrintRow2, 0);