how to get returned value from stored function in PDO?
I have this code :
include("connect.php");
// Call database function
$p = 100;
$sth = $conn->prepare('SELECT ISPPRO.USERPKG.GET_USER(:bind1, :bind3) AS v FROM DUAL');
$sth->bindParam(":bind1", $p, PDO::PARAM_INT);
$sth->bindParam(":bind3", $p, PDO::PARAM_INT);
$sth->execute();
$result = $sth->fetch(PDO::FETCH_ASSOC);
print_r( $result);
echo "<br><pre>";
print_r($conn->errorInfo());
echo "</pre>";
The ISPPRO.USERPKG.GET_USER
returns 1 开发者_开发百科or 0;
How I can get it??
Thanks in advance.
EDIT:
I changed the above code and I am getting this error:
OCIStmtExecute: ORA-00904: "ISPPRO"."USERPKG"."GET_USER": invalid identifier
If you have an Oracle function that returns a scalar you read it as any other value, e.g.:
SELECT ISPPRO.USERPKG.GET_USER(:user, :pass) AS foo
FROM DUAL
... and read the value from the column foo
as in any other query.
Do you have execute permission on the package?
User ISPPRO should run the command
GRANT EXECUTE ON userpkg TO <your_user>;
An easy way to check if you've been granted execute on this package is to run this command:
SELECT privilege
FROM all_tab_privs
WHERE table_schema = 'ISPPRO'
AND table_name = 'USERPKG';
You should get a row with EXECUTE as the privilege.
精彩评论