NYCPHP Meetup

NYPHP.org

[nycphp-talk] text: PEAR::DB Oracle BLOBs

Chris Hubbard chubbard at next-online.net
Wed Feb 4 14:15:03 EST 2004


  All,
text version
Has anyone used PEAR::DB to read and write BLOBs into Oracle?

I've got an application that writes incoming email attachments 
(typically pdf and jpg) to a blob field in oracle.  And I want to write 
the blob not from a file, but from a string.

I haven't found the mechanism in PEAR to do this.

Here's the code I'm using (it doesn't work):
    $sql = "INSERT INTO communication_content (id, id_communication, 
is_body_part, compression_method, content_type, content, 
date_record_added) VALUES
    (comm_content_id_seq.NEXTVAL, '". $a["id_communication"] ."', '". 
$a["is_body_part"] ."', '". $a["compression_method"] ."', '". 
$a["content_type"] ."', :the_blob, sysdate)";
    $stmt = OCIParse($conn,$sql);
    OCIBindByName($stmt, ':the_blob', $lob, -1, OCI_B_BLOB);
    $lob->WriteTemporary($a["content"]);
    OCIExecute($stmt, OCI_DEFAULT);
    $lob->close();
    $lob->free();
    OCICommit($conn);

Here's the error:
*Warning*: ociexecute(): OCIStmtExecute: ORA-02019: connection 
description for remote database not found ORA-02063: preceding line from 
DOCS in */Users/chubbard/Sites/imap/email_parser.php* on line *309*
INSERT INTO communication_content (id, id_communication, is_body_part, 
compression_method, content_type, content, date_record_added) VALUES 
(comm_content_id_seq.NEXTVAL, '332', '1', 'application/x-gzip', 
'application/pdf', :the_blob, sysdate)

*Warning*: ociexecute(): OCIStmtExecute: ORA-02019: connection 
description for remote database not found ORA-02063: preceding line from 
DOCS in */Users/chubbard/Sites/imap/email_parser.php* on line *309

*Thanks in advance.
Chris



More information about the talk mailing list