update post-pbf-import.sql.example

pull/120/head
vikineema 2022-04-28 19:15:40 +03:00
rodzic 007ffd6da9
commit 901376e1de
1 zmienionych plików z 20 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,20 @@
CREATE OR REPLACE FUNCTION clean_tables() RETURNS void AS
$BODY$
DECLARE osm_tables CURSOR FOR
SELECT table_name
FROM information_schema.tables
WHERE table_schema='public'
AND table_type='BASE TABLE'
AND table_name LIKE 'osm_%';
BEGIN
FOR osm_table IN osm_tables LOOP
EXECUTE 'DELETE FROM ' || quote_ident(osm_table.table_name) || ' WHERE osm_id IN (
SELECT DISTINCT osm_id
FROM ' || quote_ident(osm_table.table_name) || '
LEFT JOIN clip ON ST_Intersects(geometry, geom)
WHERE clip.ogc_fid IS NULL)
;';
END LOOP;
END;
$BODY$
LANGUAGE plpgsql;