授予赠款的程序,无效 table 名称错误

Procedure which gives grants, Invalid table name error

我正在尝试创建一个向特定模式对象授予授权的过程。程序似乎编译正常,但执行时出错。

这个简单的程序出了点问题,但我找不到原因。

程序:

create or replace procedure ch.grants_to_schema_objects(
          i_target_schema varchar2, 
          i_target_user varchar2) as
begin
 for mt in (SELECT 'GRANT SELECT ON ' || chr(39) 
              || i_target_schema || chr(39) 
              || '.' || TABLE_NAME || ' TO ' || chr(39) 
              || i_target_user || chr(39)
              || ' WITH GRANT OPTION' as grnt 
          FROM ALL_TABLES 
          WHERE OWNER = i_target_schema) loop
  dbms_output.put_line(mt.grnt);
  execute immediate mt.grnt;
end loop;
end;

通话:

 execute ch.grants_to_schema_objects('SR', 'CH');

错误:

ORA-06512: "CH.GRANTS_TO_SCHEMA_OBJECTS", line 5
ORA-06512: line 1
00903. 00000 -  "invalid table name"
*Cause:    
*Action:

CHR(39) 正在破坏它。换成CHR(34):是"你需要把你的用户名分开,不是'.