Re: can't rebind placehodler - Blob, ODBC, SQL Server, DBI, Win32



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
.



Relevant Pages

  • Unable to insert BLOB value into a MSSCE "image" field. Error: 8007000E - Not enough storage is
    ... When I'm trying to add BLOB data into a MS SQL Server Compact edition table I get following error ... First chance exception at $767442EB. ... messages sent by OutputDebugString API function. ...
    (borland.public.delphi.database.ado)
  • Re: Customized filter for content searching
    ... documents with SQL Server Full-Text Search in SQL Server 2000. ... As for your images you will need to store them separately ... Access and Modify SQL Server BLOB Data by Using the ... > I have some office documents which I am storing as image ...
    (microsoft.public.sqlserver.fulltext)
  • cant rebind placehodler - Blob, ODBC, SQL Server, DBI, Win32
    ... 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. ... SQLDescribeParam failed reverting to default type for this parameter: ... 773 0 obj ...
    (comp.lang.perl.misc)
  • Re: Full Text Search Setup
    ... have SQL Server 2000 SP3 on Win2003! ... by populating the column documentdoctype2 column with both ... Access and Modify SQL Server BLOB Data by Using the ... > (which is why we are storing the mime type.) ...
    (microsoft.public.sqlserver.fulltext)