GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
c_execute.c
Go to the documentation of this file.
1 /*!
2  * \file db/dbmi_client/c_execute.c
3  *
4  * \brief DBMI Library (client) - 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 
15 #include <grass/dbmi.h>
16 #include "macros.h"
17 
18 /*!
19  \brief Execute SQL statements
20 
21  \param driver db driver
22  \param SQLstatement SQL statement (alter, update, ...)
23 
24  \return DB_OK on success
25  \return DB_FAILED on failure
26  */
28 {
29  int ret_code;
30 
31  /* start the procedure call */
32  db__set_protocol_fds(driver->send, driver->recv);
34 
35  /* send the argument(s) to the procedure */
36  DB_SEND_STRING(SQLstatement);
37 
38  /* get the return code for the procedure call */
39  DB_RECV_RETURN_CODE(&ret_code);
40 
41  if (ret_code != DB_OK)
42  return ret_code; /* ret_code SHOULD == DB_FAILED */
43 
44  /* no results */
45  return DB_OK;
46 }
47 
48 /*!
49  \brief Begin transaction
50 
51  \param driver db driver
52 
53  \return DB_OK on success
54  \return DB_FAILED on failure
55  */
57 {
58  int ret_code;
59 
60  /* start the procedure call */
61  db__set_protocol_fds(driver->send, driver->recv);
63 
64  /* get the return code for the procedure call */
65  DB_RECV_RETURN_CODE(&ret_code);
66 
67  if (ret_code != DB_OK)
68  return ret_code;
69 
70  /* no results */
71  return DB_OK;
72 }
73 
74 /*!
75  \brief Commit transaction
76 
77  \param driver db driver
78 
79  \return DB_OK on success
80  \return DB_FAILED on failure
81  */
83 {
84  int ret_code;
85 
86  /* start the procedure call */
87  db__set_protocol_fds(driver->send, driver->recv);
89 
90  /* get the return code for the procedure call */
91  DB_RECV_RETURN_CODE(&ret_code);
92 
93  if (ret_code != DB_OK)
94  return ret_code;
95 
96  /* no results */
97  return DB_OK;
98 }
#define DB_PROC_COMMIT_TRANSACTION
Definition: dbmi.h:51
#define DB_PROC_EXECUTE_IMMEDIATE
Definition: dbmi.h:49
int db_begin_transaction(dbDriver *driver)
Begin transaction.
Definition: c_execute.c:56
int db_execute_immediate(dbDriver *driver, dbString *SQLstatement)
Execute SQL statements.
Definition: c_execute.c:27
#define DB_START_PROCEDURE_CALL(x)
Definition: macros.h:2
#define DB_RECV_RETURN_CODE(x)
Definition: macros.h:4
#define DB_SEND_STRING(x)
Definition: macros.h:12
Definition: driver.h:22
FILE * recv
Definition: dbmi.h:171
void db__set_protocol_fds(FILE *, FILE *)
?
FILE * send
Definition: dbmi.h:171
#define DB_PROC_BEGIN_TRANSACTION
Definition: dbmi.h:50
int db_commit_transaction(dbDriver *driver)
Commit transaction.
Definition: c_execute.c:82
#define DB_OK
Definition: dbmi.h:71