0
當一行更新觸發器將更改該行時,我創建了一個觸發器。當我更新一列時,我收到一個錯誤。我該如何解決?Postgresql觸發器示例
ERROR: stack depth limit exceeded HINT: Increase the configuration parameter "max_stack_depth" (currently 2048kB), after ensuring the platform's stack depth limit is adequate.
CREATE OR REPLACE FUNCTION ynt_call()
RETURNS TRIGGER AS $$
BEGIN
IF TG_OP = 'UPDATE' THEN
UPDATE ynt.a_test SET date_time = now();
END IF;
RETURN NEW;
END;
$$ language 'plpgsql';
CREATE TRIGGER update_call AFTER UPDATE ON ynt.a_test FOR EACH ROW EXECUTE PROCEDURE ynt_call();
看起來您處於無限循環狀態。要更改觸發器中的值,請使用** new **和** old **關鍵字。 – ChrisB
您應該仔細查看手冊中的示例:https://www.postgresql.org/docs/current/static/plpgsql-trigger.html#PLPGSQL-TRIGGER-EXAMPLE –