00001 #include <grass/dbmi.h> 00002 #include "macros.h" 00003 #include "dbstubs.h" 00004 00011 int 00012 db_d_open_insert_cursor() 00013 { 00014 dbCursor *cursor; 00015 dbTable *table; 00016 int stat; 00017 dbToken token; 00018 00019 /* get the arg(s) */ 00020 DB_RECV_TABLE_DEFINITION(&table); 00021 00022 /* create a cursor */ 00023 cursor = (dbCursor *) db_malloc (sizeof(dbCursor)); 00024 if (cursor == NULL) 00025 return db_get_error_code(); 00026 token = db_new_token ( (dbAddress) cursor); 00027 if (token < 0) 00028 return db_get_error_code(); 00029 db_init_cursor(cursor); 00030 db_set_cursor_table(cursor, table); 00031 00032 /* call the procedure */ 00033 stat = db_driver_open_insert_cursor (cursor); 00034 00035 /* send the return code */ 00036 if (stat != DB_OK) 00037 { 00038 DB_SEND_FAILURE(); 00039 return DB_OK; 00040 } 00041 DB_SEND_SUCCESS(); 00042 00043 /* mark this as an insert cursor */ 00044 db_set_cursor_type_insert (cursor); 00045 00046 /* add this cursor to the cursors managed by the driver state */ 00047 db__add_cursor_to_driver_state(cursor); 00048 00049 /* results */ 00050 DB_SEND_TOKEN (&token); 00051 DB_SEND_INT (cursor->type); 00052 DB_SEND_INT (cursor->mode); 00053 return DB_OK; 00054 }