Class: OracleDB::Var
- Inherits:
-
Object
- Object
- OracleDB::Var
- Defined in:
- lib/oracledb.rb,
ext/oracledb/rboradb_var.c
Instance Method Summary collapse
- #copy_data(pos, source_var, source_pos) ⇒ Object
- #get(index) ⇒ Object
-
#initialize(conn, info = nil, array_size:, oracle_type: nil, native_type: nil, size: nil, size_is_bytes: nil, is_array: nil, object_type: nil, out_filter: nil, in_filter: nil) ⇒ Var
constructor
A new instance of Var.
- #num_elements_in_array ⇒ Object
- #num_elements_in_array=(obj) ⇒ Object
- #returned_data(pos) ⇒ Object
- #set(index, obj) ⇒ Object
- #size_in_bytes ⇒ Object
Constructor Details
#initialize(conn, info = nil, array_size:, oracle_type: nil, native_type: nil, size: nil, size_is_bytes: nil, is_array: nil, object_type: nil, out_filter: nil, in_filter: nil) ⇒ Var
Returns a new instance of Var.
150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/oracledb.rb', line 150 def initialize(conn, info = nil, array_size:, oracle_type: nil, native_type: nil, size: nil, size_is_bytes: nil, is_array: nil, object_type: nil, out_filter: nil, in_filter: nil) info = info.type_info if info.respond_to? :type_info if info oracle_type = info.oracle_type if oracle_type.nil? native_type = oracle_type != :number ? info.default_native_type : :bytes if native_type.nil? size = info.client_size_in_bytes if size.nil? size_is_bytes = true if size_is_bytes.nil? is_array = false if is_array.nil? object_type = info.object_type if object_type.nil? end __initialize(conn, oracle_type, native_type, array_size, size, size_is_bytes, is_array, object_type, out_filter, in_filter) end |
Instance Method Details
#copy_data(pos, source_var, source_pos) ⇒ Object
160 161 162 163 164 165 166 167 168 |
# File 'ext/oracledb/rboradb_var.c', line 160
static VALUE var_copy_data(VALUE self, VALUE pos, VALUE source_var, VALUE source_pos)
{
Var_t *var = To_Var(self);
if (dpiVar_copyData(var->handle, NUM2UINT(pos), To_Var(source_var)->handle, NUM2UINT(source_pos)) != DPI_SUCCESS) {
rboradb_raise_error(var->dconn->ctxt);
}
return Qnil;
}
|
#get(index) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 |
# File 'ext/oracledb/rboradb_var.c', line 106
static VALUE var_get(VALUE self, VALUE index)
{
Var_t *var = To_Var(self);
uint32_t idx = NUM2UINT(index);
if (idx >= var->array_size) {
rb_raise(rb_eArgError, "wrong row index (given %u, expected between 0 and %u)",
idx, var->array_size - 1);
}
return rboradb_from_data(var->data + idx, var->native_type_num, var->oracle_type_num, var->objtype, var->out_filter, var->dconn);
}
|
#num_elements_in_array ⇒ Object
170 171 172 173 |
# File 'ext/oracledb/rboradb_var.c', line 170
static VALUE var_num_elements_in_array(VALUE self)
{
GET_UINT32(Var, NumElementsInArray);
}
|
#num_elements_in_array=(obj) ⇒ Object
175 176 177 178 |
# File 'ext/oracledb/rboradb_var.c', line 175
static VALUE var_set_num_elements_in_array(VALUE self, VALUE obj)
{
SET_UINT32(Var, NumElementsInArray);
}
|
#returned_data(pos) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'ext/oracledb/rboradb_var.c', line 118
static VALUE var_returned_data(VALUE self, VALUE pos)
{
Var_t *var = To_Var(self);
uint32_t idx, num;
dpiData *data;
VALUE ary;
if (dpiVar_getReturnedData(var->handle, NUM2UINT(pos), &num, &data) != DPI_SUCCESS) {
rboradb_raise_error(var->dconn->ctxt);
}
ary = rb_ary_new_capa(num);
for (idx = 0; idx < num; idx++) {
VALUE obj = rboradb_from_data(data + idx, var->native_type_num, var->oracle_type_num, var->objtype, var->out_filter, var->dconn);
rb_ary_push(ary, obj);
}
return ary;
}
|
#set(index, obj) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'ext/oracledb/rboradb_var.c', line 137
static VALUE var_set(VALUE self, VALUE index, VALUE obj)
{
Var_t *var = To_Var(self);
uint32_t pos = NUM2UINT(index);
dpiData *data = var->data + pos;
if (pos >= var->array_size) {
rb_raise(rb_eArgError, "wrong row index (given %u, expected between 0 and %u)",
pos, var->array_size - 1);
}
if (NIL_P(obj)) {
data->isNull = 1;
return Qnil;
}
if (!NIL_P(var->in_filter)) {
obj = rb_proc_call_with_block(var->in_filter, 1, &obj, Qnil);
}
rboradb_set_data(obj, data, var->native_type_num, var->oracle_type_num, var->dconn, var->handle, pos);
return Qnil;
}
|
#size_in_bytes ⇒ Object
180 181 182 183 |
# File 'ext/oracledb/rboradb_var.c', line 180
static VALUE var_size_in_bytes(VALUE self)
{
GET_UINT32(Var, SizeInBytes);
}
|