Chinaunix首页 | 论坛 | 博客
  • 博客访问: 338887
  • 博文数量: 94
  • 博客积分: 1500
  • 博客等级: 上尉
  • 技术积分: 1020
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-11 09:23
文章分类
文章存档

2011年(76)

2010年(18)

分类: Oracle

2011-02-12 17:18:04

场景如下:
 
-- Created on 2011-2-12 by ADMINISTRATOR
declare
 TableName_         varchar2(32) := 'sp_warehousecheckserial';
      
  sqlstr_ varchar2(1000);
begin
 
 sqlstr_ := 'create table temp_'|| TableName_ || '
 as
 select c.sguid,
        c.slogconfigid,
        c.scolumnname
 from sys_logconfig f ,
      sys_logconfigdetail c
 where f.sguid = c.slogconfigid
       and f.stablename = ''' || TableName_ || ''''; 
 
 execute immediate sqlstr_;
 
 end;
 
 
上面这样子执行是成功的。
 
 
 
-------------------------------------------------------
封装成存储过程来执行就出问题:
 
create or replace procedure pd_CreateValueTable(
       TableName_           in      varchar2
      
) is
  sqlstr_ varchar2(1000);
begin
 
 sqlstr_ := 'create table temp_'|| TableName_ || '
 as
 select c.sguid,
        c.slogconfigid,
        c.scolumnname
 from sys_logconfig f ,
      sys_logconfigdetail c
 where f.sguid = c.slogconfigid
       and f.stablename = ''' || TableName_ || ''''; 
/*sqlstr_ :='create table temp_'|| TableName_  || '( aa varchar2(32))';*/
 execute immediate sqlstr_;
 
 
      
      
end pd_CreateValueTable;
 
------------
 
declare
  -- Local variables here
  i integer;
begin
  -- Test statements here
  steel.pd_createvaluetable('sp_warehousecheckserial');
 
end;
 
 
 
------------------------
 
提示权限不够。
 
 
当时的用户还具有了DBA的权限,可为什么还是不行,百思不得其解。
 
最后,解决办法如下:
 
grant create any table to 用户名;
 
 
问题解决了。
阅读(1978) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-03-05 16:31:03

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com