0

Catchable fatal error: Object of class OCI-Collection could not be converted to string in E:\php\htdocs\PHPRPC\func.php on line 318

The code:

$sql='BEGIN NCCM_INTERFACE_HISDETAIL(:orgcode,:inhiscode,:inputer,:items); END;';
$conn=oci_connect('chis','chis123','ORCL','UTF8');
$stmt = oci_parse($conn, $sql);
$collection = oci_new_collection($conn,"NCCM_INTERFACE_TABLE");
foreach ($items as $item)
{
    $collection->append($item);
}
oci_bind_by_name($stmt, ":orgcode", $orgcode, -1);
oci_bind_by_name($stmt, ":inhiscode", $inhiscode, -1);
oci_bind_by_name($stmt, ":inputer", $inputer, -1);
oci_bind_by_name($stmt, ":items", $collection,-1); //here the error line
$s=oci_execute($stmt);

Can anyone help me to sort out this issue? Thanks in Advance.

1
  • My php version is 5.2.12 ,and oracle version is oracle 10g
    – PFeng
    Oct 17, 2010 at 5:38

1 Answer 1

1

The issue is you are binding a collection object while Oracle expects the bound type to be SQLT_CHR, e.g. a VARCHAR. Thus, Oracle will try to use the bound object in a string context, which is not possible because the collection apparently has no __toString method implemented. Hence you get the error that the object could not be converted to string.

I am not sure on this, but try to supply a different type in the binding call, for instance:

oci_bind_by_name($stmt, ":items", $collection,-1, OCI_B_NTY);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.