in reply to Re: Re: Oracle BLOBs DBD::Oracle
in thread Oracle BLOBs DBD::Oracle

First, BLOB support with Oracle and DBI definitely works, and many people have used it successfully.

I see a few things in your code. First, don't quote $blob. Second, you have to use bind variables when working with BLOBs. Don't try to just put $blob into the statement as a quoted string. Finally, "SQL_LONGVARBINARY" looks fishy to me. I have always used code that looks like this:

$sth->bind_param(1, $serialized, {ora_type => ORA_BLOB, ora_field => ' +data' });

Replies are listed 'Best First'.
Re: Re: Re: Re: Oracle BLOBs DBD::Oracle
by PerliKnight (Acolyte) on Apr 09, 2003 at 08:48 UTC

    Still not working. Do you have a working example I could see?

    Code now looks like and gets can't call bind_param on an undefined value but I don't know what it's on about.

    # prepare update statement print "INFO: reading $photo to blob\n"; open (BLOB, "<$photo") or die "Can't open $photo: $!"; binmode BLOB; local($/) = undef; $blob = <BLOB>; close (BLOB); my $sth = $dbh->prepare ("update ssi_pri_photos set recorded = sysdate +, recorded_by = 'David', photograph = ? where number = $id"); $sth->bind_param(1, $blob, {ora_type => ORA_BLOB, ora_field => 'photog +raph'});

    I've tried putting in 113 for ORA_BLOB too but that didn't make any difference.

    Any ideas?

    Thanks,
    David

      There are complete working examples in the test suite that comes with DBD::Oracle. Take a look at this one.

      The error you're getting is because your call to $dbh->prepare failed. You aren't checking the return value.

        Cheers, I'll check that out.

        (Yep on the second point. It failed because some gonzo changed permissions and didn't tell me and I'd missed the error check out).

        Thanks for your help.
        David