У меня есть таблица business_locations
со столбцом местоположения postGIS, и я пытаюсь получить строки, которые находятся в ограничивающей рамке (аргументы функции).
Я пытаюсь запустить эту функцию в Хасуре:
CREATE OR REPLACE FUNCTION search_businesses_near_project(lngW integer, latS integer, lngE integer, latN integer)
RETURNS SETOF business_locations AS $$
SELECT A.location, A.route, A.locality, A.administrative_area_level_1, A.administrative_area_level_2, A.country, A.business_id
FROM business_locations A where ST_Intersects(A.location::geography, ST_MakeEnvelope(lngW, latS, lngE, latN, 4326)::geography, 4326)
$$ LANGUAGE sql STABLE;
Возвращена ошибка:
{
"internal": {
"statement": "CREATE OR REPLACE FUNCTION search_businesses_near_project(project_location geography, lngW integer, latS integer, lngE integer, latN integer)\r\nRETURNS SETOF business_locations AS $$\r\n SELECT A.location, A.route, A.locality, A.administrative_area_level_1, A.administrative_area_level_2, A.country, A.business_id\r\n FROM business_locations A where ST_Intersects(project_location, ST_MakeEnvelope(lngW, latS, lngE, latN, 4326)::geography, 4326)\r\n$$ LANGUAGE sql STABLE;",
"prepared": false,
"error": {
"exec_status": "FatalError",
"hint": "No function matches the given name and argument types. You might need to add explicit type casts.",
"message": "function st_intersects(geography, geography, integer) does not exist",
"status_code": "42883",
"description": null
},
"arguments": []
},
"path": "$.args[0].args",
"error": "query execution failed",
"code": "postgres-error"
}