void odbc_lob_read(sth, colno, buf, length, attr = NULL) SV *sth int colno char *buf UV length SV *attr; PROTOTYPE: $$$$;$ PREINIT: SV * const bufsv = SvROK(ST(2)) ? SvRV(ST(2)) : ST(2); UV ret_len; IV sql_type = 0; CODE: if (length == 0) { croak("Cannot retrieve 0 length lob"); } if (attr) { SV **svp; DBD_ATTRIBS_CHECK("odbc_lob_read", sth, attr); DBD_ATTRIB_GET_IV(attr, "Type", 4, svp, sql_type); } sv_setpvn(bufsv, "", 0); /* ensure we can grow ok */ /* length is the length in chrs/bytes depending on the underlying * datatype. i.e., it is usually bytes but if we are built to support * unicode and the column is not a binary type, we will convert to * UTF8 encoding so we need at least 6 * as many bytes. */ buf = SvGROW(bufsv, length * + 1); ret_len = odbc_st_lob_read(sth, colno, bufsv, length, sql_type); if (ret_len > 0) { SvCUR_set(bufsv, ret_len); /* set length in SV */ *SvEND(bufsv) = '\0'; /* NUL terminate */ /*sv_setpvn(ST(3), buf, 4);*/ SvSETMAGIC(ST(2)); } ST(0) = (ret_len >= 0) ? sv_2mortal(newSViv(ret_len)) : &PL_sv_undef; #### my $s = $h->prepare(q{select 'frederick'}); $s->execute; $s->bind_col(1, undef, {BindAsLOB=>1}); $s->fetch; # SQL_SUCCESS = 0 # SQL_SUCCESS_WITH_INFO = 1 # SQL_NO_DATA = 100 while(my $len = $s->odbc_lob_read(1, \my $x, 8)) { print "len=$len, x=$x\n"; }