Hi,
I'm having a problem trying to retrieve a value from a field set as varbinary(MAX) on an MS SQL 2005 backend through DBIx::Simple.
Now I'm not big on DBI but am figuring bits out. I found that inserting and retrieving data worked find if the back was set to varbinary(8000) but since the data would likely exceed 8k varbinary(MAX) was required at which point SELECTs would fail.
I've discovered how to use the LongTruncOk & LongReadLen attributes and these have got me a bit further, I can now retrieve data but the problem I'm having now is that the data always seems to truncate to 1 character.
Can anyone help me retrieve data correctly from a varbinary(MAX)?
On the backend there is a table t_test containing :
Simplified example :
Thanks all.#!perl use strict; use Error qw(:try); use DBIx::Simple; use Sys::Hostname; use DBI; my $dsnString='dbi:ODBC:Driver={SQL Native Client};Server='.hostname.' +;Database=db_simon;Trusted_Connection=yes;'; my $dbh =DBIx::Simple->connect($dsnString,,) || throw Error::Simple("U +nable to connect to Database using DSN String \"".$dsnString."\"."); $dbh->{'dbh'}->{'AutoCommit'} = 0; $dbh->{'dbh'}->{'RowCacheSize'} = 0; $dbh->{'dbh'}->{'LongTruncOk'} = 1; $dbh->{'dbh'}->{'LongReadLen'} = 50000; # actual for varbinary(MAX) = +2147483647 #$dbh->{'dbh'}->{'RaiseError'} = 1; # insert some data my $data = "x" x 1000; $dbh->query('INSERT INTO t_test (c_data) VALUES (?)', $data) or die $d +bh->error; # and retrieve my $results = $dbh->query('SELECT c_id,c_data FROM t_test')->hashes or + die $dbh->error; foreach my $result(@{$results}) { print $result->{'c_id'}."-".substr($result->{'c_data'},0,10)."... +(".length($result->{'c_data'})." chars returned)\n"; } $dbh->disconnect;
In reply to dbix::simple & varbinary(MAX) by Lyndley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |