Reads in the next row.
STATUS dbnextrow ( PDBPROCESS dbproc );
One of five different types of values:
Regular rows contain data from columns designated by a SELECT statement.
In this case, no row has been read. To read more rows, first clear at least one row from the top of the row buffer. To clear the row buffer, call dbclrbuf.
The dbnextrow function causes the next data row to be made available through the dbproc. If the DBBUFFER option is turned on and rows have been read out of order by calling dbgetrow, the next data row is read from the buffered rows. Any specified binding of row data to program variables takes effect.
The dbresults function must be called and must have returned SUCCEED before you make any calls to dbnextrow.
Even if dbrows or dbcmdrow returns FAIL (indicating that no rows were returned), you must process the results by calling dbnextrow until it returns NO_MORE_ROWS.
Normally, each row is processed in turn by repeatedly calling dbnextrow. If row buffering is enabled and the row buffer has been cleared by the dbclrbuf function, the discarded rows are no longer available (even if dbgetrow tries to position to a discarded row). When row buffering is disabled, the last row is cleared when dbnextrow returns NO_MORE_ROWS.
SQL Server can return two types of rows:
To help process data rows from SQL Server, dbnextrow returns different values according to the type of row.
If you want data returned from SQL Server to be displayed on the default output device, use dbprrow instead of dbnextrow (except with the Microsoft Windows® operating system).
Note This function is one of the four that do not return control to the application until the server sends the required response. The application can be blocked for a considerable time if the server is waiting for a lock or is processing a large sort. If this is unacceptable, always call dbdataready before dbnextrow and set the DB-Library time-out to regain control periodically.
The typical sequence of calls is:
DBINT xvariable;
DBCHAR yvariable[10];
// Read the query into the command buffer.
dbcmd(dbproc, "SELECT x = 100, y = 'hello'");
// Send the query to SQL Server.
dbsqlexec(dbproc);
// Get ready to process the results of the query.
dbresults(dbproc);
// Bind column data to program variables.
dbbind(dbproc, 1, INTBIND, (DBINT) 0, (BYTE *)&xvariable);
dbbind(dbproc, 2, STRINGBIND, (DBINT) 0, yvariable);
// Now process each row.
while (dbnextrow(dbproc) != NO_MORE_ROWS)
{
// C-code to print or process row data
}
Note that if you are not using row buffering, you must continue calling dbnextrow until it returns NO_MORE_ROWS. This is true even if you are sure that your query only generates one results row. The while loop in the preceding example illustrates the correct way to use dbnextrow.
Bulk-Copy Functions | dbgetrow |
dbbind | DB-Library Options |
dbclrbuf | dbprrow |
dbresults |