zoukankan      html  css  js  c++  java
  • mysql 创建存储过程

    mysql 创建存储过程 

    实例一:

    CREATE PROCEDURE cp_test()
    BEGIN
    
    declare a int;
    declare b int;
    
    set a=1;
    set b=2;
    
    select a,b;
    
    
    END

    实例二:

    CREATE PROCEDURE cp_Stat_VideoData()
    BEGIN
    
    declare yestday date;
    set yestday=date(date_add(NOW(), interval -1 day));
    if exists(select Id from Stat_VideoHits where AddDate = yestday)
    THEN
    delete from Stat_VideoHits where AddDate=yestday;
    end if;
    
    insert into Stat_VideoHits(Id,VideoId,Times,AddDate) select uuid(), VideoId,COUNT(1),AddDate from Coll_VideoHits 
    where AddDate = yestday
    group by VideoId;
    
    DELETE from Sum_VideoHits;
    
    insert into Sum_VideoHits(Id,VideoId,Times,UpdateDate) select uuid(),VideoId,sum(Times),now() from Stat_VideoHits 
    group by VideoId;
    
    delete from Coll_VideoHits WHERE AddDate<date_add(yestday, interval -3 day);
    
    
    END
  • 相关阅读:
    ngTemplate
    HTML5
    angular指令
    todo
    调试语句
    route attribute in webapi
    ngModelController
    angularjs中的事件
    删除IE input 下的小叉叉
    《python网络数据采集》读后感 第八章:自然语言处理
  • 原文地址:https://www.cnblogs.com/zoro-zero/p/6511086.html
Copyright © 2011-2022 走看看