note 45741 added to ref.oracle
| From: | rd282001 at yahoo dot com | Date: | Thu, 16 Sep 2004 20:08:44 +0000 |
| Subject: | note 45741 added to ref.oracle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76844@lists.php.net to get a copy of this message | ||
Hi Everyone,
Has anyone tried calling an Oracle procedure from Php using the ora functions and getting the return
value ?
I'm still trying to get this to work. My code after the connection call is as follows:
$cur = ora_open($this->conn);
ora_commitoff($this->conn);
$requestid = '144937';
echo $requestid;
$rc = ora_parse($cur, "begin p_ins_gsdata2
(:requestid, :returnval); end;");
if ($rc == true) {
echo " Parse was successful ";
}
$rc2 = ora_bind ($cur, "requestid", ":requestid", 32, 1);
if ($rc2 == true) echo " Requestid Bind Successful ";
$rc3 = ora_bind ($cur, "returnval", ":returnval", 32, 2);
if ($rc3 == true) echo " Returnval Bind Successful ";
$returnval = "0";
$rc4 = ora_exec($cur);
echo " Result = ".$returnval." ";
if ($rc4 == false) {
echo " Exec Returned FALSE ";
echo " Error = ".ora_error($cur);
echo " ";
echo "ErrorCode = ".ora_errorcode($cur);
echo "Error Executing";
}
ora_close ($cur);
The Oracle procedure has a select count from a table and it
returns the number of records in that table. It's defined
as:
CREATE OR REPLACE procedure p_ins_gsdata2 (
p_requestid IN varchar2 default null,
p_retcode OUT varchar2)
as
BEGIN
SELECT COUNT (*) INTO p_retcode
FROM S_GSMRY_DATA_SURVEY
WHERE request_id = p_requestid ;
COMMIT;
RETURN;
END;
Nothing much there. I want to do an insert into a table,
from the procedure later, but I figured that I start with a select count since it's simpler.
When I ran the Php code, I get the following:
144937
Parse was successful
Requestid Bind Successful
Returnval Bind Successful
Result = 0
Exec Returned FALSE
Error = ORA-00000: normal, successful completion -- while
processing OCI function OBNDRA
ErrorCode = 0
Error Executing
I listed the messages on separate lines for clarity. I don't understand why it parses and binds
o.k. but the exec returns false.
Thanks again in advance for your help. Have a great day.
Regards.
----
Manual Page -- http://www.php.net/manual/en/ref.oracle.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45741
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45741&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45741&report=yes
Search -- http://master.php.net/manage/user-notes.php