zhuyeshen

use eepm_push;

DROP PROCEDURE IF EXISTS FountTable;
delimiter $$
create procedure FountTable()
begin
    declare TableName varchar(64);   
     
    DECLARE cur_FountTable CURSOR FOR SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_NAME LIKE \'msgfor%\';
    DECLARE EXIT HANDLER FOR not found CLOSE cur_FountTable;
    #打开游标
    OPEN cur_FountTable;
    REPEAT
     FETCH cur_FountTable INTO TableName;
     SET @SQLSTR1 = CONCAT(\'select * from \',TableName,\' where appId = \',\'\'\'\',\'cc055a4d-53b9-4cfc-9f1a-d8bad41b7502\',\'\'\'\',\' and createTime > \',\'\'\'\',\'2017-02-23 00:00:00\',\'\'\'\');
     PREPARE STMT1 FROM @SQLSTR1;
     EXECUTE STMT1;
      
     DEALLOCATE PREPARE STMT1;    
       
     UNTIL 0 END REPEAT;
  #关闭游标
  CLOSE cur_FountTable;
  
END $$
DELIMITER ;
  
call FountTable();

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-31
  • 2021-07-30
  • 2022-12-23
  • 2021-09-02
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
猜你喜欢
  • 2022-02-09
  • 2022-01-31
  • 2021-08-12
  • 2021-08-01
  • 2021-11-29
  • 2021-12-08
相关资源
相似解决方案