Class: Informix::Slob
- Inherits:
-
Object
- Object
- Informix::Slob
- Defined in:
- lib/informix.rb,
ext/informixc.c
Overview
class Statement
Defined Under Namespace
Classes: Stat
Constant Summary collapse
- CLOB =
INT2FIX(XID_CLOB)
- BLOB =
INT2FIX(XID_BLOB)
- RDONLY =
Access modes
INT2FIX(LO_RDONLY)
- DIRTY_READ =
INT2FIX(LO_DIRTY_READ)
- WRONLY =
INT2FIX(LO_WRONLY)
- APPEND =
INT2FIX(LO_APPEND)
- RDWR =
INT2FIX(LO_RDWR)
- BUFFER =
INT2FIX(LO_BUFFER)
- NOBUFFER =
INT2FIX(LO_NOBUFFER)
- LOCKALL =
INT2FIX(LO_LOCKALL)
- LOCKRANGE =
INT2FIX(LO_LOCKRANGE)
- SEEK_SET =
INT2FIX(LO_SEEK_SET)
- SEEK_CUR =
INT2FIX(LO_SEEK_CUR)
- SEEK_END =
INT2FIX(LO_SEEK_END)
- LOG =
Creation-time flags
INT2FIX(LO_LOG)
- NOLOG =
INT2FIX(LO_NOLOG)
- KEEP_LASTACCESS_TIME =
INT2FIX(LO_KEEP_LASTACCESS_TIME)
- NOKEEP_LASTACCESS_TIME =
INT2FIX(LO_NOKEEP_LASTACCESS_TIME)
- CURRENT_END =
Ranges
INT2FIX(LO_CURRENT_END)
- MAX_END =
INT2FIX(LO_MAX_END)
- SHARED_MODE =
Lock modes
INT2FIX(LO_SHARED_MODE)
- EXCLUSIVE_MODE =
INT2FIX(LO_EXCLUSIVE_MODE)
Class Method Summary collapse
- ._new ⇒ Object
-
.new(dbname, query, options = nil) ⇒ Object
Creates a
Slob
object.
Instance Method Summary collapse
-
#<<(data) ⇒ Object
slob << data => slob.
-
#atime ⇒ Object
slob.atime => time.
-
#close ⇒ Object
slob.close => slob.
-
#ctime ⇒ Object
stat.ctime => time.
-
#estbytes ⇒ Object
slob.estbytes => fixnum or bignum.
-
#extsz ⇒ Object
slob.extsz => fixnum.
-
#extsz=(value) ⇒ Object
slob.extsz = fixnum => fixnum.
-
#flags ⇒ Object
slob.flags => fixnum.
-
#flags=(value) ⇒ Object
slob.flags = fixnum => fixnum.
-
#initialize(*args) ⇒ Object
constructor
:nodoc:.
-
#lock(offset, whence, range, mode) ⇒ Object
slob.lock(offset, whence, range, mode) => slob.
-
#maxbytes ⇒ Object
slob.maxbytes => fixnum or bignum.
-
#mtime ⇒ Object
stat.mtime => time.
-
#open(*args) ⇒ Object
slob.open(access = Slob::RDONLY) => slob.
-
#pos=(pos) ⇒ Object
slob.pos = integer => integer.
-
#read(nbytes) ⇒ Object
slob.read(nbytes) => string.
-
#refcnt ⇒ Object
stat.refcnt => fixnum.
-
#rewind ⇒ Object
slob.rewind => fixnum.
-
#sbspace ⇒ Object
slob.sbspace => string.
-
#seek(offset, whence) ⇒ Object
slob.seek(offset, whence) => fixnum or bignum.
-
#size ⇒ Object
stat.size => fixnum or bignum.
-
#stat ⇒ Object
slob.stat => stat.
-
#tell ⇒ Object
(also: #pos)
slob.tell => integer slob.pos => integer.
-
#truncate(offset) ⇒ Object
slob.truncate(offset) => slob.
-
#unlock(offset, whence, range) ⇒ Object
slob.unlock(offset, whence, range) => slob.
-
#write(data) ⇒ Object
slob.write(data) => fixnum or bignum.
Constructor Details
#initialize(*args) ⇒ Object
:nodoc:
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
# File 'ext/informixc.c', line 557 static VALUE rb_slob_initialize(int argc, VALUE *argv, VALUE self) { mint ret, error; slob_t *slob; VALUE db, type, ; VALUE col_info, sbspace, estbytes, extsz, createflags, openflags, maxbytes; /* * EXEC SQL begin declare section; */ #line 478 "informixc.ec" #line 479 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 480 "informixc.ec" rb_scan_args(argc, argv, "12", &db, &type, &); Data_Get_Struct(db, char, did); /* * EXEC SQL set connection :did; */ #line 485 "informixc.ec" { #line 485 "informixc.ec" sqli_connect_set(0, did, 0); #line 485 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); Data_Get_Struct(self, slob_t, slob); slob->db = db; slob->database_id = did; if (!NIL_P(type)) { int t = FIX2INT(type); if (t != XID_CLOB && t != XID_BLOB) rb_raise(rb_eInternalError, "Invalid type %d for an SLOB", t); slob->type = t; } col_info = sbspace = estbytes = extsz = createflags = openflags = maxbytes = Qnil; if (!NIL_P()) { Check_Type(, T_HASH); col_info = rb_hash_aref(, sym_col_info); sbspace = rb_hash_aref(, sym_sbspace); estbytes = rb_hash_aref(, sym_estbytes); extsz = rb_hash_aref(, sym_extsz); createflags = rb_hash_aref(, sym_createflags); openflags = rb_hash_aref(, sym_openflags); maxbytes = rb_hash_aref(, sym_maxbytes); } ret = ifx_lo_def_create_spec(&slob->spec); if (ret < 0) raise_ifx_extended(); if (!NIL_P(col_info)) { ret = ifx_lo_col_info(StringValueCStr(col_info), slob->spec); if (ret < 0) raise_ifx_extended(); } if (!NIL_P(sbspace)) { char *c_sbspace = StringValueCStr(sbspace); ret = ifx_lo_specset_sbspace(slob->spec, c_sbspace); if (ret == -1) rb_raise(rb_eOperationalError, "Could not set sbspace name to %s", c_sbspace); } if (!NIL_P(estbytes)) { ifx_int8_t estbytes8; NUM2INT8(estbytes, &estbytes8); ret = ifx_lo_specset_estbytes(slob->spec, &estbytes8); if (ret == -1) rb_raise(rb_eOperationalError, "Could not set estbytes"); } if (!NIL_P(extsz)) { ret = ifx_lo_specset_extsz(slob->spec, FIX2LONG(extsz)); if (ret == -1) rb_raise(rb_eOperationalError, "Could not set extsz to %ld", FIX2LONG(extsz)); } if (!NIL_P(createflags)) { ret = ifx_lo_specset_flags(slob->spec, FIX2LONG(createflags)); if (ret == -1) rb_raise(rb_eOperationalError, "Could not set crate-time flags to 0x%X", FIX2LONG(createflags)); } if (!NIL_P(maxbytes)) { ifx_int8_t maxbytes8; NUM2INT8(maxbytes, (&maxbytes8)); ret = ifx_lo_specset_maxbytes(slob->spec, &maxbytes8); if (ret == -1) rb_raise(rb_eOperationalError, "Could not set maxbytes"); } slob->fd = ifx_lo_create(slob->spec, RTEST(openflags)? FIX2LONG(openflags): LO_RDWR, &slob->lo, &error); if (slob->fd == -1) raise_ifx_extended(); return self; } |
Class Method Details
._new ⇒ Object
292 |
# File 'lib/informix.rb', line 292 alias _new new |
.new(dbname, query, options = nil) ⇒ Object
Creates a Slob
object.
The Slob
object is passed to the block if it’s given, and automatically closes it when the block terminates, returning the value of the block.
type
can be Slob::BLOB or Slob::CLOB
options
can be a Hash object with the following possible keys:
:sbspace => Sbspace name
:estbytes => Estimated size, in bytes
:extsz => Allocation extent size
:createflags => Create-time flags
:openflags => Access mode
:maxbytes => Maximum size
:col_info => Get the previous values from the column-level storage
characteristics for the specified database column
314 315 316 317 318 319 320 321 322 |
# File 'lib/informix.rb', line 314 def self.new(dbname, query, = nil) slob = _new(dbname, query, ) return slob if !block_given? begin yield slob ensure slob.close end end |
Instance Method Details
#<<(data) ⇒ Object
slob << data => slob
Writes data to the Smart Large Object. If data is not a String object it will be converted to String using to_s
.
Returns self.
906 907 908 909 910 911 |
# File 'ext/informixc.c', line 906 static VALUE rb_slob_addstr(VALUE self, VALUE data) { rb_slob_write(self, data); return self; } |
#atime ⇒ Object
slob.atime => time
Returns the time of last access as a Time object.
1582 1583 1584 1585 1586 |
# File 'ext/informixc.c', line 1582 static VALUE rb_slob_atime(VALUE self) { return slob_stat(self, slob_atime); } |
#close ⇒ Object
slob.close => slob
Closes the Smart Large Object and returns __self__.
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
# File 'ext/informixc.c', line 737 static VALUE rb_slob_close(VALUE self) { slob_t *slob; Data_Get_Struct(self, slob_t, slob); if (slob->fd != -1) { /* * EXEC SQL begin declare section; */ #line 626 "informixc.ec" #line 627 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 628 "informixc.ec" did = slob->database_id; /* * EXEC SQL set connection :did; */ #line 631 "informixc.ec" { #line 631 "informixc.ec" sqli_connect_set(0, did, 0); #line 631 "informixc.ec" } if (SQLCODE < 0) return self; ifx_lo_close(slob->fd); slob->fd = -1; } return self; } |
#ctime ⇒ Object
stat.ctime => time
Returns the time of last change in status as a Time object.
1594 1595 1596 1597 1598 |
# File 'ext/informixc.c', line 1594 static VALUE rb_slob_ctime(VALUE self) { return slob_stat(self, slob_ctime); } |
#estbytes ⇒ Object
slob.estbytes => fixnum or bignum
Returns the estimated size of the SLOB
1409 1410 1411 1412 1413 |
# File 'ext/informixc.c', line 1409 static VALUE rb_slob_estbytes(VALUE self) { return slob_specget(self, slob_estbytes); } |
#extsz ⇒ Object
slob.extsz => fixnum
Returns the allocation extent size of the SLOB
1421 1422 1423 1424 1425 |
# File 'ext/informixc.c', line 1421 static VALUE rb_slob_extsz(VALUE self) { return slob_specget(self, slob_extsz); } |
#extsz=(value) ⇒ Object
slob.extsz = fixnum => fixnum
Sets the allocation extent size for the SLOB
1469 1470 1471 1472 1473 |
# File 'ext/informixc.c', line 1469 static VALUE rb_slob_set_extsz(VALUE self, VALUE value) { return slob_specset(self, slob_extsz, value); } |
#flags ⇒ Object
slob.flags => fixnum
Returns the create-time flags of the SLOB
1433 1434 1435 1436 1437 |
# File 'ext/informixc.c', line 1433 static VALUE rb_slob_flags(VALUE self) { return slob_specget(self, slob_flags); } |
#flags=(value) ⇒ Object
slob.flags = fixnum => fixnum
Sets the create-time flags of the SLOB
1481 1482 1483 1484 1485 |
# File 'ext/informixc.c', line 1481 static VALUE rb_slob_set_flags(VALUE self, VALUE value) { return slob_specset(self, slob_flags, value); } |
#lock(offset, whence, range, mode) ⇒ Object
slob.lock(offset, whence, range, mode) => slob
Locks range number of bytes, starting from offset bytes from whence, in mode mode.
Returns self.
Possible values:
offset => integer
whence => Slob::SEEK_SET, Slob::SEEK_CUR, Slob::SEEK_END
range => integer, Slob::CURRENT_END, Slob::MAX_END
mode => Slob::SHARED_MODE, Slob::EXCLUSIVE_MODE
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 |
# File 'ext/informixc.c', line 1136 static VALUE rb_slob_lock(VALUE self, VALUE offset, VALUE whence, VALUE range, VALUE mode) { slob_t *slob; mint ret; ifx_int8_t offset8, range8; /* * EXEC SQL begin declare section; */ #line 928 "informixc.ec" #line 929 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 930 "informixc.ec" Data_Get_Struct(self, slob_t, slob); if (slob->fd == -1) rb_raise(rb_eProgrammingError, "Open the Slob object first"); did = slob->database_id; /* * EXEC SQL set connection :did; */ #line 938 "informixc.ec" { #line 938 "informixc.ec" sqli_connect_set(0, did, 0); #line 938 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); NUM2INT8(offset, &offset8); NUM2INT8(range, &range8); ret = ifx_lo_lock(slob->fd, &offset8, FIX2INT(whence), &range8, FIX2INT(mode)); if (ret < 0) raise_ifx_extended(); return self; } |
#maxbytes ⇒ Object
slob.maxbytes => fixnum or bignum
Returns the maximum size of the SLOB
1445 1446 1447 1448 1449 |
# File 'ext/informixc.c', line 1445 static VALUE rb_slob_maxbytes(VALUE self) { return slob_specget(self, slob_maxbytes); } |
#mtime ⇒ Object
stat.mtime => time
Returns the time of last modification as a Time object.
1606 1607 1608 1609 1610 |
# File 'ext/informixc.c', line 1606 static VALUE rb_slob_mtime(VALUE self) { return slob_stat(self, slob_mtime); } |
#open(*args) ⇒ Object
slob.open(access = Slob::RDONLY) => slob
Opens the Smart Large Object in access mode.
Access modes:
Slob::RDONLY:: Read only Slob::DIRTY_READ:: Read uncommitted data Slob::WRONLY:: Write only Slob::APPEND:: Append data to the end, if combined with RDWR or WRONLY; read only otherwise Slob::RDWR:: Read/Write Slob::BUFFER:: Use standard database server buffer pool Slob::NOBUFFER:: Use private buffer from the session pool of the database server Slob::LOCKALL:: Lock the entire Smart Large Object Slob::LOCKRANGE:: Lock a range of bytes
Returns __self__.
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 |
# File 'ext/informixc.c', line 685 static VALUE rb_slob_open(int argc, VALUE *argv, VALUE self) { VALUE access; slob_t *slob; mint error; /* * EXEC SQL begin declare section; */ #line 589 "informixc.ec" #line 590 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 591 "informixc.ec" Data_Get_Struct(self, slob_t, slob); if (slob->fd != -1) /* Already open */ return self; did = slob->database_id; /* * EXEC SQL set connection :did; */ #line 599 "informixc.ec" { #line 599 "informixc.ec" sqli_connect_set(0, did, 0); #line 599 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); rb_scan_args(argc, argv, "01", &access); slob->fd = ifx_lo_open(&slob->lo, NIL_P(access)? LO_RDONLY: FIX2INT(access), &error); if (slob->fd == -1) raise_ifx_extended(); return self; } |
#pos=(pos) ⇒ Object
slob.pos = integer => integer
Seeks to the given position (in bytes) in slob.
985 986 987 988 989 |
# File 'ext/informixc.c', line 985 static VALUE rb_slob_set_pos(VALUE self, VALUE pos) { return rb_slob_seek(self, pos, LO_SEEK_SET); } |
#read(nbytes) ⇒ Object
slob.read(nbytes) => string
Reads at most nbytes bytes from the Smart Large Object.
Returns the bytes read as a String object.
784 785 786 787 788 789 790 791 792 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 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 |
# File 'ext/informixc.c', line 784 static VALUE rb_slob_read(VALUE self, VALUE nbytes) { slob_t *slob; mint error, ret; char *buffer; long c_nbytes; VALUE str; /* * EXEC SQL begin declare section; */ #line 658 "informixc.ec" #line 659 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 660 "informixc.ec" Data_Get_Struct(self, slob_t, slob); if (slob->fd == -1) rb_raise(rb_eProgrammingError, "Open the Slob object before reading"); did = slob->database_id; /* * EXEC SQL set connection :did; */ #line 669 "informixc.ec" { #line 669 "informixc.ec" sqli_connect_set(0, did, 0); #line 669 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); c_nbytes = FIX2LONG(nbytes); buffer = ALLOC_N(char, c_nbytes); ret = ifx_lo_read(slob->fd, buffer, c_nbytes, &error); if (ret == -1) { xfree(buffer); raise_ifx_extended(); } str = rb_str_new(buffer, ret); xfree(buffer); return str; } |
#refcnt ⇒ Object
stat.refcnt => fixnum
Returns the number of references
1618 1619 1620 1621 1622 |
# File 'ext/informixc.c', line 1618 static VALUE rb_slob_refcnt(VALUE self) { return slob_stat(self, slob_refcnt); } |
#rewind ⇒ Object
slob.rewind => fixnum
Moves the cursor position to the start of the Smart Large Object.
997 998 999 1000 1001 |
# File 'ext/informixc.c', line 997 static VALUE rb_slob_rewind(VALUE self) { return rb_slob_seek(self, INT2FIX(0), LO_SEEK_SET); } |
#sbspace ⇒ Object
slob.sbspace => string
Returns the name of the sbspace where the SLOB is stored
1457 1458 1459 1460 1461 |
# File 'ext/informixc.c', line 1457 static VALUE rb_slob_sbspace(VALUE self) { return slob_specget(self, slob_sbspace); } |
#seek(offset, whence) ⇒ Object
slob.seek(offset, whence) => fixnum or bignum
Sets the file position for the next read or write operation on the open Smart Large Object.
offset offset from the starting seek position whence identifies the starting seek position
Values for whence:
Slob::SEEK_SET:: The start of the Smart Large Object Slob::SEEK_CUR:: The current seek position in the Smart Large Object Slob::SEEK_END:: The end of the Smart Large Object
Returns the new position.
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 |
# File 'ext/informixc.c', line 932 static VALUE rb_slob_seek(VALUE self, VALUE offset, VALUE whence) { slob_t *slob; mint ret; VALUE seek_pos; ifx_int8_t offset8, seek_pos8; /* * EXEC SQL begin declare section; */ #line 773 "informixc.ec" #line 774 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 775 "informixc.ec" Data_Get_Struct(self, slob_t, slob); if (slob->fd == -1) rb_raise(rb_eProgrammingError, "Open the Slob object first"); did = slob->database_id; /* * EXEC SQL set connection :did; */ #line 783 "informixc.ec" { #line 783 "informixc.ec" sqli_connect_set(0, did, 0); #line 783 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); NUM2INT8(offset, &offset8); ret = ifx_lo_seek(slob->fd, &offset8, FIX2INT(whence), &seek_pos8); if (ret < 0) raise_ifx_extended(); INT82NUM(&seek_pos8, seek_pos); return seek_pos; } |
#size ⇒ Object
stat.size => fixnum or bignum
Returns the size in bytes
1630 1631 1632 1633 1634 |
# File 'ext/informixc.c', line 1630 static VALUE rb_slob_size(VALUE self) { return slob_stat(self, slob_size); } |
#stat ⇒ Object
slob.stat => stat
Creates and returns an Slob::Stat object with status information for slob.
1114 1115 1116 1117 1118 |
# File 'ext/informixc.c', line 1114 static VALUE rb_slob_stat(VALUE self) { return rb_class_new_instance(1, &self, rb_cSlobStat); } |
#tell ⇒ Object Also known as: pos
slob.tell => integer slob.pos => integer
Returns the current file or seek position for an open Smart Large Object
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 |
# File 'ext/informixc.c', line 1010 static VALUE rb_slob_tell(VALUE self) { slob_t *slob; mint ret; VALUE seek_pos; ifx_int8_t seek_pos8; /* * EXEC SQL begin declare section; */ #line 835 "informixc.ec" #line 836 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 837 "informixc.ec" Data_Get_Struct(self, slob_t, slob); if (slob->fd == -1) rb_raise(rb_eProgrammingError, "Open the Slob object first"); did = slob->database_id; /* * EXEC SQL set connection :did; */ #line 845 "informixc.ec" { #line 845 "informixc.ec" sqli_connect_set(0, did, 0); #line 845 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); ret = ifx_lo_tell(slob->fd, &seek_pos8); if (ret < 0) raise_ifx_extended(); INT82NUM(&seek_pos8, seek_pos); return seek_pos; } |
#truncate(offset) ⇒ Object
slob.truncate(offset) => slob
Truncates a Smart Large Object at a specified byte position.
Returns __self__.
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
# File 'ext/informixc.c', line 1064 static VALUE rb_slob_truncate(VALUE self, VALUE offset) { slob_t *slob; mint ret; ifx_int8_t offset8; /* * EXEC SQL begin declare section; */ #line 872 "informixc.ec" #line 873 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 874 "informixc.ec" Data_Get_Struct(self, slob_t, slob); if (slob->fd == -1) rb_raise(rb_eProgrammingError, "Open the Slob object first"); did = slob->database_id; /* * EXEC SQL set connection :did; */ #line 882 "informixc.ec" { #line 882 "informixc.ec" sqli_connect_set(0, did, 0); #line 882 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); NUM2INT8(offset, &offset8); ret = ifx_lo_truncate(slob->fd, &offset8); if (ret < 0) raise_ifx_extended(); return self; } |
#unlock(offset, whence, range) ⇒ Object
slob.unlock(offset, whence, range) => slob
Unlocks range number of bytes, starting from offset bytes from whence.
Returns self.
Possible values:
offset => integer
whence => Slob::SEEK_SET, Slob::SEEK_CUR, Slob::SEEK_END
range => integer
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 |
# File 'ext/informixc.c', line 1196 static VALUE rb_slob_unlock(VALUE self, VALUE offset, VALUE whence, VALUE range) { slob_t *slob; mint ret; ifx_int8_t offset8, range8; /* * EXEC SQL begin declare section; */ #line 972 "informixc.ec" #line 973 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 974 "informixc.ec" Data_Get_Struct(self, slob_t, slob); if (slob->fd == -1) rb_raise(rb_eProgrammingError, "Open the Slob object first"); did = slob->database_id; /* * EXEC SQL set connection :did; */ #line 982 "informixc.ec" { #line 982 "informixc.ec" sqli_connect_set(0, did, 0); #line 982 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); NUM2INT8(offset, &offset8); NUM2INT8(range, &range8); ret = ifx_lo_unlock(slob->fd, &offset8, FIX2INT(whence), &range8); if (ret < 0) raise_ifx_extended(); return self; } |
#write(data) ⇒ Object
slob.write(data) => fixnum or bignum
Writes data to the Smart Large Object. If data is not a String object it will be converted to String using to_s
.
Returns the number of bytes written.
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 |
# File 'ext/informixc.c', line 847 static VALUE rb_slob_write(VALUE self, VALUE data) { slob_t *slob; mint error, ret; char *buffer; long nbytes; VALUE str; /* * EXEC SQL begin declare section; */ #line 705 "informixc.ec" #line 706 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 707 "informixc.ec" Data_Get_Struct(self, slob_t, slob); if (slob->fd == -1) rb_raise(rb_eProgrammingError, "Open the Slob object before writing"); did = slob->database_id; /* * EXEC SQL set connection :did; */ #line 715 "informixc.ec" { #line 715 "informixc.ec" sqli_connect_set(0, did, 0); #line 715 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); str = rb_obj_as_string(data); buffer = RSTRING_PTR(str); nbytes = RSTRING_LEN(str); ret = ifx_lo_write(slob->fd, buffer, nbytes, &error); if (ret == -1) raise_ifx_extended(); return LONG2NUM(ret); } |