本帖最后由 pchyping 于 2013-04-03 12:23:11 编辑

解决方案 »

  1.   

      k_date:='select sysdate+v1 from dual';
            num:='select count(1) from all_tables where TABLE_NAME='||'''tablename''';这两个写法好奇怪啊……
      

  2.   

    还有if ...
    else if ...
    end if;这又是什么的语法?你编译这个过程时,会给你报很多语法错误的,对照着改吧。
      

  3.   

    我改过了,你给我看看
    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
      step4:如有异常则输出‘在RUNPROCEDURE过程中出错!’  */
            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'||k_date;
             execute immediate q_sqlstr;
            else
              return;
             end if;
       exception
         when others then
         DBMS_OUTPUT.PUT_LINE('在RUNPROCEDURE过程中出错!'); 
    end;
      

  4.   

    把基本PL/SQL语法重新学一次。