我正在执行一个PL / SQL程序,但我收到错误PLS-00201:标识符' KURTWB'必须声明
DECLARE
create_user dba_users%ROWTYPE;
model_id varchar2(20);
user_name varchar2(20);
BEGIN
model_id:=&model_id;
user_name:=&user_name;
Select * INTO create_user from dba_users where username=model_id;
EXECUTE IMMEDIATE 'create user user_name identified by password
user_name default tablespace create_user.default_tablespace
temporary tablespace create_user.temporary_tablespace profile
create_user.profile;';
END;
/
以下是我输入的值
Enter value for model_id: kurtwb
old 6: model_id:=&model_id;
new 6: model_id:=kurtwb;
Enter value for user_name: rohit
old 7: user_name:=&user_name;
new 7: user_name:=rohit;
以下是我得到的错误
ERROR at line 6:
ORA-06550: line 6, column 11:
PLS-00201: identifier 'KURTWB' must be declared
ORA-06550: line 6, column 1:
PL/SQL: Statement ignored
ORA-06550: line 7, column 12:
PLS-00201: identifier 'ROHIT' must be declared
ORA-06550: line 7, column 1:
PL/SQL: Statement ignored
答案 0 :(得分:0)
您已输入kurtwb
作为名为&model_id
的替换变量的值
SQLPLus(或Oracle-SQL-Developer`)在此行中替换此变量:
BEGIN
model_id:=&model_id;
....
....
输入值kurtwb
。替换后,代码如下所示:
BEGIN
model_id:=kurtwb;
....
....
由于kurtwb
未在任何地方定义,因此会出现PLS-00201: identifier 'KURTWB' must be declared
错误。
我想您希望将kurtwb
存储为model_id
变量中的字符串,在这种情况下,您必须使用撇号替换变量:
BEGIN
model_id:='&model_id';
....
....