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



309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'ext/oci8/bind.c', line 309

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



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'ext/oci8/bind.c', line 342

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