17,090
社区成员
发帖
与我相关
我的任务
分享
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 created
SQL>
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.sql
E:\>more test.sql
begin
grantToUser(&startBy,&endBy);
end;
/
E:\>todo.bat
E:\>sqlplus scott/tiger @test.sql
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 11月 4 16:57:49 2010
Copyright (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