56,677
社区成员
发帖
与我相关
我的任务
分享
-- Function: auto_i_sy()
-- DROP FUNCTION auto_i_sy();
CREATE OR REPLACE FUNCTION auto_i_sy()
RETURNS trigger AS
$BODY$
DECLARE
vsalaryid bigint ;
BEGIN
select sum(sy.salaryid) into vsalaryid from tsalary sy where sy.yueFen=NEW.zhangQi and sy.enterpriseid=NEW.enterpriseid AND sy.staffid=NEW.staffid;
update tinsurance set salaryid=vsalaryid where enterpriseid=NEW.enterpriseid AND staffid=NEW.staffid and zhangQi=NEW.zhangQi;
return null;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION auto_i_sy() OWNER TO postgres;