在Oracle中创建存储过程会抱怨无效变量声明

时间:2011-03-08 09:29:44

标签: oracle stored-procedures plsql

当我尝试创建这样的存储过程时:

create or replace
procedure USR_Trial
( auth out usrr.DEPARTMENT 
)
AS
BEGIN
  select authority_id 
  into auth
  from usrr where user_id='G68EF610';
END USR_Trial;

我收到以下错误:

Error(2,1): PLS-00488: invalid variable declaration:  object 'USRR.DEPARTMENT' must be a type or subtype

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:6)

如果usrr.DEPARTMENT是表中的列,并且您希望OUT参数与该列具有相同的数据类型,则语法为:

create or replace
procedure USR_Trial
( auth out usrr.DEPARTMENT%type 
)
...