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

oracle存储过程
本帖最后由 pchyping 于 2013-04-03 12:23:11 编辑
create or replace procedure test_droptable
    (
       dbname varchar2,/*传入数据库名称参数*/
       tablename varchar2,/*传入表名参数*/
        v1 int/*时间偏移量*/
    )
as
 k_date date;
 q_sqlstr varchar2(200);
 num int;
  begin
  /*执行语句块*/
  /*
  step1: 获得系统时间
         根据系统时间来加上偏移量得到要执行的时间变量 _date
  step2: 判断数据库中是否有这张表
           yes:拼接sql语句 drop table schema.table_name||_date
           no:直接返回
  step3:执行sql


  */
        k_date:='select sysdate+v1 from dual';
        num:='select count(1) from all_tables where TABLE_NAME='||'''tablename''';
        if (num=1) then
         q_sqlstr:='drop table schema.tablename||_date';
        else if(num=0)
          return;

          end if;
         execute immediate q_sqlstr;
end;


请大侠帮忙看看,提示TEST_DROPTABLE无效
oracle 存储

------解决方案--------------------
还有

if ...
else if ...
end if;

这又是什么的语法?

你编译这个过程时,会给你报很多语法错误的,对照着改吧。