如何从PDO中的存储函数获取返回值?

发布于 2024-11-07 17:26:17 字数 686 浏览 1 评论 0原文

我有这个代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花伊自在美 2024-11-14 17:26:17

如果您有一个返回标量的 Oracle 函数,您可以将其作为任何其他值读取,例如:

SELECT ISPPRO.USERPKG.GET_USER(:user, :pass) AS foo
FROM DUAL

... 并像在任何其他查询中一样从 foo 列中读取值。

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.

看海 2024-11-14 17:26:17

您对该包有执行权限吗?

用户 ISPPRO 应运行该命令

GRANT EXECUTE ON userpkg TO <your_user>;

检查您是否已被授予执行此程序包的一个简单方法是运行此命令:

SELECT privilege
  FROM all_tab_privs
 WHERE table_schema = 'ISPPRO'
   AND table_name = 'USERPKG';

您应该获得一行以 EXECUTE 作为特权。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文