Class: Informix::CursorBase

Inherits:
Object
  • Object
show all
Defined in:
ext/informixc.c

Direct Known Subclasses

InsertCursor, SequentialCursor

Instance Method Summary collapse

Instance Method Details

#closeObject

cursor.close => cursor

Closes the cursor and returns __self__.



4073
4074
4075
4076
4077
4078
4079
4080
4081
# File 'ext/informixc.c', line 4073

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;
}

#freeObject

cursor.free => nil

Closes the cursor and frees the memory associated with it. The cursor cannot be opened again.



4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
# File 'ext/informixc.c', line 4090

static VALUE
rb_cursorbase_free(VALUE self)
{
	cursor_t *c;

	Data_Get_Struct(self, cursor_t, c);
	cursorbase_close_or_free(c, 2);

	return Qnil;
}

#idObject

cursor.id => string

Returns the cursor ID



3963
3964
3965
3966
3967
3968
3969
3970
# File 'ext/informixc.c', line 3963

static VALUE
rb_cursorbase_id(VALUE self)
{
	cursor_t *c;

	Data_Get_Struct(self, cursor_t, c);
	return rb_str_new2(c->cursor_id);
}

#open(*args) ⇒ Object

cursor.open(*params) => cursor

Executes the previously prepared select statement, binding params as input parameters.

Returns __self__.



3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
# File 'ext/informixc.c', line 3981

static VALUE
rb_cursorbase_open(int argc, VALUE *argv, VALUE self)
{
	struct sqlda *input;
	cursor_t *c;
/*
 * 	EXEC SQL begin declare section;
 */
#line 3000 "informixc.ec"
#line 3001 "informixc.ec"
  char *cid, *did;
/*
 * 	EXEC SQL end   declare section;
 */
#line 3002 "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 3010 "informixc.ec"
  {
#line 3010 "informixc.ec"
  sqli_connect_set(0, did, 0);
#line 3010 "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 3024 "informixc.ec"
  {
#line 3025 "informixc.ec"
  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), input, (char *)0, (struct value *)0, 1, 1);
#line 3025 "informixc.ec"
  }
			clean_input_slots(c);
		}
		else
/*
 * 			EXEC SQL open :cid with reoptimization;
 */
#line 3029 "informixc.ec"
  {
#line 3029 "informixc.ec"
  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 1);
#line 3029 "informixc.ec"
  }
	}
	else
/*
 * 		EXEC SQL open :cid;
 */
#line 3032 "informixc.ec"
  {
#line 3032 "informixc.ec"
  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
#line 3032 "informixc.ec"
  }

	if (SQLCODE < 0)
		raise_ifx_extended();

	c->is_open = 1;
	return self;
}