PostgreSQL 触发器和存储过程未启动
我的目标是在表中的行发生更新之前计算并保留某个值。
我创建了触发器和函数,没有收到任何错误,但函数似乎没有启动。我哪里出错了?
procedure
CREATE or REPLACE FUNCTION foo() returns trigger as
$BODY$
DECLARE
BEGIN
NEW.geomtry := st_transform(st_pointfromtext('POINT(' || NEW.af_lon || ' ' || NEW.af_lat || ')', 4326), 32643);
return NEW;
END;
$BODY$
language plpgsql;
在更新发生之前触发该方法的触发器
CREATE TRIGGER foo_trigger BEFORE UPDATE ON foo_table FOR EACH ROW EXECUTE PROCEDURE foo();
My goal is to compute and persist a certain value before an update happens to a row in my table.
I created the trigger and the function, I don't get any errors but the function doesn't seem to be kicking in. Where am I going wrong?
The procedure
CREATE or REPLACE FUNCTION foo() returns trigger as
$BODY$
DECLARE
BEGIN
NEW.geomtry := st_transform(st_pointfromtext('POINT(' || NEW.af_lon || ' ' || NEW.af_lat || ')', 4326), 32643);
return NEW;
END;
$BODY$
language plpgsql;
The trigger to trigger the method before an update happens
CREATE TRIGGER foo_trigger BEFORE UPDATE ON foo_table FOR EACH ROW EXECUTE PROCEDURE foo();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在存储过程中拼写的“几何”不正确。确保它在表和存储过程中拼写一致。
You spelled "geometry" incorrectly in your stored proc. Make sure it is spelled consistently in your table and stored proc.