PG存储过程是什么
发表于:2025-02-08 作者:千家信息网编辑
千家信息网最后更新 2025年02月08日,这篇文章主要讲解了"PG存储过程是什么",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"PG存储过程是什么"吧!-- 删除函数drop function
千家信息网最后更新 2025年02月08日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安全错误
数据库的锁怎样保障安全
软件开发团队赚钱吗
英文通知网络安全活动作文
教育类软件开发流程
两台wincc服务器如何同步
数据库全文
杭州美创科技网络安全工程师
国家网络安全局现任局长是谁
阿里云服务器已锁定
拉鹏网络技术有限公司
SIP服务器出错什么意思
windows7数据库怎么安装
这么查网贷个人大数据库
服务器 耗电
sql如何添加数据库文件
我的世界如何重建服务器
市政网络安全设计单位名单
云服务器中安装python
清北应届生软件开发实力
远程服务器和web服务器一样吗
加强网络安全的提案
软件开发前端是属于互联吗
邮件服务器api管理
软件开发部的绩效工资
阿里云服务器已锁定
战神复古手游服务器
在数据库的三级模式有几个
九通服务器是什么
程序员数据库面试问题
数据库中的双精度类型是什么
mc服务器插件去哪购买