PL / SQL Oracle-遇到符号“文件结束”

时间:2018-07-09 09:17:30

标签: oracle plsql

我正在尝试制定一个程序,以向用户授予某种类型的对象

这就是我所做的

CREATE OR REPLACE PROCEDURE grants AS
DECLARE
   Cursor c IS select OBJECT_NAME as view_name from all_objects where object_type in ('VIEW');

BEGIN
    FOR tmp in c
    LOOP
        EXECUTE IMMEDIATE 'GRANT ALL on ' || tmp.view_name ||  ' TO my_users';
    END LOOP;
END;

但是我遇到了[...]符号错误...

你们有一个使该程序起作用的想法吗?

1 个答案:

答案 0 :(得分:0)

删除DECLARE

SQL> CREATE OR REPLACE PROCEDURE grants AS
  2      CURSOR c  IS
  3          SELECT OBJECT_NAME AS view_name
  4            FROM all_objects
  5           WHERE object_type IN ('VIEW');
  6  BEGIN
  7      FOR tmp IN c
  8      LOOP
  9          EXECUTE IMMEDIATE 'GRANT ALL on ' || tmp.view_name || ' TO my_users';
 10      END LOOP;
 11  END;
 12  /

Procedure created.