The error message is:sub updateFlyer { my $contentType = shift; use DBI qw(:sql_types); my ( $sql, $sth, $dbh, $mimeType, $contentImage ); # Database connection $dbh = DBI->connect("dbi:ODBC:something", 'something', 'somepass', + {RaiseError => 1}) or die DBI->errstr; # Debug stuff if (1) { DBI->trace(2, "trace.txt"); } ( $mimeType, $contentImage ) = uploadImage( $query ); $sql = "UPDATE interface..CustomContent " . "SET contentImage = ?," . " contentImageType = ? ". "WHERE contentType = ?"; $sth = $dbh->prepare( $sql ); # Gotta bind the image $sth->bind_param( 1, $contentImage, SQL_LONGVARBINARY ); $sth->execute ( $contentImage, $mimeType, $contentType ); $sth->finish; $dbh->disconnect; }
Digging further, I ran a trace with both this script and the working original (I cannot find a significant difference in how they are written) using the same 13K jpeg. The only difference I can see is the following information buried in the trace text:DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL +Server]String or binary data would be truncated. (SQL-22001) [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been +terminated. (SQL-01000)(DBD: st_execute/SQLExecute err=-1) at D:\some +path\cgi-bin\somescript.cgi line 447.
I'm sure that zero is the source of the problem, but I have no idea what it means.Failed upload: (size 12723/12724/0, ptype 4, otype 1) Good upload: (size 12723/12724/12723, ptype 4, otype 1)
We're using NT 4.0, service pack six with IIS and MS SQL Server 7.0. The two scripts are writing to separate tables and I have verified that the field is defined the same way in both tables.
Barring anyone having seen this problem before, can you point me to where I can get information on deciphering the DBI->trace() method's output?
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats.
In reply to DBI Problem - binding variables by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |