日期:2014-05-17  浏览次数:20760 次

oracle存储过程实现
把一个table_input(传入的参数)表格的数据复制到新建table_num中,如果table_num存在,
不用再新建,先删除table_num中数据再赋值数据,table_num再添加新的一列time,加上sysdate系统当前时间,坐等
------解决方案--------------------
游标循环里面 exit when 写错了,改为

create or replace procedure simo_pro as
begin
declare   
  isHas number; 
  cursor table_input(inid varchar2) is
  select id,name from simo_tab where id = inid;
  input table_input%ROWTYPE;
begin   
  select   count(1)   into   isHas   from   user_tables   
   where   table_name='大写表名';   
  if   isHas>0   then   
  execute   immediate   'delete  table   '
------解决方案--------------------
'大写表名';   --删除表数据
  end   if;   
  execute   immediate   'create   table....';   --创建表
  
   open table_input('1') ;--传入参数
         loop
           fetch table_input into input;
           exit when table_input%NOTFOUND;
           begin
             ...;   --你的数据插入操作
           end;
         end loop;
    close table_input;
end;
end simo_pro;