我怎么能用Postgresql中的存储过程呢?

时间:2014-02-26 12:57:47

标签: sql postgresql stored-procedures

我计算逐渐执行此查询的坐标之间的距离。

  1. 
    
         /*insert into tmp11(select * from clients_lite where inwork > 0 limit(5000));*/
    
    

    2

    
    
         select *, cast(ATAN(SQRT(power((COS(tmp11.lat*PI()/180)*SIN(city.lon1*PI()/180-tmp11.lon*PI()/180)),2)+power((COS(city.lat1*PI()/180)
                      *SIN(tmp11.lat*PI()/180)-SIN(city.lat1*PI()/180)*COS(tmp11.lat*PI()/180)*COS(city.lon1*PI()/180-tmp11.lon*PI()/180)),2))/
                      (SIN(city.lat1*PI()/180)*SIN(tmp11.lat*PI()/180)+COS(city.lat1*PI()/180)*COS(tmp11.lat*PI()/180)*COS(city.lon1*PI()/180-tmp11.lon*PI()/180)))*6372795 as int) as distance
        into dist
        from tmp11 
        inner join  city
        on cast(ATAN(SQRT(power((COS(tmp11.lat*PI()/180)*SIN(city.lon1*PI()/180-tmp11.lon*PI()/180)),2)+power((COS(city.lat1*PI()/180)
                      *SIN(tmp11.lat*PI()/180)-SIN(city.lat1*PI()/180)*COS(tmp11.lat*PI()/180)*COS(city.lon1*PI()/180-tmp11.lon*PI()/180)),2))/
                      (SIN(city.lat1*PI()/180)*SIN(tmp11.lat*PI()/180)+COS(city.lat1*PI()/180)*COS(tmp11.lat*PI()/180)*COS(city.lon1*PI()/180-tmp11.lon*PI()/180)))*6372795 as int) between 0 and 60000
    
    

    3。   

    /*insert into clients_res(select clients.pid, clients.owner_id, dist.country, dist.city, dist.distance, clients.inwork  from clients left outer join dist on clients.pid = dist.pid);
     */
    

    4.

    {{1}}

    如何将其转换为程序?

0 个答案:

没有答案