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:



764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
# File 'ext/oci8/lob.c', line 764

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:



799
800
801
802
803
804
805
# File 'ext/oci8/lob.c', line 799

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:



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

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)


863
864
865
866
867
868
869
870
871
872
# File 'ext/oci8/lob.c', line 863

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:



812
813
814
815
816
817
818
# File 'ext/oci8/lob.c', line 812

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:



847
848
849
850
851
852
853
854
855
856
# File 'ext/oci8/lob.c', line 847

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



907
908
909
910
# File 'ext/oci8/lob.c', line 907

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



188
189
190
191
# File 'ext/oci8/lob.c', line 188

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



188
189
190
191
# File 'ext/oci8/lob.c', line 188

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