PDA

View Full Version : How to insert a BLOB using OCI


tobia
07-28-2011, 10:08 AM
Hello

I'm having difficulties inserting a BLOB into an Oracle 11 DB using Quercus 4.0.18 and the OCI API.

The following, taken from PHP manual (http://php.net/manual/en/function.oci-new-descriptor.php), does not work. The row gets inserted, no error is raised, but the BLOB column is null.


$cur = oci_parse($db, "insert into binary_table (bin_blob) values (empty_blob()) returning bin_blob into :blob");
$lob = oci_new_descriptor($db, OCI_D_LOB);
oci_bind_by_name($cur, ':blob', $lob, -1, OCI_B_BLOB);
oci_execute($cur, OCI_DEFAULT);
$lob->write('Lorem ipsum.');
oci_commit($db);
$lob->free();
oci_free_statement($cur);



Does anybody know how to do it?

tobia
07-29-2011, 04:01 PM
Nevermind, I managed to do it using PDO. In hindsight, it was straightforward!


$cur = $db->prepare("insert into test (test_blob) values (:blob)");
$cur->bindParam(':blob', $blob_data, PDO::PARAM_LOB);
$cur->execute();

biggirl2012
08-16-2011, 09:34 AM
Do you have anything else?
--------------------------
Phan mem SEO (http://vinaposter.com) | Phan mem SEO (http://vinaposter.com) | Phan mem Marketing (http://vinaposter.com) | Phan mem dang tin (http://vinaposter.com) | Phan mem dang tin (http://phanmemdangtin.vn)