MySQL 定時函式 過程demo

2022-09-15 15:36:24 字數 1500 閱讀 7120

-- 函式

-- 設定好時區

set time_zone = '+8:00';

-- 開啟事件排程器

set global event_scheduler = 1;

drop event if exists commission_zjdj_a_every_hours;

# 設定分隔符為 '$$'

delimiter $$

create event commission_zjdj_a_every_hours

on schedule every 1 hour starts '2018-06-24 23:59:59'

do begin

call proc_zjdj_a_commission();

end $$

# 將語句分割符設定回 ';'

delimiter ;

-- 過程

###獲取當天有效的資金對接a崗一次打包資料,保持當天乙份

drop procedure if exists proc_zjdj_a_commission;

create procedure proc_zjdj_a_commission ()

begin

delete

from

report_statistics_commission_inquiry

where

type = 2

and date_format(count_time, '%y-%m') = date_format(now(), '%y-%m');

#一次打包--> 資金對接a崗

insert into `report_statistics_commission_inquiry` (

`user_id`,

`order_code`,

`execute_time`,

`task_code`,

`count_time`,

`type`,

`ext1`,

`ext2`,

`ext3`

) select

receive_id,

order_code,

finish_time,

task_code,

now(),

2, null,

null,

null

from

my_task

where

`status` = 2

and task_code = 't_ycdb_0004'

#排除重複訂單

and order_code not in (

select

order_code

from

report_statistics_commission_inquiry

where

type = 2

) group by order_code;

end;

方法 函式 過程

封裝了一段邏輯 或者實現特定的功能 方法可以重複被呼叫 增加了 的復用 提公升開發效率 方法五要素 修飾詞 返回值型別 方法名 引數列表 main函式 public static void main string args 修飾詞 public static 返回值型別 void 表示該函式沒有返回...

mysql定時任務demo

開啟事件 set global event scheduler on 檢視事件是否開啟 show variables like event scheduler 建立表 create table test sche id int 11 not null,counts int 11 default nu...

快速排序分治函式過程總結

假設我們已經知道快速排序的演算法框架時,我們已經可以從巨集觀地去掌握快速排序演算法的思想。但是快速排序演算法的關鍵還是在於劃分操縱,同時快速排序的效能主要取決於劃分操作的好壞。快速排序分治partition過程有兩種方法 1 兩個下標分別從首 尾向中間掃瞄的方法 2 兩個指標索引一前一後逐步向後掃瞄...