[英]Why is PHP's OCI8/Oracle oci_bind_array_by_name not working for me?
我正在尝试将PHP变量绑定到pl / sql数组。 当我手动执行并设置绑定时,pl / sql过程可以正常工作,因此我知道这不是问题。 这是oci_bind_array_by_name
,是造成问题。
我在下面的PHP代码行中收到以下错误消息,在这里我调用oci_bind_array_by_name
函数:
Warning: oci_bind_array_by_name() [function.oci-bind-array-by-name]: You must provide max length value for empty arrays
我很困惑,因为实际上我根据文档在函数调用中提供了最大长度(250):
http://php.net/manual/zh/function.oci-bind-array-by-name.php我正在使用PHP 5.1.6
以下是相关的PHP代码:
$SQL = "BEGIN MYPKG.PROCESS_USERS(:USER_ID_ARRAY); END;";
$conn = self::getConnection();
$stmt = OCIParse($conn, $SQL);
$userIdArray= array(); /*I've also tried not initializing the OUT array (same error)
If I put some dummy value into the $userIdArray the procedure will run fine, but the results afterward will contain only that dummy value and not the output of the procedure*/
oci_bind_array_by_name($stmt,'USER_ID_ARRAY', $userIdArray, 250, -1, SQLT_VCS);
我在包中定义了一个数组类型:
TYPE USER_ID_ARRAY IS TABLE OF VARCHAR2(250) INDEX BY BINARY_INTEGER;
The PROCESS_USERS function in an abbreviated form:
PROCEDURE PROCESS_USERS(p_userIdArray out USER_ID_ARRAY) AS
--Code here which processes all waiting users and returns their IDs in p_userIdArray
END PROCESS USERS;
而且我觉得自己很傻,因为我没有足够仔细地阅读API。 显然我指定的是max_table_length,但错误消息指向的是我留为-1的max_item_length ...但这是不行,因为我绑定的是OUT参数而不是IN参数。
像这样更改了绑定,它现在可以工作:
oci_bind_array_by_name($stmt,'USER_ID_ARRAY', $userIdArray, 250, 250, SQLT_VCS);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.