Perl DBI dbi:sybase to MSSQL server using binary rtf on a fieldtype image
- From: "kivanc_k" <kivanc_k@xxxxxxxxx>
- Date: 27 Apr 2005 13:50:39 -0700
from my linux, I`ve connected to an MSSQL server using
use DBI;
$ENV{'SYBASE'} = '/usr/local' unless $ENV{'SYBASE'};
my $dbh =
DBI->connect('dbi:Sybase:server=10.22.21.130;database=thedb','sa','');
I was asked for retrieving some text data, OK. no problem with
my $sth3 = $dbh->prepare("SELECT * from OLE where x='$y'");
$sth3->execute() or die $sth3->errstr;
while (my @type3 = $sth3->fetchrow_array()) {
...
}
$sth3->finish();
Then I`m asked to bring binary data. They told me, they`ve stored an
RTF file in a binary field, type named IMAGE.
OK, first, I`ve glimpsed on CPAN and found 2 RTF modules (RTF::Parser,
RTF::Tokeniser i think). I`ve tried on file conversions (regular rtf`s
stored on disk) with those modules from RTF to text and HTML, great,
everything works perfect.
and I`ve queried the database, the related table with both text fields
and binary field, she said me "error_handler: Data-conversion resulted
in overflow".
I`ve searched freetds source file, I`ve found SYBTEXT case giving me
the error from (len > destlen). Googled a bit, I`ve found I need to
make
$dbh->do("set textsize 102400");
before my
my $sth3 = $dbh->prepare("SELECT * from OLE where x='$y'");
to make her happy.
I did, and she returned me a long hex string, as mentioned in perl DBI
book.
whatever I did with pack() and unpack() of perl, I couldn`t recover
that RTF to read.
In fact I`ve had some part of it human readable, but I could never make
it a real RTF.
Now I`m stuck.
How will I read long hex string output from DBI to dump rtf from a
field type IMAGE, stored a legal rtf ?
I`ve written all it down step by step what I`ve done, in order to help
others, because there must be others stuck on same.
thanks
.
- Prev by Date: RE: Can't locate DBI.pm
- Next by Date: Re: cPanel / DBI / mySQL / Exim issue
- Previous by thread: cPanel / DBI / mySQL / Exim issue
- Next by thread: Re: DBD::mysql 2.9007 and DBD::mysql 2.9015_3 (beta) released
- Index(es):