Class: OCI8::BFILE

Inherits:
LOB show all
Defined in:
ext/oci8/lob.c,
ext/oci8/lob.c

Instance Method Summary collapse

Methods inherited from LOB

#available?, #chunk_size, #close, #eof?, #pos, #read, #rewind, #seek

Constructor Details

#initialize(conn, dir_alias = nil, filename = nil) ⇒ OCI8::BFILE

Creates a BFILE object. This is correspond to BFILENAME.

Parameters:



793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
# File 'ext/oci8/lob.c', line 793

static VALUE oci8_bfile_initialize(int argc, VALUE *argv, VALUE self)
{
    oci8_lob_t *lob = DATA_PTR(self);
    VALUE svc;
    VALUE dir_alias;
    VALUE filename;
    int rv;

    rb_scan_args(argc, argv, "12", &svc, &dir_alias, &filename);
    TO_SVCCTX(svc); /* check argument type */
    rv = OCIDescriptorAlloc(oci8_envhp, &lob->base.hp.ptr, OCI_DTYPE_LOB, 0, NULL);
    if (rv != OCI_SUCCESS) {
        oci8_env_raise(oci8_envhp, rv);
    }
    lob->base.type = OCI_DTYPE_LOB;
    lob->svc = svc;
    lob->pos = 0;
    lob->char_width = 1;
    lob->csfrm = SQLCS_IMPLICIT;
    lob->lobtype = OCI_TEMP_BLOB;
    lob->state = S_BFILE_CLOSE;
    if (argc != 1) {
        OCI8SafeStringValue(dir_alias);
        OCI8SafeStringValue(filename);
        oci8_bfile_set_name(self, dir_alias, filename);
    }
    oci8_link_to_parent((oci8_base_t*)lob, (oci8_base_t*)DATA_PTR(svc));
    return Qnil;
}

Instance Method Details

#dir_aliasString

Returns the directory object name.

Returns:



828
829
830
831
832
833
834
# File 'ext/oci8/lob.c', line 828

static VALUE oci8_bfile_get_dir_alias(VALUE self)
{
    VALUE dir_alias;

    oci8_bfile_get_name(self, &dir_alias, NULL);
    return dir_alias;
}

#dir_alias=(name) ⇒ Object

Changes the directory object name.

Parameters:



857
858
859
860
861
862
863
864
865
866
# File 'ext/oci8/lob.c', line 857

static VALUE oci8_bfile_set_dir_alias(VALUE self, VALUE dir_alias)
{
    VALUE filename;

    OCI8SafeStringValue(dir_alias);
    oci8_bfile_get_name(self, NULL, &filename);
    oci8_bfile_set_name(self, dir_alias, filename);
    rb_ivar_set(self, id_dir_alias, dir_alias);
    return dir_alias;
}

#exists?true or false

Returns true when the BFILE exists on the server’s operating system.

Returns:

  • (true or false)


892
893
894
895
896
897
898
899
900
901
# File 'ext/oci8/lob.c', line 892

static VALUE oci8_bfile_exists_p(VALUE self)
{
    oci8_lob_t *lob = DATA_PTR(self);
    oci8_svcctx_t *svcctx = oci8_get_svcctx(lob->svc);
    boolean flag;

    chker2(OCILobFileExists_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob, &flag),
           &svcctx->base);
    return flag ? Qtrue : Qfalse;
}

#filenameString

Returns the file name.

Returns:



841
842
843
844
845
846
847
# File 'ext/oci8/lob.c', line 841

static VALUE oci8_bfile_get_filename(VALUE self)
{
    VALUE filename;

    oci8_bfile_get_name(self, NULL, &filename);
    return filename;
}

#filename=(name) ⇒ Object

Changes the file name.

Parameters:



876
877
878
879
880
881
882
883
884
885
# File 'ext/oci8/lob.c', line 876

static VALUE oci8_bfile_set_filename(VALUE self, VALUE filename)
{
    VALUE dir_alias;

    OCI8SafeStringValue(filename);
    oci8_bfile_get_name(self, &dir_alias, NULL);
    oci8_bfile_set_name(self, dir_alias, filename);
    rb_ivar_set(self, id_filename, filename);
    return filename;
}

#size( = length) ⇒ Object

#size=(dummy) ⇒ Object

call-seq:

write(data)

Raises RuntimeError.

Raises:

  • (RuntimeError)

    cannot modify a read-only BFILE object



936
937
938
939
# File 'ext/oci8/lob.c', line 936

static VALUE oci8_bfile_error(VALUE self, VALUE dummy)
{
    rb_raise(rb_eRuntimeError, "cannot modify a read-only BFILE object");
}

#truncate(dummy) ⇒ Object

call-seq:

write(data)

Raises RuntimeError.

Raises:

  • (RuntimeError)

    cannot modify a read-only BFILE object



205
206
207
208
# File 'ext/oci8/lob.c', line 205

static VALUE oci8_bfile_error(VALUE self, VALUE dummy)
{
    rb_raise(rb_eRuntimeError, "cannot modify a read-only BFILE object");
}

#write(dummy) ⇒ Object

call-seq:

write(data)

Raises RuntimeError.

Raises:

  • (RuntimeError)

    cannot modify a read-only BFILE object



205
206
207
208
# File 'ext/oci8/lob.c', line 205

static VALUE oci8_bfile_error(VALUE self, VALUE dummy)
{
    rb_raise(rb_eRuntimeError, "cannot modify a read-only BFILE object");
}