Class: OCI8::BindType::Base

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OCIHandle

#free, #initialize

Constructor Details

This class inherits a constructor from OCIHandle

Class Method Details

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



167
168
169
# File 'lib/oci8/oci8.rb', line 167

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

Instance Method Details

#getObject



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'ext/oci8/bind.c', line 332

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



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'ext/oci8/bind.c', line 369

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