isql(sql随处可见)触发器给出错误 [英] isql (sql anywhere) trigger gives error
问题描述
得到一个奇怪的错误未找到相关名称'Club'",但是表Club在数据库中.我认为问题出在插入值之后:
got strange error "Correlation name 'Club' not found" but the table Club is in the DB. I think the problem is after inserting the values:
ALTER TRIGGER "tg_add_club" AFTER INSERT,
UPDATE ON Club
REFERENCING NEW AS item
FOR EACH ROW
WHEN (item.address NOT IN (SELECT name FROM Place))
BEGIN
//DECLARE i_id INTEGER;
INSERT INTO Place(name)
VALUES (item.address);
//SELECT @@identity INTO i_id;
UPDATE Club SET place = (SELECT id FROM Place WHERE name=item.address)
WHERE Name = item.name; //AND Place.name = item.address;
END
我认为问题出在VALUES(项目地址)之后,但是我不确定.
I think the problem is somewhere after VALUES (item.address), but I'm not sure.
尝试了不同的方法,但是仍然没有任何效果.感谢您的阅读!
Have tried different things with it, but still nothing works. Thanks for reading!
推荐答案
问题是SET place
和WHERE Name
应该相同,否则会给我错误.现在应该可以工作:
The problem was, that the SET place
and WHERE Name
should be the same, or it would give me the error. Should work now:
更新俱乐部设置名称=(在地点名称= item.address中选择SELECT ID) 名称= item.name;
UPDATE Club SET Name = (SELECT id FROM Place WHERE name=item.address) WHERE Name = item.name;
如果是新地址,则将创建随机ID,Club从存储所有地址的表中获取ID.
If it's new address, then the random id is made and Club gets the id from the table, where all the addresses are stored.
这篇关于isql(sql随处可见)触发器给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!