GRASS Programmer's Manual  6.4.1(2011)
d_openinsert.c
Go to the documentation of this file.
00001 
00015 #include <grass/dbmi.h>
00016 #include "macros.h"
00017 #include "dbstubs.h"
00018 
00025 int db_d_open_insert_cursor(void)
00026 {
00027     dbCursor *cursor;
00028     dbTable *table;
00029     int stat;
00030     dbToken token;
00031 
00032     /* get the arg(s) */
00033     DB_RECV_TABLE_DEFINITION(&table);
00034 
00035     /* create a cursor */
00036     cursor = (dbCursor *) db_malloc(sizeof(dbCursor));
00037     if (cursor == NULL)
00038         return db_get_error_code();
00039     token = db_new_token((dbAddress) cursor);
00040     if (token < 0)
00041         return db_get_error_code();
00042     db_init_cursor(cursor);
00043     db_set_cursor_table(cursor, table);
00044 
00045     /* call the procedure */
00046     stat = db_driver_open_insert_cursor(cursor);
00047 
00048     /* send the return code */
00049     if (stat != DB_OK) {
00050         DB_SEND_FAILURE();
00051         return DB_OK;
00052     }
00053     DB_SEND_SUCCESS();
00054 
00055     /* mark this as an insert cursor */
00056     db_set_cursor_type_insert(cursor);
00057 
00058     /* add this cursor to the cursors managed by the driver state */
00059     db__add_cursor_to_driver_state(cursor);
00060 
00061     /* results */
00062     DB_SEND_TOKEN(&token);
00063     DB_SEND_INT(cursor->type);
00064     DB_SEND_INT(cursor->mode);
00065     return DB_OK;
00066 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines