Postgresql 触发器未更新 - 达到堆栈深度限制
每个人! 我想做一个非常简单的触发器,看看某些条件是否为 0,它们在同一张表上设置为 false,购买时我做错了,它没有更新,
CREATE or REPLACE FUNCTION chequeo_datos() RETURNS trigger AS $$
BEGIN
IF NEW.val_cuota = 0 or NEW.val_pat = 0 THEN
UPDATE habitat SET status=False;
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER chequeo_datos AFTER INSERT OR UPDATE ON public.habitat
FOR EACH ROW EXECUTE FUNCTION chequeo_datos();
它给了我这个错误:“达到堆栈深度限制”。 你能告诉我我做错了什么吗?
everyone!
i want to do a very simple trigger that sees if some conditionals are 0 they set false on the same table, buy i am doing wrong and it s not updating
CREATE or REPLACE FUNCTION chequeo_datos() RETURNS trigger AS $
BEGIN
IF NEW.val_cuota = 0 or NEW.val_pat = 0 THEN
UPDATE habitat SET status=False;
END IF;
RETURN NEW;
END;
$ LANGUAGE plpgsql;
CREATE TRIGGER chequeo_datos AFTER INSERT OR UPDATE ON public.habitat
FOR EACH ROW EXECUTE FUNCTION chequeo_datos();
it gives me this error : "stack depth limit reached".
could you tell me what i am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要更新表,而是将新值分配给记录的列:
为此,您需要一个
BEFORE
触发器:Don't UPDATE the table, assign the new value to the record's column:
For that to work, you need a
BEFORE
trigger: