用个包Package,在里面些个过程即可!

解决方案 »

  1.   

    你这个要求不能用简单sql实现,需要用plsql处理。
    declare
    newval number(10,2);
    begin
        begin
            select ACTIVEQUA-"+ornum+" 
            into newval
            from ware_res 
            where resid='004215';
        exception when no_data_gound then
            Raise_application_error(-20001,'no_data_found');
        end;
        if newval < 0 then 
            Raise_application_error(-20002,'error,allready < 0 ');
        else
            update ware_res set ACTIVEQUA=ACTIVEQUA-"+ornum+" where resid='004215'
        end if;
    end;如果不需要错误提示一个sql可以实现小于0时不更新,只需要增加一个where条件。:)
      

  2.   

    怎么写呀,最好能用java写的。
      

  3.   

    老兄,刚刚看到你给你的回复,非常感谢,你说“如果不需要错误提示一个sql可以实现小于0时不更新,只需要增加一个where条件。:)”,那该怎么写呀?
      

  4.   

    create trigger test_tri
    before update on ware_res
    for each row 
    begin
    if :new.ACTIVEQUA-ornum<=0 then
    raise_application_error(-20001,'出错');
    end if;
    end;
    /