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:



805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
# File 'ext/oci8/lob.c', line 805

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;
    oci8_svcctx_t *svcctx;
    int rv;

    rb_scan_args(argc, argv, "12", &svc, &dir_alias, &filename);
    svcctx = oci8_get_svcctx(svc);
    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->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));
    lob->svcctx = svcctx;
    return Qnil;
}

Instance Method Details

#dir_aliasString

Returns the directory object name.

Returns:



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

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:



870
871
872
873
874
875
876
877
878
879
# File 'ext/oci8/lob.c', line 870

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)


905
906
907
908
909
910
911
912
913
914
# File 'ext/oci8/lob.c', line 905

static VALUE oci8_bfile_exists_p(VALUE self)
{
    oci8_lob_t *lob = DATA_PTR(self);
    oci8_svcctx_t *svcctx = check_svcctx(lob);
    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:



854
855
856
857
858
859
860
# File 'ext/oci8/lob.c', line 854

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:



889
890
891
892
893
894
895
896
897
898
# File 'ext/oci8/lob.c', line 889

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



949
950
951
952
# File 'ext/oci8/lob.c', line 949

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



219
220
221
222
# File 'ext/oci8/lob.c', line 219

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



219
220
221
222
# File 'ext/oci8/lob.c', line 219

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