| Class | Informix::CursorBase |
| In: |
ext/informixc.c
|
| Parent: | Object |
The CursorBase class provides the basic functionality for any cursor.
Closes the cursor and returns self.
/*
* call-seq:
* cursor.close => cursor
*
* Closes the cursor and returns __self__.
*/
static VALUE
rb_cursorbase_close(VALUE self)
{
cursor_t *c;
Data_Get_Struct(self, cursor_t, c);
cursorbase_close_or_free(c, 1);
return self;
}
Closes the cursor and frees the memory associated with it. The cursor cannot be opened again.
/*
* call-seq:
* cursor.drop => nil
*
* Closes the cursor and frees the memory associated with it. The cursor
* cannot be opened again.
*/
static VALUE
rb_cursorbase_drop(VALUE self)
{
cursor_t *c;
Data_Get_Struct(self, cursor_t, c);
cursorbase_close_or_free(c, 2);
return Qnil;
}
Returns the cursor ID
/*
* call-seq:
* cursor.id => string
*
* Returns the cursor ID
*/
static VALUE
rb_cursorbase_id(VALUE self)
{
cursor_t *c;
Data_Get_Struct(self, cursor_t, c);
return rb_str_new2(c->cursor_id);
}
Executes the previously prepared select statement, binding params as input parameters.
Returns self.
/*
* call-seq:
* cursor.open(*params) => cursor
*
* Executes the previously prepared select statement, binding <i>params</i> as
* input parameters.
*
* Returns __self__.
*/
static VALUE
rb_cursorbase_open(int argc, VALUE *argv, VALUE self)
{
struct sqlda *input;
cursor_t *c;
/*
* EXEC SQL begin declare section;
*/
#line 3012 "informixc.ec"
#line 3013 "informixc.ec"
char *cid, *did;
/*
* EXEC SQL end declare section;
*/
#line 3014 "informixc.ec"
Data_Get_Struct(self, cursor_t, c);
if (c->is_open)
return self;
did = c->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 3022 "informixc.ec"
{
#line 3022 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 3022 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
input = &c->daInput;
cid = c->cursor_id;
if (c->is_select) {
if (argc != input->sqld) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, input->sqld);
}
if (argc) {
bind_input_params(c, argv);
/*
* EXEC SQL open :cid using descriptor input
* with reoptimization;
*/
#line 3036 "informixc.ec"
{
#line 3037 "informixc.ec"
sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), input, (char *)0, (struct value *)0, 1, 1);
#line 3037 "informixc.ec"
}
clean_input_slots(c);
}
else
/*
* EXEC SQL open :cid with reoptimization;
*/
#line 3041 "informixc.ec"
{
#line 3041 "informixc.ec"
sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 1);
#line 3041 "informixc.ec"
}
}
else
/*
* EXEC SQL open :cid;
*/
#line 3044 "informixc.ec"
{
#line 3044 "informixc.ec"
sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
#line 3044 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
c->is_open = 1;
return self;
}