【发布时间】:2020-04-16 20:26:56
【问题描述】:
我想创建一个触发器,该触发器将执行一个存储过程,该过程将更新几行。当我使用 Call 方法对其进行测试时,程序可以工作,但触发器无法找到它,错误是函数不存在。 这是我的程序
create or replace PROCEDURE update_reg_location(latitude text, longitude text,userid int)
LANGUAGE SQL
AS $$
update users set reg_lat=latitude , reg_lon=longitude where id =userid
$$;
当我使用时
call update_reg_location('123','234',1)
从 IDE 中它工作正常并且记录已更新,但是当我在触发器中使用它时它不会编译。
CREATE TRIGGER update_reg_location
after INSERT ON users
FOR EACH ROW
EXECUTE PROCEDURE update_reg_location('123','234',1);
当我想像这样获取插入行的新值时也会出错
CREATE TRIGGER update_reg_location
after INSERT ON users
FOR EACH ROW
EXECUTE PROCEDURE update_reg_location(new.lat,new.lon,1);
得到错误为 在新处或附近出现语法错误。 (new.lat,new.lon,1);在这一行
【问题讨论】:
标签: postgresql stored-procedures database-trigger