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

    drop procedure count_points;
    create procedure count_points()
    begin
        declare n_Latitude double;
        declare n_Longitude double;
        declare isExist int;
        declare countExist int default 0;
        declare n_cellname varchar(255);
    
        -- 定义游标遍历时,作为判读是否遍历完全被记录的标记
        declare num int default 0;
        declare lat_long_list CURSOR FOR select Longitude,Latitude,cellname from         
        table_name;
    
        -- 声明当游标遍历完全被记录后将标志变量置成某个值
        declare continue handler for sqlstate '02000' set num=1;
        truncate table t_cell_name;
    
        -- 打开游标
        open lat_long_list;
    
        -- 将游标中的值赋值给变量,要注意sql结果列的顺序
        fetch lat_long_list into n_Longitude,n_Latidute,n_cellname;
    
        -- 打印值
        -- select n_Longitude,n_Latitude;
    
        -- while循环
        while num<>1 do
        select  count(*) into isExist from tableb;
        if isExist = 1 then
            set countExist = countExist +1;
            insert into t_cell_name(cellname) values(n_cellname);
        end if;
        
        -- 循环变量下一条数据,将游标中的值赋值给变量,要注意sql结果列的顺序
        fetch lat_long_list into n_Longitude,n_Latitude,n_cellname;
    
        end while;
    
        --  关闭游标
        close lat_long_list;
    
        -- 打印值
        select countExist;
    end
  • 相关阅读:
    Variant 数组
    socket c/s分佈式編程
    多線程幾個方法說明
    hash表的使用
    MIS系统权限控制的一个简便方法
    git 使用总结
    让 VAGRANT 启动并运行起来
    深入理解 Laravel 中 config 配置加载原理
    Vagrant入门
    php开发APP接口(总结一)
  • 原文地址:https://www.cnblogs.com/nizuimeiabc1/p/11031056.html
Copyright © 2011-2022 走看看