c_openupdate.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*!
  2. * \file db/dbmi_client/c_openupdate.c
  3. *
  4. * \brief DBMI Library (client) - open update cursor
  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 Open update cursor
  18. \param driver db driver
  19. \param table_name table name
  20. \param select SQL update statement (?)
  21. \param cursor db cursor to be opened
  22. \param mode open mode (?)
  23. \return DB_OK on success
  24. \return DB_FAILED on failure
  25. */
  26. int db_open_update_cursor(dbDriver * driver, dbString * table_name,
  27. dbString * select, dbCursor * cursor, int mode)
  28. {
  29. int ret_code;
  30. db_init_cursor(cursor);
  31. cursor->driver = driver;
  32. /* start the procedure call */
  33. db__set_protocol_fds(driver->send, driver->recv);
  34. DB_START_PROCEDURE_CALL(DB_PROC_OPEN_UPDATE_CURSOR);
  35. /* send the argument(s) to the procedure */
  36. DB_SEND_STRING(table_name);
  37. DB_SEND_STRING(select);
  38. DB_SEND_INT(mode);
  39. /* get the return code for the procedure call */
  40. DB_RECV_RETURN_CODE(&ret_code);
  41. if (ret_code != DB_OK)
  42. return ret_code; /* ret_code SHOULD == DB_FAILED */
  43. /* get the results */
  44. DB_RECV_TOKEN(&cursor->token);
  45. DB_RECV_INT(&cursor->type);
  46. DB_RECV_INT(&cursor->mode);
  47. DB_RECV_TABLE_DEFINITION(&cursor->table);
  48. db_alloc_cursor_column_flags(cursor);
  49. return DB_OK;
  50. }