Oracle Function Calls Redux
| From: | Richard S. Crawford | Date: | Thu, 08 Mar 2001 17:18:55 +0000 |
| Subject: | Oracle Function Calls Redux | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7209@lists.php.net to get a copy of this message | ||
Problem solved!
Thanks to everyone who helped out (and to our system DBA for reminding me that an Oracle function is just a type of stored procedure).
For what it's worth, here is the code that I wound up using (sensitive company information xxxx'ed out, of course):
<?php
// Establish Oracle connection
putenv("ORACLE_SID=xxxx");
putenv("ORACLE_HOME=xxxx");
$db = ocilogon("xxxx","xxxx","xxxx");
if(!$db) die("Database connection failed.");
// Execute stored procedure
$functionCall = "begin :result := hubins_func('Richard','Y');end;";
$parsedFunctionCall=ociparse($db,$functionCall);
ocibindbyname($parsedFunctionCall,":result",$result,10);
if(!ociexecute($parsedFunctionCall)) die ("Stored Procedure execution failed.");
print("Value of primary key: $result");
// End Oracle connection
ocilogoff($db);
?>
The value of $result is the primary key which is associated with the value inserted into the database with the hubins_func stored proc.