将一系列表TableXXX的权限授予给其他用户,其中表名包含的XXX是递增的数字序列,比如table001,table002,table003.....
执行脚本时,要求输入参数包括开始编号vi1和结束编号vi2
如输入21,50,那么执行后的结果便是将table021至table050的30个表格的select权限授给用户OtherUser
望高人解答,谢谢啦

解决方案 »

  1.   

    oracle 要接受操作系统的传过来的参数?
      

  2.   

    对~~~  运行bat文件时需要输入参数
      

  3.   


    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 
    Connected as scott
    SQL> 
    SQL> create or replace procedure grantToUser(startBy in number,endBy in number)
      2  is
      3  v_sql varchar2(2000);
      4  begin
      5    for i in startBy .. endBy loop
      6      v_sql := 'grant select on table'||lpad(i,'0')||' to system';
      7      execute immediate  v_sql;
      8    end loop;
      9  end grantToUser;
     10  /Procedure createdSQL> 我这里没有你的表所以报错了Microsoft Windows XP [版本 5.1.2600]
    (C) 版权所有 1985-2001 Microsoft Corp.C:\Documents and Settings\lkf12998>E:E:\>more todo.bat
    sqlplus scott/tiger @test.sqlE:\>more test.sql
    begin
    grantToUser(&startBy,&endBy);
    end;
    /E:\>todo.batE:\>sqlplus scott/tiger @test.sqlSQL*Plus: Release 10.2.0.1.0 - Production on 星期四 11月 4 16:57:49 2010Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    连接到:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options输入 startby 的值:  1
    输入 endby 的值:  2
    原值    2: grantToUser(&startBy,&endBy);
    新值    2: grantToUser(1,2);
    begin
    *
    第 1 行出现错误:
    ORA-00903: 表名无效
    ORA-06512: 在 "SCOTT.GRANTTOUSER", line 7
    ORA-06512: 在 line 2