Class: OCI8::BindType::Base

Inherits:
OCIHandle show all
Defined in:
lib/oci8/bindtype.rb,
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



622
623
624
625
626
627
628
629
630
631
632
633
634
# File 'ext/oci8/bind.c', line 622

static VALUE oci8_bind_get(VALUE self)
{
    oci8_bind_t *obind = TO_BIND(self);
    const oci8_bind_data_type_t *data_type = (const oci8_bind_data_type_t *)obind->base.data_type;
    ub4 idx = obind->curar_idx;
    void **null_structp = NULL;

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

#set(val) ⇒ Object



664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
# File 'ext/oci8/bind.c', line 664

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