我建立了一个 存储过程
 里面用到了临时表
           CREATE   GLOBAL   TEMPORARY  table  cellBusyHour_temp  
      (
        cell_name varchar2(30),
        tch_traffic float
       )
      ON   COMMIT   DELETE   ROWS;         CREATE   GLOBAL   TEMPORARY  table  cellBusyHour_temptwo  
      (
       cell_name varchar2(30),
       scan_start_time date
       )
      ON   COMMIT   DELETE   ROWS; 
在存储过程中也用到了 这个存储零时表
    sql_insert := 'insert into pmdb.t_s_radio_temp1 select * from pmdb.t_s_radio a  where a.START_TIME >= :1 and a.START_TIME < :2 ';
           execute immediate sql_insert using s_time,e_time;
           sql_insert :=' insert into pmdb.cellBusyHour_temp1(cell_name,tch_traffic) select LEVEL_DN , max(tch_traffic) from  pmdb.t_s_radio_temp1   group by LEVEL_DN   ';
           execute immediate sql_insert;
           sql_insert := 'insert into pmdb.cellBusyHour_temptwo1(cell_name,scan_start_time)     select  a.LEVEL_DN ,max(a.start_time) as scan_start_time   from  
                          pmdb.t_s_radio_temp1 a , pmdb.cellBusyHour_temp1 b where a.LEVEL_DN=b.cell_name and a.tch_traffic=b.tch_traffic group by  a.LEVEL_DN  ';
           execute immediate sql_insert;    在运行过程中 改临时表所在的表空间  就无限增大了。。 存储过程也不停止
   但是我把零时表 改成  实体表。
   存储过程能结束。。 也没有看 实体表所在的表空间 没怎么变大。
 想知道原因。。
   还有个问题 如果我用实体表 那么存储最后是需要
   
            sql_truncate := ' truncate table pmdb.t_s_radio_temp1 '; 
            execute immediate sql_truncate;
            sql_truncate := ' truncate table pmdb.cellBusyHour_temp1 '; 
            execute immediate sql_truncate;
            sql_truncate := ' truncate table pmdb.cellBusyHour_temptwo1 '; 
            execute immediate sql_truncate;
   
        但是报错 没有 什么权限之类的
  但是 我在外面 truncate table pmdb.t_s_radio_temp1 这样是能执行的
  问下原因 知道的 帮助下。

解决方案 »

  1.   

    没有权限很正常
    在plsql中可以执行 但是在存储过程或者函数中没有权限的话 要用dba给用户授权的
    大概是grant truncate table to username这样的语句来授权 具体的你可以百度
    还有 你当前登陆用户和创建存储过程的用户是同一个吗?
      

  2.   


    过程中清除表中数据:
    sql_text :='truncate table table_name'; 
    execute immediate sql_text;
    不过此用户得有删除任意表的权限,若没有,可以授权:
    grant drop any table to 当前用户 
      

  3.   

    你需要联系你们的dba 让他给你用的用户授权