Discussions
Categories
- 196.8K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.3K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 544 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.8K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.5K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 439 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
Call Oracle procedure with 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 .
Answers
-
The obsolete ocifetchstatement() is equivalent to oci_fetch_all() so
I'd expect it to fetch multiple rows if the query returns them.
Triple-check everything: are you connected to the right database? Is
the PL/SQL code being executed the same as the one you think it is?
I recommend using non-obsolete OCI8 functions e.g. see the OCI8 manual
or look at "Using REF CURSORS for Result Sets" on p 197 of
http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html