GRASS Programmer's Manual  6.4.2(2012)
c_openselect.c
Go to the documentation of this file.
00001 
00015 #include <grass/dbmi.h>
00016 #include "macros.h"
00017 
00029 int db_open_select_cursor(dbDriver * driver, dbString * select, dbCursor * cursor,
00030                           int mode)
00031 {
00032     int ret_code;
00033 
00034     db_init_cursor(cursor);
00035     cursor->driver = driver;
00036 
00037     /* start the procedure call */
00038     db__set_protocol_fds(driver->send, driver->recv);
00039     DB_START_PROCEDURE_CALL(DB_PROC_OPEN_SELECT_CURSOR);
00040 
00041     /* send the argument(s) to the procedure */
00042     DB_SEND_STRING(select);
00043     DB_SEND_INT(mode);
00044 
00045     /* get the return code for the procedure call */
00046     DB_RECV_RETURN_CODE(&ret_code);
00047 
00048     if (ret_code != DB_OK)
00049         return ret_code;        /* ret_code SHOULD == DB_FAILED */
00050 
00051     /* get the results */
00052     DB_RECV_TOKEN(&cursor->token);
00053     DB_RECV_INT(&cursor->type);
00054     DB_RECV_INT(&cursor->mode);
00055     DB_RECV_TABLE_DEFINITION(&cursor->table);
00056     return DB_OK;
00057 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines