Domanda

Sto cercando di associare una variabile php per PL / SQL array. La procedura di sql pl / funziona bene quando eseguo manualmente e impostare il binding, quindi so che non è il problema. E 'il oci_bind_array_by_name che sta causando problemi.

ottengo il seguente messaggio di errore per la linea nel codice PHP sotto dove io chiamo la funzione 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

Sono confuso perché sono in realtà fornire una lunghezza massima (250) nella chiamata di funzione per la documentazione:

http://php.net/manual /en/function.oci-bind-array-by-name.php Sto utilizzando PHP 5.1.6

Ecco il codice PHP in questione:

$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);

Ho un tipo di matrice definito nel pacchetto:

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;
È stato utile?

Soluzione

E mi sento come un pazzo, perché non ho letto l'API abbastanza da vicino. A quanto pare ero specificando il max_table_length, ma il messaggio di errore riferivo alla max_item_length che ho lasciato come -1 ... ma questo è un no-no dal momento che sto associazione di un parametro OUT invece di un tutto in uno.

ha cambiato il bind in questo modo e funziona ora:

oci_bind_array_by_name($stmt,'USER_ID_ARRAY', $userIdArray, 250, 250, SQLT_VCS);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top