Forum Stats

  • 3,875,283 Users
  • 2,266,904 Discussions
  • 7,912,137 Comments

Discussions

Call Oracle procedure with PHP

1019592
1019592 Member Posts: 1
edited Jul 9, 2013 4:11PM in PHP

Hello.

I saw on this forums a littlle example who permit to me work with a Oracle procedure with PHP (https://forums.oracle.com/thread/379275).

I had follow this example and it works fine . But i would customize a bit this example and i met a problem.

that it's my PL/SQL code :

PL/SQL Code

create or replace

PROCEDURE PROCEDURE_CURSEUR_EMPLOYE (nameIN VARCHAR2, PO_REF_CURSOR OUT SYS_REFCURSOR) AS

BEGIN

  OPEN PO_REF_CURSOR FOR -- Opens ref cursor for query

  SELECT * FROM EMPLOYES WHERE EMPLOYES.name= name;

END PROCEDURE_CURSEUR_EMPLOYE;

Normally, this procedure permit to me to get all information for the NAME of EMPLOYE I passed in parameters.

that is my PHP code :

PHP code

$temp = 'Leverling';

$outrefc = ocinewcursor($connect); //Declare cursor variable

$mycursor = ociparse ($connect, 'begin procedure_curseur_employe(:name, :curs); end;'); // prepare procedure call

ocibindbyname($mycursor, ':name', $temp, -1, SQLT_CHR); // bind procedure parameters

ocibindbyname($mycursor, ':curs', $outrefc, -1, OCI_B_CURSOR); // bind procedure parameters

$ret = ociexecute($mycursor); // Execute function

$ret = ociexecute($outrefc); // Execute cursor

$nrows = ocifetchstatement($outrefc, $data); // fetch data from cursor

ocifreestatement($mycursor); // close procedure call

ocifreestatement($outrefc); // close cursor

$temp variable contains a Name of one of the employes.

The code work fine (no errors), but when i do var_dump($data) to see the content of it, I see ALL result (Name,phone, ...) for ALL EMPLOYES not juste for employe Leverling.

Anyone got any idea to my problem ?

Thanks in advance and sorry for my english .

Tagged:

Answers

This discussion has been closed.