Class: OCI8::BindType::Base

Inherits:
OCIHandle show all
Defined in:
lib/oci8/bindtype.rb,
ext/oci8/oci8lib.c,
ext/oci8/ocinumber.c

Direct Known Subclasses

Float, Integer, OraNumber

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(con, val, param, max_array_size) ⇒ Object



13
14
15
# File 'lib/oci8/bindtype.rb', line 13

def self.create(con, val, param, max_array_size)
  self.new(con, val, param, max_array_size)
end

Instance Method Details

#getObject



195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'ext/oci8/bind.c', line 195

static VALUE oci8_bind_get(VALUE self)
{
    oci8_bind_t *obind = DATA_PTR(self);
    const oci8_bind_vtable_t *vptr = (const oci8_bind_vtable_t *)obind->base.vptr;
    ub4 idx = obind->curar_idx;
    void **null_structp = NULL;

    if (NIL_P(obind->tdo)) {
        if (obind->u.inds[idx] != 0)
            return Qnil;
    }
    return vptr->get(obind, (void*)((size_t)obind->valuep + obind->alloc_sz * idx), null_structp);
}

#set(val) ⇒ Object



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'ext/oci8/bind.c', line 228

static VALUE oci8_bind_set(VALUE self, VALUE val)
{
    oci8_bind_t *obind = DATA_PTR(self);
    const oci8_bind_vtable_t *vptr = (const oci8_bind_vtable_t *)obind->base.vptr;
    ub4 idx = obind->curar_idx;

    if (NIL_P(val)) {
        if (NIL_P(obind->tdo)) {
            obind->u.inds[idx] = -1;
        } else {
            *(OCIInd*)obind->u.null_structs[idx] = -1;
        }
    } else {
        void **null_structp = NULL;

        if (NIL_P(obind->tdo)) {
            null_structp = NULL;
            obind->u.inds[idx] = 0;
        } else {
            null_structp = &obind->u.null_structs[idx];
            *(OCIInd*)obind->u.null_structs[idx] = 0;
        }
        vptr->set(obind, (void*)((size_t)obind->valuep + obind->alloc_sz * idx), null_structp, val);
    }
    return self;
}