c_rows.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*!
  2. * \file db/dbmi_client/c_rows.c
  3. *
  4. * \brief DBMI Library (client) - get number of records
  5. *
  6. * (C) 1999-2008 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public
  9. * License (>=v2). Read the file COPYING that comes with GRASS
  10. * for details.
  11. *
  12. * \author Joel Jones (CERL/UIUC), Radim Blazek
  13. */
  14. #include <grass/dbmi.h>
  15. #include "macros.h"
  16. /*!
  17. \brief Get number of selected rows
  18. \param cursor db select cursor
  19. \return DB_OK on success
  20. \return DB_FAILED on failure
  21. */
  22. int db_get_num_rows(dbCursor * cursor)
  23. {
  24. int nrows, ret_code;
  25. /* start the procedure call */
  26. db__set_protocol_fds(cursor->driver->send, cursor->driver->recv);
  27. DB_START_PROCEDURE_CALL(DB_PROC_ROWS);
  28. /* send the argument(s) to the procedure */
  29. DB_SEND_TOKEN(&cursor->token);
  30. /* get the return code for the procedure call */
  31. DB_RECV_RETURN_CODE(&ret_code);
  32. if (ret_code != DB_OK)
  33. return -1;
  34. /* get the results */
  35. DB_RECV_INT(&nrows);
  36. return nrows;
  37. }