Hi Everyone,

Hope that this is the right place to post a question.

Has anyone tried calling an Oracle procedure from Php using the ora functions and getting the return value ? I need to use the ora funtions (no oci)because of compatibility and oracle 7.x as the database.

I'm 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,

Rudi

    Write a Reply...