Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在查询中使用变量的PostgreSQL/PostGIS_Postgresql_Postgis - Fatal编程技术网

在查询中使用变量的PostgreSQL/PostGIS

在查询中使用变量的PostgreSQL/PostGIS,postgresql,postgis,Postgresql,Postgis,我正在尝试访问一个点并获取其名称。它自己的查询工作正常,但我需要将经度和纬度作为变量,因为Lng和Lat将发生变化 这就是我所拥有的 DO $$ DECLARE longitude text := -4.323966436509; latitiude text := 51.857052145748; BEGIN --RAISE NOTICE '% %', longitude, latitiude; SELECT inspectors_name as Name

我正在尝试访问一个点并获取其名称。它自己的查询工作正常,但我需要将经度和纬度作为变量,因为Lng和Lat将发生变化

这就是我所拥有的

DO $$
DECLARE
   longitude text := -4.323966436509;
   latitiude text := 51.857052145748;
BEGIN 
    --RAISE NOTICE '% %', longitude, latitiude;
    SELECT inspectors_name as Name  
    FROM ccc_transport_streets."Inspectors_Areas_polygon" 
    WHERE ST_Contains(geom, ST_Transform (ST_GeometryFromText('POINT(lonitude latitiude)',4326), 27700));
END $$;
然而,我得到的错误:-


错误:分析错误-无效几何提示:“点(lo”要创建点,请使用st_makepoint()函数。然后为点设置SRID,然后检查多边形是否包含该点

DO $$
    DECLARE
       longitude numeric := -4.323966436509;
       latitiude numeric := 51.857052145748;
    BEGIN 
        --RAISE NOTICE '% %', longitude, latitiude;
        SELECT inspectors_name as Name  
        FROM ccc_transport_streets."Inspectors_Areas_polygon" 
        WHERE ST_Contains(geom, ST_setSRID (st_makePOINT (longitude, latitiude),4326)
);
    END $$;