GRASS Programmer's Manual 6.4.1(2011)
|
00001 00015 #include <stdlib.h> 00016 #include <grass/dbmi.h> 00017 #include "macros.h" 00018 #include "dbstubs.h" 00019 00026 int db_d_open_update_cursor(void) 00027 { 00028 dbCursor *cursor; 00029 int stat; 00030 dbToken token; 00031 dbString select; 00032 dbString table_name; 00033 int mode; 00034 00035 /* get the arg(s) */ 00036 db_init_string(&table_name); 00037 db_init_string(&select); 00038 DB_RECV_STRING(&table_name); 00039 DB_RECV_STRING(&select); 00040 DB_RECV_INT(&mode); 00041 00042 /* create a cursor */ 00043 cursor = (dbCursor *) db_malloc(sizeof(dbCursor)); 00044 if (cursor == NULL) 00045 return db_get_error_code(); 00046 token = db_new_token((dbAddress) cursor); 00047 if (token < 0) 00048 return db_get_error_code(); 00049 db_init_cursor(cursor); 00050 00051 /* call the procedure */ 00052 stat = db_driver_open_update_cursor(&table_name, &select, cursor, mode); 00053 db_free_string(&table_name); 00054 db_free_string(&select); 00055 00056 /* send the return code */ 00057 if (stat != DB_OK) { 00058 DB_SEND_FAILURE(); 00059 return DB_OK; 00060 } 00061 DB_SEND_SUCCESS(); 00062 00063 /* mark this as an update cursor */ 00064 db_set_cursor_type_update(cursor); 00065 00066 /* add this cursor to the cursors managed by the driver state */ 00067 db__add_cursor_to_driver_state(cursor); 00068 00069 /* results */ 00070 DB_SEND_TOKEN(&token); 00071 DB_SEND_INT(cursor->type); 00072 DB_SEND_INT(cursor->mode); 00073 DB_SEND_TABLE_DEFINITION(cursor->table); 00074 return DB_OK; 00075 }