Re: can't rebind placehodler - Blob, ODBC, SQL Server, DBI, Win32
- From: Mark Clements <mark.clementsREMOVETHIS@xxxxxxxxxx>
- Date: Thu, 25 Aug 2005 21:58:14 +0200
Eric Anderson wrote:
I have been banging my head against the wall for a while now trying to figure out why I can't upload a some blob data to a SQL Server database via DBI. I think I had it working a while back but I cannot be sure and obviously I am missing something here. The basic code is:
$sql = 'UPDATE "File" SET Data = ? WHERE FileID = ?'; $stmt = $self->storage()->prepare( $sql ); $stmt->trace('5', 'C:\trace.log'); $stmt->bind_param(1, $self->data(), {TYPE=>SQL_LONGVARBINARY}); $stmt->bind_param(2, $self->id()); $stmt->execute(); $stmt->trace('0');
I've tried many variations of the above but I always get the same basic results. The above variations is what I understand as the "correct" method based on the documentation. This code is inside an object so $self->data() returns the blob data as a scalar and $self->id() returns the id of the record we are updating. The whole thing is in the context of a CGI application (Mason actually) that is doing a file upload. My test file is a PDF file (but I have tried many different files of various sizes and types). $self->storage() returns a database handler to the SQL server and I generally haven't had any problems storing other types of data. It will return a brand new handler (new connection) so there is not an issue of a previous execution getting in the way.
My error message I get is:
Can't rebind placeholder 1 at /Program Files/Apache Group/Apache2/sites/cordata/singlesignon/sso/app/models//Data/File.pm line 36.
Line 36 is the execute() statement. To try to debug this I enabled tracing (as you can see from the code). I have pasted the trace at the end of this message. I would be very thankful for any insight that could be provided. The two things that jump out to me in the trace are:
SQLDescribeParam failed reverting to default type for this parameter: HY010 [Microsoft][ODBC Driver Manager] Function sequence error
and
_rebind_ph/SQLBindParameter error -1 recorded: [Microsoft][ODBC SQL Server Driver]Invalid precision value (SQL-HY104)(DBD: _rebind_ph/SQLBindParameter err=-1)
but I don't know enough about what is going on to determine what I need to do to fix the problem. Again thank you for any help you can provide.
<snip trace>
Have you tried binding as different types eg
SQL_BINARY SQL_VARBINARY
what is the actual datatype of the field in question ie "Data" (which isn't a very descriptive name :) )?
Mark .
- Follow-Ups:
- Re: can't rebind placehodler - Blob, ODBC, SQL Server, DBI, Win32
- From: Eric Anderson
- Re: can't rebind placehodler - Blob, ODBC, SQL Server, DBI, Win32
- References:
- can't rebind placehodler - Blob, ODBC, SQL Server, DBI, Win32
- From: Eric Anderson
- can't rebind placehodler - Blob, ODBC, SQL Server, DBI, Win32
- Prev by Date: Re: I just thought I'd ask...
- Next by Date: groups of inputs using CGI.pm
- Previous by thread: can't rebind placehodler - Blob, ODBC, SQL Server, DBI, Win32
- Next by thread: Re: can't rebind placehodler - Blob, ODBC, SQL Server, DBI, Win32
- Index(es):
Relevant Pages
|