Interbase触发器,错误在哪里? (50分)

  • 主题发起人 主题发起人 yifeibbs
  • 开始时间 开始时间
Y

yifeibbs

Unregistered / Unconfirmed
GUEST, unregistred user!
触发器有些错误,不能建立,错在哪里?

SET TERM !! ;
CREATE TRIGGER ip_store FOR ipsb
AFTER insert AS
DECLARE VARIABLE sid char(2);
BEGIN
select sid from ipsh where id=new.id into :sid;
if exists (select * from onhand where sid=:sid and pid=new.pid) then
update onhand
set oh4=oh4+amount4,
oh6=oh6+amount6,
oh8=oh8+amount8,
oh10=oh10+amount10,
oh12=oh12+amount12,
oh14=oh14+amount14,
oh16=oh16+amount16
where sid=:sid and pid=new.pid
else
INSERT INTO onhand(sid, pid, oh4, oh6, oh8, oh10, oh12, oh14, oh16)
VALUES (:sid,new.pid,new.oh4,new.oh6,new.oh8,new.oh10,new.oh12,new.oh14,new.oh16);
END !!

SET TERM ; !!
 
不能修改分值真郁闷
 
Interbase没用过,看你郁闷的!帮你提下,加分就重开贴
 
if () then //()必须
begin //begin end 必须即使只有一行
end else
begin
end //此处不能有;
 
看看速达吧!!!!
 
这个困扰我8个月的问题终于解决了,多谢各位。
错误太多我不一一指出,主要靠铁盒子兄了,正确形式如下:

SET TERM !! ;
CREATE TRIGGER ip_store FOR ipsb
AFTER insert AS
DECLARE VARIABLE sid char(2);
BEGIN
select sid from ipsh where id=new.id into :sid;
if (exists (select * from onhand where sid=:sid and pid=new.pid)) then
begin
update onhand
set oh4=oh4+new.amount4,
oh6=oh6+new.amount6,
oh8=oh8+new.amount8,
oh10=oh10+new.amount10,
oh12=oh12+new.amount12,
oh14=oh14+new.amount14,
oh16=oh16+new.amount16
where sid=:sid and pid=new.pid;
end
else begin
INSERT INTO onhand(sid, pid, oh4, oh6, oh8, oh10, oh12, oh14, oh16)
VALUES (:sid,new.pid,new.amount4,new.amount6,new.amount8,new.amount10,new.amount12,new.amount14,new.amount16);
end
END !!

SET TERM ; !!
 
后退
顶部