Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

How to insert BLOB into DB2 using DBI?

by Anonymous Monk
on Jan 14, 2005 at 15:15 UTC ( [id://422262]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I did a lot of searching on here but couldn't find a direct answer. How would I insert an image file to a DB2 blob via DBI? Thanks

Replies are listed 'Best First'.
Re: How to insert BLOB into DB2 using DBI?
by Tanktalus (Canon) on Jan 14, 2005 at 15:26 UTC

    Can you give us some hints of what you've tried? I would have assumed that normal replacements and binding would work - have you tried that?

    my $stmt = "INSERT INTO my.table (NAME,IMAGE) VALUES(?,?)"; my $sth = $dbh->prepare($stmt); my $rc = $sth->execute('filename.jpg', $contents_of_filename_jpg);
    Untested - but that's because I've not had a need for BLOBs yet. I have a plan for it, and I'm counting on this working ;-)

      Thanks, your code did work. Now how would I download the same data and write it to a file? Thanks

        When you SELECT that column, you should have the raw data in the returned row - just write it to the new file ... print FH $data should work.

        (So far, I doubt any of this is DB2 specific ;->)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://422262]
Approved by holli
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-19 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found