是否无法使用 mycat2.0 创建存储过程

作者: z18539749496创建于 2024年6月17日更新于 2024年6月18日
标签help wanted

CREATE PROCEDURE `poly_pay_transaction_max_concurrency`() BEGIN DECLARE currentDate DATE; DECLARE endDate DATE; -- Get the start and end dates SELECT MIN(DATE(create_time)), (MAX(DATE(create_time))- INTERVAL 1 DAY) INTO currentDate, endDate FROM poly_pay_transaction; -- Create a temporary table to store the results CREATE TABLE IF NOT EXISTS poly_pay_transaction_max_concurrency ( day DATE, max_concurrency_time INT, max_concurrency INT ); -- Loop to calculate the number of active merchants for each day WHILE currentDate <= endDate DO -- Add a condition to ensure that the same date is not repeated if NOT EXISTS (SELECT 1 FROM poly_pay_transaction_max_concurrency WHERE day = currentDate) THEN INSERT INTO poly_pay_transaction_max_concurrency (day, max_concurrency_time, max_concurrency) SELECT currentDate, DATE_FORMAT(create_time,'%H') 'time node', COUNT(id) AS count FROM poly_pay_transaction WHERE DATE_FORMAT(create_time,'%Y-%m-%d') = currentDate GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') ORDER BY count DESC LIMIT 1; END IF; -- Update the date SET currentDate = currentDate + INTERVAL 1 DAY; END WHILE; -- Select the results SELECT * FROM poly_pay_transaction_max_concurrency; -- Delete the temporary table -- DROP TABLE IF EXISTS poly_pay_transaction_max_concurrency; END;

内容来源: MyCATApache/Mycat-Server