d_rows.c 958 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*!
  2. * \file db/dbmi_driver/d_rows.c
  3. *
  4. * \brief DBMI Library (driver) - 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. #include "dbstubs.h"
  17. /*!
  18. \brief Get number of selected rows
  19. \return DB_OK on success
  20. \return DB_FAILED on failure
  21. */
  22. int db_d_get_num_rows(void)
  23. {
  24. dbToken token;
  25. dbCursor *cursor;
  26. int nrows;
  27. /* get the arg(s) */
  28. DB_RECV_TOKEN(&token);
  29. cursor = (dbCursor *) db_find_token(token);
  30. /* call the procedure */
  31. nrows = db_driver_get_num_rows(cursor);
  32. /* send the return code */
  33. if (nrows < 0) {
  34. DB_SEND_FAILURE();
  35. return DB_OK;
  36. }
  37. DB_SEND_SUCCESS();
  38. /* results */
  39. DB_SEND_INT(nrows);
  40. return DB_OK;
  41. }