d_update.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*!
  2. * \file db/dbmi_driver/d_update.c
  3. *
  4. * \brief DBMI Library (driver) - update statemets
  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 ?
  19. \return DB_OK on success
  20. \return DB_FAILED on failure
  21. */
  22. int db_d_update(void)
  23. {
  24. dbToken token;
  25. dbCursor *cursor;
  26. int stat;
  27. /* get the arg(s) */
  28. DB_RECV_TOKEN(&token);
  29. cursor = (dbCursor *) db_find_token(token);
  30. if (cursor == NULL || !db_test_cursor_type_update(cursor)) {
  31. db_error("** not an update cursor **");
  32. DB_SEND_FAILURE();
  33. return DB_FAILED;
  34. }
  35. if (!db_test_cursor_any_column_flag(cursor)) {
  36. db_error("** no columns bound in cursor for update **");
  37. DB_SEND_FAILURE();
  38. return DB_FAILED;
  39. }
  40. DB_RECV_TABLE_DATA(cursor->table);
  41. /* call the procedure */
  42. stat = db_driver_update(cursor);
  43. /* send the return code */
  44. if (stat != DB_OK) {
  45. DB_SEND_FAILURE();
  46. return DB_OK;
  47. }
  48. DB_SEND_SUCCESS();
  49. /* no results */
  50. return DB_OK;
  51. }