Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Call Oracle procedure with PHP

1019592Jun 25 2013 — edited Jul 9 2013

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 .

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2013
Added on Jun 25 2013
1 comment
2,203 views