[ Previous ] [ Contents ] [ Index ] [ Next ]



Fetch the next waiting row after an Ns_DbSelect


    int Ns_DbGetRow(
    Ns_DbHandle *handle,
    Ns_Set *row


The Ns_DbGetRow function fetches the next row waiting to be retrieved after an Ns_DbSelect. The row Ns_Set must be the result of a previous Ns_DbSelect. Ns_DbGetRow frees any existing values of the set and sets the values to the next row fetched from the database. Possible return values are:


A row has been fetched and more rows may be waiting.


No row has been fetched and there are no more rows waiting.


A database error occurred, or the function has already returned NS_END_DATA but has been called again anyway.

You cannot call Ns_DbDML, Ns_Db1Row, or Ns_Db0or1Row with the same database handle while fetching rows from the database in an Ns_DbGetRow loop. Doing so flushes any waiting rows and a subsequent call to Ns_DbGetRow will fail. You can do so if you use separate database handles.


    	Ns_DbHandle *handle;
    	Ns_Set *row;
    	int		status;
    	handle = Ns_DbPoolGetHandle("mypool");
    	row = Ns_DbSelect(handle, "select * from mytable");
    	if (row == NULL) {
    		/*... handle select error ...*/
    	while ((status = Ns_DbGetRow(handle, row)) == NS_OK) {
    		/*... process the row fetched from the database ...*/
    	if (status != NS_END_DATA) {
    		/*... handle get row error ...*/

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1998-99 America Online, Inc.