当前位置: 代码迷 >> Oracle管理 >> pl/sql块异常
  详细解决方案

pl/sql块异常

热度:62   发布时间:2016-04-24 04:29:04.0
pl/sql块错误
declare
    v_countone  int;
    begin
        select count(1)  into v_countone
        --`select count(1)
        from user_tables b
        where b.table_name='SHISHIBIAO' ;
        
       -- end;
        if(v_countone <> 0) then
            execute immediate 'drop table SHISHIBIAO';
        else
        execute immediate 'create table shishibiao
                            (
                            id int not null,
                            subject int not null,
                            begin date,
                            lend date
                            )';
           end if;    
          
           commit;
                   
        --end; 如果执行以上语句能成功
        insert into SHISHIBIAO(id,subject,begin,lend)
        values(1,1,to_date('2013-12-17','yyyy-mm-dd'),to_date('2009-11-11','yyyy-mm-dd'));
        commit;
end;
        --insert into语句和上面的放在一起就出错,查了很久都没弄清错误

------解决方案--------------------
引用:
Quote: 引用:

如果在,你就drop,但没重建~~


declare
    v_countone  int;
    begin
        select count(1)  into v_countone
        --select count(1)
        from user_tables b
        where b.table_name=upper('shishibiao') ;
        
       -- end;
        if(v_countone <> 0) then
            execute immediate 'drop table shishibiao';
        end if;

        /*end;*/
        execute immediate 'create table shishibiao
                            (
                            id int not null,
                            subject int not null,
                            begind date,
                            lend date
  相关解决方案