Method: OCI8::BindType::Base#set

Defined in:
ext/oci8/bind.c

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