如何从PDO中的存储函数获取返回值?
我有这个代码:
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>";
ISPPRO.USERPKG.GET_USER
返回 1 或 0;
我怎样才能得到它?
提前致谢。
编辑:
我更改了上面的代码,但收到此错误:
OCIStmtExecute: ORA-00904: "ISPPRO"."USERPKG"."GET_USER": invalid identifier
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有一个返回标量的 Oracle 函数,您可以将其作为任何其他值读取,例如:
... 并像在任何其他查询中一样从
foo
列中读取值。If you have an Oracle function that returns a scalar you read it as any other value, e.g.:
... and read the value from the column
foo
as in any other query.您对该包有执行权限吗?
用户 ISPPRO 应运行该命令
检查您是否已被授予执行此程序包的一个简单方法是运行此命令:
您应该获得一行以 EXECUTE 作为特权。
Do you have execute permission on the package?
User ISPPRO should run the command
An easy way to check if you've been granted execute on this package is to run this command:
You should get a row with EXECUTE as the privilege.