GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
d_fetch.c
Go to the documentation of this file.
1
15
#include <grass/dbmi.h>
16
#include "
macros.h
"
17
#include "
dbstubs.h
"
18
19
20
static
int
valid_cursor(dbCursor * cursor,
int
position);
21
28
int
db_d_fetch
(
void
)
29
{
30
dbToken token;
31
dbCursor *cursor;
32
int
stat;
33
int
more;
34
int
position;
35
36
/* get the arg(s) */
37
DB_RECV_TOKEN
(&token);
38
DB_RECV_INT
(&position);
39
cursor = (dbCursor *)
db_find_token
(token);
40
if
(!valid_cursor(cursor, position)) {
41
DB_SEND_FAILURE
();
42
return
DB_FAILED;
43
}
44
45
/* call the procedure */
46
stat =
db_driver_fetch
(cursor, position, &more);
47
48
/* send the return code */
49
if
(stat != DB_OK) {
50
DB_SEND_FAILURE
();
51
return
DB_OK;
52
}
53
DB_SEND_SUCCESS
();
54
55
/* results */
56
DB_SEND_INT
(more);
57
if
(more) {
58
DB_SEND_TABLE_DATA
(cursor->table);
59
}
60
61
return
DB_OK;
62
}
63
64
65
static
int
valid_cursor(dbCursor * cursor,
int
position)
66
{
67
if
(cursor ==
NULL
)
68
return
0;
69
70
if
(!
db_test_cursor_type_fetch
(cursor)) {
71
db_error
(
"not a fetchable cursor"
);
72
return
0;
73
}
74
75
if
(position != DB_NEXT && !
db_test_cursor_mode_scroll
(cursor)) {
76
db_error
(
"not a scrollable cursor"
);
77
return
0;
78
}
79
80
return
1;
81
}
lib
db
dbmi_driver
d_fetch.c
Generated on Wed Jun 6 2012 14:04:20 for GRASS Programmer's Manual by
1.8.1