Gustavo Benito Silva
Gustavo Benito Silva

Reputation: 543

calling oracle anonimous pl/sql from php

I have this code:

$P_ID = 12;
$P_RESULTADO = null;

$c = OCILogon($config['db']['username'], $config['db']['password'], $config['db']['hostspec']);


$query = 'DECLARE
P_ID NUMBER;
P_RESULTADO VARCHAR2(32767);
BEGIN
P_ID := 12; 
P_RESULTADO := NULL;
SINTRA.PKG_CONSULTAS_RAPIDAS.P_DATOS_PAIS_PHP ( :P_ID, :P_RESULTADO );
COMMIT;
END;';

$stid = oci_parse($c, $query);
   oci_bind_by_name($stid, ":P_RESULTADO", $P_RESULTADO, 32767);
   oci_bind_by_name($stid, ":P_ID", $P_ID, 2);

    oci_execute($stid,OCI_DEFAULT);



while ($row = oci_fetch($stid)) {

$este[] = $row; 

}

oci_close($c);

print_r($este);

But is giving me this error:

Warning: oci_fetch(): ORA-24374: define not done before fetch or execute and fetch in

I really don´t know what i'm doing wrong here, can you please give me a hint on how to resolve it?

Upvotes: 0

Views: 94

Answers (1)

Pavlo Vons
Pavlo Vons

Reputation: 76

Before fetch or execute and fetch in you must do

oci_define_by_name 

for each column than fetch or execute.

Upvotes: 1

Related Questions