GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-38f5cf43d1
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_open_update_cursor(dbDriver *driver, dbString *table_name, dbString *select, dbCursor *cursor, int mode)
Open update cursor.
Definition: c_openupdate.c:30
#define DB_OK
Definition: dbmi.h:71
#define DB_PROC_OPEN_UPDATE_CURSOR
Definition: dbmi.h:43
int db_alloc_cursor_column_flags(dbCursor *)
Allocate columns' flags for cursor.
Definition: cursor.c:275
void db_init_cursor(dbCursor *)
Initialize dbCursor.
Definition: cursor.c:23
void db__set_protocol_fds(FILE *, FILE *)
?
const struct driver * driver
Definition: driver/init.c:25
#define DB_SEND_STRING(x)
Definition: macros.h:24
#define DB_SEND_INT(x)
Definition: macros.h:82
#define DB_RECV_TABLE_DEFINITION(x)
Definition: macros.h:142
#define DB_RECV_INT(x)
Definition: macros.h:87
#define DB_RECV_TOKEN(x)
Definition: macros.h:219
#define DB_START_PROCEDURE_CALL(x)
Definition: macros.h:2
#define DB_RECV_RETURN_CODE(x)
Definition: macros.h:7
dbDriver * driver
Definition: dbmi.h:223
int mode
Definition: dbmi.h:227
dbTable * table
Definition: dbmi.h:224
int type
Definition: dbmi.h:226
dbToken token
Definition: dbmi.h:222
Definition: driver.h:21