GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
c_openupdate.c
Go to the documentation of this file.
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 
15 #include <grass/dbmi.h>
16 #include "macros.h"
17 
18 /*!
19  \brief Open update cursor
20 
21  \param driver db driver
22  \param table_name table name
23  \param select SQL update statement (?)
24  \param cursor db cursor to be opened
25  \param mode open mode (?)
26 
27  \return DB_OK on success
28  \return DB_FAILED on failure
29  */
31  dbString * select, dbCursor * cursor, int mode)
32 {
33  int ret_code;
34 
35  db_init_cursor(cursor);
36  cursor->driver = driver;
37 
38  /* start the procedure call */
39  db__set_protocol_fds(driver->send, driver->recv);
41 
42  /* send the argument(s) to the procedure */
43  DB_SEND_STRING(table_name);
44  DB_SEND_STRING(select);
45  DB_SEND_INT(mode);
46 
47  /* get the return code for the procedure call */
48  DB_RECV_RETURN_CODE(&ret_code);
49 
50  if (ret_code != DB_OK)
51  return ret_code; /* ret_code SHOULD == DB_FAILED */
52 
53  /* get the results */
54  DB_RECV_TOKEN(&cursor->token);
55  DB_RECV_INT(&cursor->type);
56  DB_RECV_INT(&cursor->mode);
59  return DB_OK;
60 }
int db_alloc_cursor_column_flags(dbCursor *)
Allocate columns&#39; flags for cursor.
Definition: cursor.c:276
#define DB_PROC_OPEN_UPDATE_CURSOR
Definition: dbmi.h:43
#define DB_SEND_INT(x)
Definition: macros.h:37
#define DB_RECV_INT(x)
Definition: macros.h:39
#define DB_RECV_TOKEN(x)
Definition: macros.h:99
int db_open_update_cursor(dbDriver *driver, dbString *table_name, dbString *select, dbCursor *cursor, int mode)
Open update cursor.
Definition: c_openupdate.c:30
dbDriver * driver
Definition: dbmi.h:233
int type
Definition: dbmi.h:236
#define DB_START_PROCEDURE_CALL(x)
Definition: macros.h:2
const struct driver * driver
Definition: driver/init.c:25
#define DB_RECV_TABLE_DEFINITION(x)
Definition: macros.h:64
void db_init_cursor(dbCursor *)
Initialize dbCursor.
Definition: cursor.c:23
#define DB_RECV_RETURN_CODE(x)
Definition: macros.h:4
#define DB_SEND_STRING(x)
Definition: macros.h:12
dbToken token
Definition: dbmi.h:232
Definition: driver.h:22
FILE * recv
Definition: dbmi.h:171
void db__set_protocol_fds(FILE *, FILE *)
?
int mode
Definition: dbmi.h:237
FILE * send
Definition: dbmi.h:171
dbTable * table
Definition: dbmi.h:234
#define DB_OK
Definition: dbmi.h:71