1 Reply Latest reply: Jul 9, 2013 3:11 PM by cj RSS

    Call  Oracle procedure with PHP

    e95c92f4-d0cf-4371-b120-0626e82b0d0d

      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 .