oracle 之 定时任务,存储过程和游标等语法案例
--定时任务 declare job20 number; begin sys.dbms_job.submit(job20,'test1;',sysdate,'sysdate+1'); end; --存储过程 create or replace procedure test3 as xh_zgid varchar(50); xh_zggh varchar(50); xh_xm varchar(50); xh_grdh varchar(50); xh_count int; xh_dxxh int; xh_zfqnr varchar(100); --游标 CURSOR z1 is select zgid,zggh,xm,grdh from RSGL_ZGDA where zxpb=0 and (rdsj is not null )and zxpb=0 AND to_char(rdsj,'yyyy')!='0001' and (to_char(rdsj,'MM-dd')) = (to_char(sysdate,'MM-dd')); begin select NR into xh_zfqnr from OA_ZFQ where zfqid='DYSR'; select to_number(dqz) into xh_dxxh from xt_xhb where bm='SMS_DAIFASONG_DX'; dbms_output.put_line(xh_dxxh); open z1; loop fetch z1 into xh_zgid,xh_zggh,xh_xm,xh_grdh; if z1 %notfound then exit;end if; select count(*) into xh_count from BirthDayTip_jl where zgid=xh_zgid and jlsj=to_char(sysdate,'yyyy/MM/dd'); dbms_output.put_line(xh_count); if xh_count<1 then xh_dxxh:=xh_dxxh+1; insert into BirthDayTip_jl(zgid,phone,Jlsj) values(xh_zgid,xh_grdh,to_char(sysdate,'yyyy/MM/dd')); insert into sms_daifasong_dx(WEIYIBM,FASONGR,FASONGSJ,DUANXINNR,FASONGLX,SHOUJIHM) values(xh_dxxh,xh_xm,sysdate,xh_zfqnr,'3',xh_grdh); dbms_output.put_line(xh_dxxh); dbms_output.put_line(xh_xm); dbms_output.put_line(sysdate); dbms_output.put_line(xh_zfqnr); dbms_output.put_line(xh_grdh); end if; end loop; close z1; update xt_xhb set dqz=to_char((xh_dxxh)) where bm='SMS_DAIFASONG_DX'; end; --执行存储过程 begin test3; commit; end;
学到的语法规范:
--查询语句赋值时
select 字段名 into 变量名 from 表 where 条件
--变量名计算时
变量名:=变量名 运算符 值(变量名+1)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现