Home » Other » General » Oracle Stored Procedure
Oracle Stored Procedure [message #128291] Sun, 17 July 2005 04:22 Go to next message
stockton
Messages: 10
Registered: July 2005
Location: South Africa
Junior Member
I need a little help writing a PHP program that will call an Oracle stored Procedure but being neither an Oracle nor PHP
expert I am a little stuck.

The stored procedure already exists and it takes a 10 digit number as a parameter and returns 4 variables that I am
interested in, namely MEM_NUMBER, MEM_SNAME, MEM_FNAME & MEM_TITLE.

What I have so far is :-
<?php
  // Connect to database...
  $c=OCILogon("UserName", "UserPassword", "DataBaseName");
// Obviously the "UserName", "UserPassword", "DataBaseName" above are not real.
  if ( ! $c ) {
     echo "Unable to connect: " . var_dump( OCIError() );
     die();
  }

  // Call database procedure...
        // spMemberDetails @number varchar 22
        // MEM_NUMBER, MEM_SNAME, MEM_FNAME, MEM_TITLE
  $in_var = 10;
  $number = 2100418933;
  $s = OCIParse($c, "begin spMemberDetails(:number, :MEM_NUMBER, :MEM_SNAME, :MEM_FNAME, :MEM_TITLE); end;");
  OCIBindByName($s, ":bind1", $in_var);
  OCIBindByName($s, ":bind2", $out_var, 32); // 32 is the return length
  OCIExecute($s, OCI_DEFAULT);
  echo "Procedure returned value: " . $out_var;

  // Logoff from Oracle...
  OCILogoff($c);
?>


but while trying to code the OCIParse I got really lost, as you can see.

Re: Oracle Stored Procedure [message #128455 is a reply to message #128291] Mon, 18 July 2005 12:25 Go to previous message
Frank Naude
Messages: 4581
Registered: April 1998
Senior Member
I don't have a PHP environment to test, but you need to code OCIBindByName() calls for each of your bind variables - :number, :MEM_NUMBER, :MEM_SNAME, :MEM_FNAME and :MEM_TITLE:

   OCIBindByName($s, ":number", $number);
  OCIBindByName($s, ":MEM_NUMBER", ...


Best regards.

Frank
Previous Topic: unable to save strings with crlf to table from ASP
Next Topic: Why need a Schema
Goto Forum:
  


Current Time: Sat Nov 23 02:38:46 CST 2024