请问关于postgreSQL触发器????

9812 2003-03-18 04:58:31
我想做一个,删除主键记录。后删除所有相关外建的记录。

CREATE OR REPLACE FUNCTION siteuser_delete (integer) RETURNS TRIGGER AS '
BEGIN
Delete from link where id = $1;
END;
' LANGUAGE 'plpgsql';

CREATE TRIGGER siteuser_trigger
BEFORE DELETE ON siteuser FOR EACH ROW
EXECUTE PROCEDURE siteuser_delete (NEW.id);

可以吗???


CREATE OR REPLACE FUNCTION siteuser_delete () RETURNS TRIGGER AS '
BEGIN
Delete from link where id = NEW.id;
END;
' LANGUAGE 'plpgsql';

CREATE TRIGGER siteuser_trigger
BEFORE DELETE ON siteuser FOR EACH ROW
EXECUTE PROCEDURE siteuser_delete ();
或可不可以象oracle 那样写
CREATE TRIGGER siteuser_trigger
BEFORE DELETE ON siteuser FOR EACH ROW
BEGIN
Delete from link where id = NEW.id;
END;
...全文
32 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
MySQL
创建于2007-09-28

5.5w+

社区成员

MySQL相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2003-03-18 04:58
社区公告
暂无公告