0
我想綁定一個php變量到pl/sql數組。當我手動執行它並設置綁定時,pl/sql過程正常工作,所以我知道這不是問題。這是導致問題的oci_bind_array_by_name
。爲什麼PHP的OCI8/Oracle oci_bind_array_by_name不適合我?
我得到下面,我叫oci_bind_array_by_name
函數在PHP代碼行以下錯誤信息:
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/en/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;