EyeOpener has asked for the wisdom of the Perl Monks concerning the following question:
I'm working on a script which will gzip a bunch of images in a SQLServer 2000 database. The actual script is pretty lengthy (it iterates through several records and includes tons of error-checking), so I've abbreviated it here:
use DBI; use Compress::Zlib; my $server = "servername"; my $database = "databasename"; my $connstr = "driver={SQL Server};Server=$server;database=$database"; my $dbh = DBI->connect("dbi:ODBC:$connstr") or die "$DBI::errstr\n"; my $qry_getdata = qq { SELECT Image FROM Table1 WHERE Id = 1 }; my ($bindata) = $dbh->selectrow_array($qry_getdata); my $output = Compress::Zlib::memGzip($bindata); # Put the compressed data back here $dbh->disconnect();
This works, but I'm stuck on the step of updating the database with the compressed data now stored in $output. I can't do a simple
because binary fields are handled differently (actually, this is an "Image" datatype). I'm not sure if this is a database, DBI, or ODBC question, but I was hoping one of you fabulous monks could point me in the right direction or provide a code sample. Anyone? Thanks in advance!UPDATE Table1 SET Image = $output WHERE Id = 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Updating binary data through DBI
by tachyon (Chancellor) on Jun 18, 2004 at 01:00 UTC | |
by EyeOpener (Scribe) on Jun 18, 2004 at 19:55 UTC | |
|
Re: Updating binary data through DBI
by Roger (Parson) on Jun 18, 2004 at 01:02 UTC | |
|
Re: Updating binary data through DBI
by mpeppler (Vicar) on Jun 18, 2004 at 05:40 UTC | |
|
Re: Updating binary data through DBI
by jZed (Prior) on Jun 18, 2004 at 01:00 UTC |