执行立即更改用户绑定变量 [英] Execute Immediate Alter User Bind Variable

查看:65
本文介绍了执行立即更改用户绑定变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下过程:

create or replace
PROCEDURE ChangePassword
(
    p_Name      VARCHAR2,
    p_Password  VARCHAR2
)
AS
  EXECUTE IMMEDIATE 'ALTER USER :a IDENTIFIED BY :b' USING p_Name, p_Password;
END;

编译成功,但是执行时:

compiles successfuly, but when executed:

exec ChangePassword('TestUser', 'newPassword');

导致错误:

01935. 00000 -  "missing user or role name"
*Cause:    A user or role name was expected.
*Action:   Specify a user or role name.

为什么?

推荐答案

您不能使用绑定变量代替标识符,例如此语句中的用户名.解析语句时需要知道标识符的值,而解析后并在执行前合并绑定值.

You can't use bind variables in place of identifiers, such as the user name in this statement. The value of the identifier needs to be known when the statement is parsed, whereas a bind value is incorporated after parsing, before execution.

这篇关于执行立即更改用户绑定变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆