有没有办法解决这个错误,或者我的代码中缺少一些东西,我正在学习postgresql
并且我一直在研究table inheritance and triggers
我有两个表,temporary_object table
并且persons table
persons表继承了临时对象具有的所有属性,然后我有在persons表上创建了一个触发器函数,它检查记录与我尝试运行时出现的问题相同id before updating
,我得到了这些tables
insert query
errors
ERROR: end of trigger procedure achieved without RETURN
CONTEXT: function PL / pgSQL muli_function ()
ERROR: end of trigger procedure achieved without RETURN
SQL-state: 2F005
Context: The PL / pgSQL muli_function ()
这是通过插入查询
INSERT INTO persons (id, time_create, time_dead, First_name, Last_name) values (1, '2011-10-07 15:25:00 EDT', '2011-10-07 3:25 PM EDT', 'sathiya', 'james');
这是我的触发功能并自行触发
CREATE FUNCTION muli_function() RETURNS trigger AS '
BEGIN
IF tg_op = ''UPDATE'' THEN
UPDATE persons
SET time_dead = NEW.time_create
Where
id = NEW.id
AND time_dead IS NULL
;
RETURN new;
END IF;
END
' LANGUAGE plpgsql;
CREATE TRIGGER sofgr BEFORE INSERT OR DELETE OR UPDATE
ON persons FOR each ROW
EXECUTE PROCEDURE muli_function();
这是我的两个表查询
CREATE TABLE temporary_object
(
id integer NOT NULL,
time_create timestamp without time zone NOT NULL,
time_dead timestamp without time zone,
PRIMARY KEY (id, time_create)
);
CREATE TABLE persons
(
First_Name text,
Last_Name text
)
INHERITS (temporary_object);