if t.flag = 0 then 
update table t set t.flag = 1 ;
end if;

解决方案 »

  1.   

    if t.flag = 0 then 
        update table t set t.flag = 1 ;
    elsif condition then
    ---
    esle
    ---
    end if;
      

  2.   

    我按照楼上写了一个例子运行,if t.POOL_DELETED_FLAG = 0 then 
    update apm_emp_pool_tbl t set t.POOL_DELETED_FLAG = 1;
    end if;但是报错:
    ORA-00900 invalid SQL statementCause: The statement is not recognized as a valid SQL statement. This error can occur if the Procedural Option is not installed and a SQL statement is issued that requires this option (for example, a CREATE PROCEDURE statement). You can determine if the Procedural Option is installed by starting SQL*Plus. If the PL/SQL banner is not displayed, then the option is not installed.请问什么原因?Procedural Option 是不是存储过程的啊 ,怎么 install?
      

  3.   

    if ... end if是PL/SQL, 报错原因是非法SQL, 你在SQL环境下写PL/SQL, 当然非法啦,
    SQL环境下只能用 case... when...  ,  没if的
      

  4.   

    我是在toad 和pl/sql developer上运行的,那按照楼上的意思,这个环境就是sql环境,而非pl/sql环境了。那请问怎么才算pl/sql环境呢? 可能问题很菜。大家原谅了。
      

  5.   

    在 pl/sql developer sql window 中declare
           cursor c_flag is select flag from table ;
    begin
          for cc in c_flag loop
             if (cc.flag=0) then
                 update table set flag=1 ;
             end if;
          end loop;
          commit;
    end ;
    /个人感觉sql中用 decode 或 case 好些!!
      

  6.   

    请在if ...end if 前后加在begin end;
    begin
      if thne
      end if;
    end;
      

  7.   

    update table t set t.flag=1
    where t.flag=0;
      

  8.   

    begin
      if thne
      end if;
    end;