GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_openupdate.c
Go to the documentation of this file.
1 
15 #include <grass/dbmi.h>
16 #include "macros.h"
17 
31 int db_open_update_cursor(dbDriver * driver, dbString * table_name,
32  dbString * select, dbCursor * cursor, int mode)
33 {
34  int ret_code;
35 
36  db_init_cursor(cursor);
37  cursor->driver = driver;
38 
39  /* start the procedure call */
40  db__set_protocol_fds(driver->send, driver->recv);
41  DB_START_PROCEDURE_CALL(DB_PROC_OPEN_UPDATE_CURSOR);
42 
43  /* send the argument(s) to the procedure */
44  DB_SEND_STRING(table_name);
45  DB_SEND_STRING(select);
46  DB_SEND_INT(mode);
47 
48  /* get the return code for the procedure call */
49  DB_RECV_RETURN_CODE(&ret_code);
50 
51  if (ret_code != DB_OK)
52  return ret_code; /* ret_code SHOULD == DB_FAILED */
53 
54  /* get the results */
55  DB_RECV_TOKEN(&cursor->token);
56  DB_RECV_INT(&cursor->type);
57  DB_RECV_INT(&cursor->mode);
58  DB_RECV_TABLE_DEFINITION(&cursor->table);
60  return DB_OK;
61 }