create or replace trigger tri_t_exgood
before insert 
on t_exgoodfor each row
begin    if inserting
   then  select in_count  from t_ingood,t_exgood
         where :new.eg_name=ig_id;
         if(in_count<2) then
         dbms_output.put_line('注意,商品库存数量将耗尽!');
         end if;
   end if;
  
end; 

解决方案 »

  1.   

    非sqlserver,是什么数据库的?
      

  2.   

    create or replace trigger tri_t_exgood
    before insert  on t_exgood for each row
    declare
    v_count number:=0;
    begin
      if inserting then 
        --select in_count into v_count from t_ingood,t_exgood where :new.eg_name=ig_id;
        select in_count into v_count from t_ingood,t_exgood where ig_id=:new.eg_name;
        if(v_count < 2) then
     dbms_output.put_line('注意,商品库存数量将耗尽!');
        end if;
      end if;  
    end tri_t_exgood; 
    /
      

  3.   

    很明显是这句的问题:
    select in_count from t_ingood,t_exgood where :new.eg_name=ig_id;
    你select出来的in_count必须放在一个变量中。