|
|
Ns_Set *Ns_DbSelect(
Ns_DbHandle *handle,
char *sql
);
On error, Ns_DbSelect returns NULL. Detailed error message may have accumulated in an internal buffer in the Ns_DbHandle. These errors can be conveyed back to the user through the Ns_DbReturnError function.
Ns_DbHandle *handle;
if ((handle = Ns_DbPoolGetHandle("aPoolName")) != NULL) {
Ns_Set *row;
row = Ns_DbSelect(handle, "select * from aTable");
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 ...*/
}
Ns_DbPoolPutHandle(handle); /* done with handle */
}