c_openupdate.c

Go to the documentation of this file.
00001 
00015 #include <grass/dbmi.h>
00016 #include "macros.h"
00017 
00031 int db_open_update_cursor(dbDriver * driver, dbString * table_name,
00032                           dbString * select, dbCursor * cursor, int mode)
00033 {
00034     int ret_code;
00035 
00036     db_init_cursor(cursor);
00037     cursor->driver = driver;
00038 
00039     /* start the procedure call */
00040     db__set_protocol_fds(driver->send, driver->recv);
00041     DB_START_PROCEDURE_CALL(DB_PROC_OPEN_UPDATE_CURSOR);
00042 
00043     /* send the argument(s) to the procedure */
00044     DB_SEND_STRING(table_name);
00045     DB_SEND_STRING(select);
00046     DB_SEND_INT(mode);
00047 
00048     /* get the return code for the procedure call */
00049     DB_RECV_RETURN_CODE(&ret_code);
00050 
00051     if (ret_code != DB_OK)
00052         return ret_code;        /* ret_code SHOULD == DB_FAILED */
00053 
00054     /* get the results */
00055     DB_RECV_TOKEN(&cursor->token);
00056     DB_RECV_INT(&cursor->type);
00057     DB_RECV_INT(&cursor->mode);
00058     DB_RECV_TABLE_DEFINITION(&cursor->table);
00059     db_alloc_cursor_column_flags(cursor);
00060     return DB_OK;
00061 }