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
In reply to Updating binary data through DBI by EyeOpener
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |