1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
/*****************************************************************************
*
* MODULE: DBF driver
*
* AUTHOR(S): Radim Blazek
*
* PURPOSE: Simple driver for reading and writing dbf files
*
* COPYRIGHT: (C) 2000 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
*****************************************************************************/
#include <dbmi.h>
#include <shapefil.h>
#include "globals.h"
#include "proto.h"
int
db__driver_open_select_cursor(sel, dbc, mode)
dbString *sel;
dbCursor *dbc;
int mode;
{
int ret;
cursor *c;
char *sql;
dbTable *table;
/* allocate cursor */
c = alloc_cursor();
if (c == NULL)
return DB_FAILED;
db_set_cursor_mode(dbc,mode);
db_set_cursor_type_readonly(dbc);
sql = db_get_string(sel);
ret = execute ( sql, c);
if ( ret == DB_FAILED )
{
append_error("Error in db_open_select_cursor()");
report_error( );
return DB_FAILED;
}
describe_table( c->table, c->cols, c->ncols, &table);
/* record table with dbCursor */
db_set_cursor_table(dbc, table);
/* set dbCursor's token for my cursor */
db_set_cursor_token(dbc, c->token);
return DB_OK;
}
|