Calling ORACLE stored function from php

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Zoran_Dimov
Forum Newbie
Posts: 16
Joined: Wed Jun 21, 2006 6:10 pm
Location: Macedonia
Contact:

Calling ORACLE stored function from php

Post by Zoran_Dimov »

I have this function declaration

FUNCTION GENSECURE RETURN VARCHAR2;

I am trying to call it in PHP with the following code

$sql="begin :bind = GENSECURE; end";
$s = ociparse($c, $sql);
OCIBindByName($s, ":bind", $user);
$result=ociexecute($s, OCI_DEFAULT);

The last command (ociexecute($s, OCI_DEFAULT); ) can't be executed. Can anyone tell me where am i wrong?

Thanks
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

I have always used adodb as a database access layer to isolate me from the oci* details. Here is a simple example usind adodb (amp_adodb_connection is a factory function returning and adodb connection):

Code: Select all

$ php -r 'require_once "dblogin.php";
$c = amp_adodb_connection("prdcrm"); 
$c->debug=true; 
$rs = $c->executecursor("begin :r := pdftrade_web.getmonths; end;","r"); 
var_dump(count($rs->getArray()));'

InParameter($stmt, $php_var='', $name='r', $maxLen=-1, $type=116);
-----
(oci8): begin :r := pdftrade_web.getmonths; end;
-----
int(26)
ADOdb is also nice if you have to deal with blobs.
Post Reply