d_execute.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*!
  2. * \file db/dbmi_driver/d_execute.c
  3. *
  4. * \brief DBMI Library (driver) - execute SQL statements
  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 <stdlib.h>
  15. #include <grass/dbmi.h>
  16. #include "macros.h"
  17. #include "dbstubs.h"
  18. /*!
  19. \brief Execute SQL statements
  20. \return DB_OK on success
  21. \return DB_FAILED on failure
  22. */
  23. int db_d_execute_immediate(void)
  24. {
  25. int stat;
  26. dbString SQLstatement;
  27. /* get the arg(s) */
  28. db_init_string(&SQLstatement);
  29. DB_RECV_STRING(&SQLstatement);
  30. /* call the procedure */
  31. stat = db_driver_execute_immediate(&SQLstatement);
  32. db_free_string(&SQLstatement);
  33. /* send the return code */
  34. if (stat != DB_OK) {
  35. DB_SEND_FAILURE();
  36. return DB_OK;
  37. }
  38. DB_SEND_SUCCESS();
  39. /* no results */
  40. return DB_OK;
  41. }
  42. /*!
  43. \brief Begin transaction
  44. \return DB_OK on success
  45. \return DB_FAILED on failure
  46. */
  47. int db_d_begin_transaction(void)
  48. {
  49. int stat;
  50. /* call the procedure */
  51. stat = db_driver_begin_transaction();
  52. /* send the return code */
  53. if (stat != DB_OK) {
  54. DB_SEND_FAILURE();
  55. return DB_OK;
  56. }
  57. DB_SEND_SUCCESS();
  58. /* no results */
  59. return DB_OK;
  60. }
  61. /*!
  62. \brief Commit transaction
  63. \param driver db driver
  64. \return DB_OK on success
  65. \return DB_FAILED on failure
  66. */
  67. int db_d_commit_transaction()
  68. {
  69. int stat;
  70. /* call the procedure */
  71. stat = db_driver_commit_transaction();
  72. /* send the return code */
  73. if (stat != DB_OK) {
  74. DB_SEND_FAILURE();
  75. return DB_OK;
  76. }
  77. DB_SEND_SUCCESS();
  78. /* no results */
  79. return DB_OK;
  80. }