MySQL定时执行存储过程
1,run--cmd-cd C:Program FilesMySQLMySQL Server 5.5bin 2, mysql -uXXXX -pXXXXXX 3, SHOW FULL PROCESSLISTG 4,设置sheduler SET GLOBAL event_scheduler = ON; SET @@global.event_scheduler = ON; SET GLOBAL event_scheduler = 1; SET @@global.event_
1,run-->cmd->cd C:Program FilesMySQLMySQL Server 5.5bin
2, mysql -uXXXX -pXXXXXX
3, SHOW FULL PROCESSLISTG
4,设置sheduler
SET GLOBAL event_scheduler = ON;
SET @@global.event_scheduler = ON;
SET GLOBAL event_scheduler = 1;
SET @@global.event_scheduler = 1;
Similarly, any of these 4 statements can be used to turn off the Event Scheduler:
SET GLOBAL event_scheduler = OFF;
SET @@global.event_scheduler = OFF;
SET GLOBAL event_scheduler = 0;
SET @@global.event_scheduler = 0;
5,create procedure
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `Get_Info_Every_Day`()
BEGIN
Declare pIntSumTotalAction int;
Declare pIntSumNoduedate int;
Declare pIntSumClosed int;
Declare pIntSumForinfo int;
Declare pIntSumOverdue int;
Declare pIntSumTBDin1Week int;
Declare pIntSumTBDafter1Week int;
Declare pIntSumPendingJPMO int;
Declare pIntSumEPS int;
Declare pIntSumWCI int;
Declare pIntSumOnTimeClosed int;
Declare pIntTotal int; ##统计的时候所有的action items
Declare strStatus varchar(40);
Declare dDuedate datetime;
Declare dClosedDate datetime;
Declare nOverdue int;
Declare nCountOnTime int; ##nIsOnTime count(*)数量
declare fetchSeqOk boolean; ## define the flag for loop judgement
/*
Declare my_cursor cursor for select b.status,b.duedate,b.closedate,datediff(now(),b.duedate) as overdue,
b.fk_actionitem from actionitem a,actionitemdetail b where a.id_actionitem=b.fk_actionitem and a.finishdate=0
and status'forinfo' and (actionby like '%WEC%' or actionby like '%Consortium%' );
*/
Declare my_cursor cursor for select b.status,b.duedate,b.closedate,datediff(now(),b.duedate) as overdue
from actionitem a,actionitemdetail b where a.id_actionitem=b.fk_actionitem and a.finishdate=0
and status'forinfo' and (actionby like '%WEC%' or actionby like '%Consortium%' );
Declare my_cursor2 cursor for select cast(count(*) as UNSIGNED) as lnOnTimeClosedAI from actionitemdetail
where datediff(now(),duedate)=0
and (actionby like '%WEC%' or actionby like '%Consortium%' )
and status='Closed' and datediff(closedate,duedate)
declare continue handler for not found set fetchSeqOk = true;
set pIntSumTotalAction=0;
set pIntSumNoduedate=0;
set pIntSumClosed=0;
set pIntSumForinfo=0;
set pIntSumOverdue=0;
set pIntSumTBDin1Week=0;
set pIntSumTBDafter1Week=0;
set pIntSumPendingJPMO=0;
set pIntSumEPS=0;
set pIntSumWCI=0;
set fetchSeqOk = false;
/*
declare continue handler for NOT FOUND set fetchSeqOk = true;
#define the continue handler for not found flag
set fetchSeqOk = false;
open fetchSeqCursor;
fetchSeqLoop:Loop
fetch fetchSeqCursor into _seqname, _value;
if fetchSeqOk then
leave fetchSeqLoop;
else
select _seqname, _value;
end if;
end Loop;
close fetchSeqCursor;
*/
open my_cursor;
fetchLoop:LOOP
fetch my_cursor into strStatus,dDuedate,dClosedDate,nOverdue;
if fetchSeqOk then
leave fetchLoop;
else
if LOWER(strStatus)='open' then
case nOverdue
when isnull(nOverdue) then set pIntSumNoduedate=pIntSumNoduedate+1;
when nOverdue>0 then set pIntSumOverdue=pIntSumOverdue+1 ;
when nOverdue-7 then set pIntSumTBDin1Week=pIntSumTBDin1Week+1;
else set pIntSumTBDafter1Week=pIntSumTBDafter1Week+1;
end case;
else
case LOWER(strStatus)
when 'closed' then set pIntSumClosed=pIntSumClosed+1;
when 'forinfo' then set pIntSumForinfo=pIntSumForinfo+1;
when 'pending jpmo' then set pIntSumPendingJPMO=pIntSumPendingJPMO+1;
when 'escalated to pcc for support' then set pIntSumEPS=pIntSumEPS+1;
when 'waiting for customer input' then set pIntSumWCI=pIntSumWCI+1;
end case;
end if;
end if;
End LOOP;
close my_cursor;
set pIntTotal=pIntSumTBDafter1Week+pIntSumOverdue+pIntSumTBDin1Week+
pIntSumNoduedate+pIntSumPendingJPMO+pIntSumEPS+pIntSumWCI+pIntSumClosed;
/*** 统计从当前日期向前推7天的committed closed情况
nCountOnTime 表示count of on time closed number
*/
set fetchSeqOk = false;
open my_cursor2;
my_loop:Loop
fetch my_cursor2 into nCountOnTime;
if fetchSeqOk then
leave my_loop;
else
set pIntSumOnTimeClosed=nCountOnTime;
end if;
end Loop;
close my_cursor2;
insert into mytest(testdate)value(now());
insert into daily_statistic(Total,Open,overdue,DueWithin7Days,PTP,NoDueDate,PendingJPMO,EPS,WCI,Closed)
values(pIntTotal,pIntSumTBDafter1Week,pIntSumOverdue,pIntSumTBDin1Week,
pIntSumOnTimeClosed,pIntSumNoduedate,
pIntSumPendingJPMO,pIntSumEPS,pIntSumWCI,pIntSumClosed);
/*
insert into daily_statistic(Total,Open,overdue,DueWithin7Days,PTP,NoDueDate,PendingJPMO,EPS,WCI,Closed)values
(pIntTotal,pIntSumTBDafter1Week,pIntSumOverdue,pIntSumTBDin1Week,10,pIntSumNoduedate,
pIntSumPendingJPMO,pIntSumEPS,pIntSumWCI,pIntSumClosed);
*/
END
6,create event
use cddl;
DROP EVENT IF EXISTS e_statistics_daily;
CREATE EVENT e_statistics_daily
ON SCHEDULE EVERY 1 Day
STARTS '2013-10-18 16:45:00'
on completion preserve
DO CALL Get_Info_Every_Day();
7, testing whether it is having the value or not
select * from daily_statistic;
,
ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









MySQLは、インストールが簡単で、強力で管理しやすいため、初心者に適しています。 1.さまざまなオペレーティングシステムに適した、単純なインストールと構成。 2。データベースとテーブルの作成、挿入、クエリ、更新、削除などの基本操作をサポートします。 3.参加オペレーションやサブクエリなどの高度な機能を提供します。 4.インデックス、クエリの最適化、テーブルパーティション化により、パフォーマンスを改善できます。 5。データのセキュリティと一貫性を確保するために、バックアップ、リカバリ、セキュリティ対策をサポートします。

NAVICAT自体はデータベースパスワードを保存せず、暗号化されたパスワードのみを取得できます。解決策:1。パスワードマネージャーを確認します。 2。NAVICATの「パスワードを記憶する」機能を確認します。 3.データベースパスワードをリセットします。 4.データベース管理者に連絡してください。

NAVICATプレミアムを使用してデータベースを作成します。データベースサーバーに接続し、接続パラメーターを入力します。サーバーを右クリックして、[データベースの作成]を選択します。新しいデータベースの名前と指定された文字セットと照合を入力します。新しいデータベースに接続し、オブジェクトブラウザにテーブルを作成します。テーブルを右クリックして、データを挿入してデータを挿入します。

MySQLでテーブルをコピーするには、新しいテーブルの作成、データの挿入、外部キーの設定、インデックスのコピー、トリガー、ストアドプロシージャ、および機能が必要です。特定の手順には、同じ構造を持つ新しいテーブルの作成が含まれます。元のテーブルからデータを新しいテーブルに挿入します。同じ外部キーの制約を設定します(元のテーブルに1つがある場合)。同じインデックスを作成します。同じトリガーを作成します(元のテーブルに1つがある場合)。同じストアドプロシージャまたは関数を作成します(元のテーブルが使用されている場合)。

Passwordが暗号化された形式で保存されているため、MariadbのNavicatはデータベースパスワードを直接表示できません。データベースのセキュリティを確保するには、パスワードをリセットするには3つの方法があります。NAVICATを介してパスワードをリセットし、複雑なパスワードを設定します。構成ファイルを表示します(推奨されていない、高リスク)。システムコマンドラインツールを使用します(推奨されません。コマンドラインツールに習熟する必要があります)。

MySQLは、オープンソースのリレーショナルデータベース管理システムです。 1)データベースとテーブルの作成:createdatabaseおよびcreateTableコマンドを使用します。 2)基本操作:挿入、更新、削除、選択。 3)高度な操作:参加、サブクエリ、トランザクション処理。 4)デバッグスキル:構文、データ型、およびアクセス許可を確認します。 5)最適化の提案:インデックスを使用し、選択*を避け、トランザクションを使用します。

NAVICATがデータベースとそのソリューションに接続できない一般的な理由:1。サーバーの実行ステータスを確認します。 2。接続情報を確認します。 3.ファイアウォール設定を調整します。 4.リモートアクセスを構成します。 5.ネットワークの問題のトラブルシューティング。 6.許可を確認します。 7.バージョンの互換性を確保します。 8。他の可能性のトラブルシューティング。

NAVICATでSQLを実行する手順:データベースに接続します。 SQLエディターウィンドウを作成します。 SQLクエリまたはスクリプトを書きます。 [実行]ボタンをクリックして、クエリまたはスクリプトを実行します。結果を表示します(クエリが実行された場合)。
