PG存储过程是什么
发表于:2025-11-19 作者:千家信息网编辑
千家信息网最后更新 2025年11月19日,这篇文章主要讲解了"PG存储过程是什么",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"PG存储过程是什么"吧!-- 删除函数drop function
千家信息网最后更新 2025年11月19日PG存储过程是什么
这篇文章主要讲解了"PG存储过程是什么",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"PG存储过程是什么"吧!
-- 删除函数drop function if exists upgrade_task_device(integer);create or replace function upgrade_task_device(exec_way integer) returns integer as$$declare cron_prefix varchar default '0 */'; cron_suffix varchar default ' * * * ?'; cron_period varchar; tmp_cron_period integer; cron_exp varchar default ''; cur_row record; ret integer default 0; task_cursor cursor (exec_way integer) for select t.* from task t where t.execution_way = exec_way;begin -- task表如果 time_period > 59,设值为59 update task set time_period = 59 where time_period is not null and time_period > 59; open task_cursor(exec_way); loop fetch task_cursor into cur_row; exit when not FOUND; -- 定时执行|立即执行 if cur_row.execution_way = 1 or cur_row.execution_way = 2 then update task_device set task_type = cur_row.task_type, task_name = cur_row.task_name, retry = cur_row.retry, start_time=cur_row.start_time, end_time=cur_row.end_time, -- 执行方式全部更改为'周期执行' execution_way = 3, create_user_id=cur_row.create_user_id where task_id = cur_row.id and time_rule is null; elsif cur_row.execution_way = 3 then -- 周期执行 tmp_cron_period = cur_row.time_period; if tmp_cron_period > 59 then tmp_cron_period = 59; end if; -- 转换为字符串进行拼接 cron_period = TRIM(to_char(tmp_cron_period, '99')); -- cron 拼接 cron_exp = cron_prefix || cron_period || cron_suffix; update task_device set task_type = cur_row.task_type, task_name = cur_row.task_name, retry = cur_row.retry, start_time=cur_row.start_time, end_time=cur_row.end_time, time_rule=cron_exp, -- 执行方式全部更改为'周期执行' execution_way = 3, create_user_id=cur_row.create_user_id where task_id = cur_row.id and time_rule is null; end if; end loop; close task_cursor; ret = 1; return ret;end;$$ language plpgsql;-- 分别处理定时执行、周期执行、立即执行select upgrade_task_device(1);select upgrade_task_device(2);select upgrade_task_device(3);-- 删除函数drop function if exists upgrade_task_device(integer);
感谢各位的阅读,以上就是"PG存储过程是什么"的内容了,经过本文的学习后,相信大家对PG存储过程是什么这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
过程
存储
周期
学习
内容
函数
方式
字符
字符串
就是
思路
情况
文章
更多
知识
知识点
篇文章
跟着
问题
实践
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
数据库优化用什么软件
加强网络安全意识培养
软件开发专用发票
软件开发 企业笔试题目
用友软件的数据库在哪儿
数据库怎么算
jdbc中的数据库驱动程序
数据库文件分成三类
2018年网络安全损失
阿里云 服务器配置
肇庆通讯软件开发厂家直销
怀旧服服务器开启访问限制
服务器管理监控系统
数据库变更说明
小蛙幻塔服务器账号
电影院票务系统数据库的项目介绍
新浪网络技术股份有限公司英文
2018 网络安全 试卷5
三国杀十周年服务器是什么
社会科学数据库
数据库实现的详细描述
无锡无边网络技术
软件开发中类是什么意思
数据库文件分成三类
广西互联网科技奖
多服务器网站吗
pc上位机软件开发
专业软件开发设施价格优惠
网络安全专项活动标题
云南服务器硬盘性能