d_openupdate.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <grass/dbmi.h>
00003 #include "macros.h"
00004 #include "dbstubs.h"
00005 
00012 int
00013 db_d_open_update_cursor()
00014 {
00015     dbCursor *cursor;
00016     int stat;
00017     dbToken token;
00018     dbString select;
00019     dbString table_name;
00020     int mode;
00021 
00022 /* get the arg(s) */
00023     db_init_string (&table_name);
00024     db_init_string (&select);
00025     DB_RECV_STRING(&table_name);
00026     DB_RECV_STRING(&select);
00027     DB_RECV_INT(&mode);
00028 
00029 /* create a cursor */
00030     cursor = (dbCursor *) db_malloc (sizeof(dbCursor));
00031     if (cursor == NULL)
00032         return db_get_error_code();
00033     token = db_new_token ( (dbAddress) cursor);
00034     if (token < 0)
00035         return db_get_error_code();
00036     db_init_cursor(cursor);
00037 
00038 /* call the procedure */
00039     stat = db_driver_open_update_cursor (&table_name, &select, cursor, mode);
00040     db_free_string (&table_name);
00041     db_free_string (&select);
00042 
00043 /* send the return code */
00044     if (stat != DB_OK)
00045     {
00046         DB_SEND_FAILURE();
00047         return DB_OK;
00048     }
00049     DB_SEND_SUCCESS();
00050 
00051 /* mark this as an update cursor */
00052     db_set_cursor_type_update (cursor);
00053 
00054 /* add this cursor to the cursors managed by the driver state */
00055     db__add_cursor_to_driver_state(cursor);
00056 
00057 /* results */
00058     DB_SEND_TOKEN (&token);
00059     DB_SEND_INT (cursor->type);
00060     DB_SEND_INT (cursor->mode);
00061     DB_SEND_TABLE_DEFINITION (cursor->table);
00062     return DB_OK;
00063 }

Generated on Sun Apr 6 17:31:38 2008 for GRASS by  doxygen 1.5.5