Class: OCI8::BindType::Base

Inherits:
8_cOCIHandle
  • Object
show all
Defined in:
lib/oci8/bindtype.rb,
ext/oci8/oci8lib.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

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



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

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

Instance Method Details

#getObject



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'ext/oci8/bind.c', line 296

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

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

#set(val) ⇒ Object



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'ext/oci8/bind.c', line 333

static VALUE oci8_bind_set(VALUE self, VALUE val)
{
    oci8_bind_t *obind = DATA_PTR(self);
    const oci8_bind_class_t *obc = (const oci8_bind_class_t *)obind->base.klass;
    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];
        }
        obc->set(obind, (void*)((size_t)obind->valuep + obind->alloc_sz * idx), null_structp, val);
    }
    return self;
}