首页 > 数据库技术 > 详细

postgresql function

时间:2019-10-31 14:54:53      阅读:87      评论:0      收藏:0      [点我收藏+]
CREATE or replace FUNCTION faq_sys.dataBackup() RETURNS integer AS

declare
ver numeric;
c_row faq_sys.CONTENT%ROWTYPE;
BEGIN
for c_row in (select c.id_, c.version, c.del_flg from faq_sys.content c inner join (select id_, max(version) as version from faq_sys.content group by id_) tmp_c on c.id_ = tmp_c.id_ and c.version = tmp_c.version) loop
if (c_row.del_flg) then
insert into faq_sys.temp_content(id_,version,content_no,service,title) select * from faq_sys.content where id_= c_row.id_;
delete from faq_sys.content where id_ = c_row.id_;
insert into faq_sys.temp_content_status_history(id_,content_id,status_id,user_id) select * from faq_sys.content_status_history where content_id = c_row.id_;
delete from faq_sys.content_status_history where content_id = c_row.id_;
end if;
end loop;
return 1;
END;

LANGUAGE ‘plpgsql‘;

postgresql function

原文:https://www.cnblogs.com/taobr/p/11771141.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!