freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Michael Hudin" <hudin AT zoetrope.com>
- To: <freetds AT franklin.oit.unc.edu>
- Subject: BLOB with MSSQL 7 - more information
- Date: Fri, 3 May 2002 11:33:00 -0700
I'm using DBI
and DBD::SYBASE through freetds 4.2 to connect to an
MSSQL 7.0 sp4 server. I'm trying to retrieve a pdf file from the database--I've been doing this for years on an NT webserver using ODBC, but Linux and FreeTDS is having problems with it. The pdf file is, as you may imagine, stored in a column of type IMAGE. If I try to retrieve the entire file I just get an empty string. I can get the datalength of the file, and I can use SUBSTRING to retrieve up to 228 bytes of data from the file (229 bytes or more results in a 'segmentation error'). I've tried setting the TEXTSIZE to be larger than the file I'm retrieving, but it has had no apparent effect. To demonstrate, here's a snippet of code that shows what's happening, followed by the resulting output: - - - - CODE - - - - - #!/usr/bin/perl use DBI; use strict; my ($textsize, $size, $part_of_data, $all_data); my $dbh = DBI->connect([working connect string]); ($textsize, $size, $part_of_data, $all_data) = $dbh->selectrow_array("SELECT \@\@textsize, datalength(pdf), SUBSTRING(pdf, 1, 20), pdf FROM pdf_sheets WHERE pdf_id = 1"); print <<EOF; Initial Textsize: $textsize File Size: $size Part of Data: $part_of_data All Data: $all_data EOF $dbh->do("SET TEXTSIZE 102400" ); ($textsize, $size, $part_of_data, $all_data) = $dbh->selectrow_array("SELECT \@\@textsize, datalength(pdf), SUBSTRING(pdf, 1, 20), pdf FROM pdf_sheets WHERE pdf_id = 1"); print <<EOF; New Textsize: $textsize File Size: $size Part of Data: $part_of_data All Data: $all_data EOF exit(); - - - - RESULT - - - - - Initial Textsize: 4096 File Size: 92029 Part of Data: '0x255044462d312e330d25e2e3cfd30d0a31203020' All Data: '' New Textsize: 102400 File Size: 92029 Part of Data: '0x255044462d312e330d25e2e3cfd30d0a31203020' All Data: '' |
-
BLOB with MSSQL 7 - more information,
Michael Hudin, 05/03/2002
- <Possible follow-up(s)>
- RE: BLOB with MSSQL 7 - more information, Lowden, James K, 05/03/2002
Archive powered by MHonArc 2.6.24.