(编辑:jimmy 日期: 2024/12/25 浏览:2)
为待模糊查询的表创建函数
CREATE OR REPLACE FUNCTION fuzzy_query_func() RETURNS TRIGGER AS $$ BEGIN INSERT INTO fuzzy_query(id,name,address,table_name) VALUES (new.id, NEW.name,NEW.address,TG_TABLE_NAME); RETURN NEW; END; $$ LANGUAGE plpgsql;
删除触发器 第一步:创建函数
CREATE OR REPLACE FUNCTION fuzzy_query_del() RETURNS trigger AS $$ BEGIN DELETE from fuzzy_query where id = OLD.id; RETURN OLD; END; $$ LANGUAGE plpgsql VOLATILE
CREATE OR REPLACE FUNCTION fuzzy_query_update() RETURNS trigger AS $$ BEGIN UPDATE fuzzy_query SET name = NEW.name,address = NEW.address where id = NEW.id; RETURN NEW; END; $$ LANGUAGE plpgsql VOLATILE