Hello,
I am trying to insert a binary object into a SQL Server table field of type
IMAGE,
using Perl and DBI. I have been unsuccessful so far, though I have tried all
the
solutions suggested in the various lists on the internet. Could anyone who has
implemented such a thing successfully please let me know how to proceed ?
Here is what I am doing :
- Open a connection to the SQL Server database.
- Set LongtruncOK = 1 and LongReadLen = 10MB.
# Insert the document.
$SQL = "INSERT INTO blob ( filename, data ) " .
"VALUES ( ?, ?)";
$Stmt = $dbh->prepare($SQL);
if ( ! $Stmt ) {
print "\nUnable to prepare !";
return;
}
$Stmt->bind_param(1, $FileName);
$Stmt->bind_param(2, $Data);
$Stmt->execute;
That the contents $Data is proper, has been verified.
Using $Stmt->bind_param(2, $Data, { TYPE => SQL_BINARY}); did not work,
neither did SQL_VARBINARY nor SQL_VARLONGBINARY.
I have tried quotemeta and $dbh->quote on $Data, but
all I seem to get is :
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]String data,
right truncation
(SQL-22001)(DBD: st_execute/SQLExecute err=-1) at C:\TEMP\attachment.pl line
136.
Any help in this regard would be appreciated.
Thanks & Regards,
Arun Kalkunte.