php+oracle(OCI) 问题
可捕获的致命错误:第 318 行 E:\php\htdocs\PHPRPC\func.php 中的 OCI-Collection 类对象无法转换为字符串
代码:
$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);
任何人都可以帮我解决这个问题吗?提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您正在绑定一个集合对象,而 Oracle 期望绑定类型为
SQLT_CHR
,例如VARCHAR
。因此,Oracle 将尝试在字符串上下文中使用绑定对象,这是不可能的,因为该集合显然没有实现 __toString 方法。因此,您会收到对象无法转换为字符串的错误。我对此不确定,但尝试在绑定调用中提供不同的类型,例如:
The issue is you are binding a collection object while Oracle expects the bound type to be
SQLT_CHR
, e.g. aVARCHAR
. 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: