PHP Transferring Photos From One Oracle Database Table to Another

Posted by Jonathan Swift on Stack Overflow See other posts from Stack Overflow or by Jonathan Swift
Published on 2010-03-16T12:13:43Z Indexed on 2010/03/16 12:16 UTC
Read the original article Hit count: 274

Filed under:
|
|

I am attempting to transfer a set of photos (blobs) from one table to another across databases. I'm nearly there, except for binding the photo parameter. I have the following code:

$conn_db1 = oci_pconnect('username', 'password', 'db1');
$conn_db2 = oci_pconnect('username', 'password', 'db2');

$parse_db1_select = oci_parse($conn_db1,
"SELECT
    REF PID,
    BINARY_OBJECT PHOTOGRAPH
FROM
    BLOBS");

$parse_db2_insert = oci_parse($conn_db2,
"INSERT INTO
    PHOTOGRAPHS
    (PID,
    PHOTOGRAPH)
VALUES
    (:pid,
    :photo)");    

oci_execute($parse_db1_select);

while ($row = oci_fetch_assoc($parse_db1_select)) {
    $pid = $row['PID'];
    $photo = $row['PHOTOGRAPH'];

    oci_bind_by_name($parse_db2_insert, ':pid', $pid, -1, OCI_B_INT);

    // This line causes an error
    oci_bind_by_name($parse_db_insert, ':photo', $photo, -1, OCI_B_BLOB);

    oci_execute($parse_db2_insert);
}

oci_close($db1);
oci_close($db2);

But I get the following error, on the error line commented above:

Warning: oci_execute() [function.oci-execute]: ORA-03113: end-of-file on communication channel Process ID: 0 Session ID: 790 Serial number: 118 

Does anyone know the right way to do this?

© Stack Overflow or respective owner

Related posts about php

Related posts about Oracle