Changes between Version 2 and Version 3 of UsersWikiCheckInvalidGeometriesFromGeometryColumns


Ignore:
Timestamp:
May 8, 2011, 9:29:33 AM (13 years ago)
Author:
aperi2007
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiCheckInvalidGeometriesFromGeometryColumns

    v2 v3  
    99RETURNS VOID AS $$
    1010DECLARE
    11         sql text;
    12         sql2 text;
     11    sql text;
     12    sql2 text;
    1313    _rec1 record;
    1414    ris integer;
    1515BEGIN
    16         sql := 'DROP TABLE IF EXISTS ' || quote_ident(tabris) ||';';
     16    sql := 'DROP TABLE IF EXISTS ' || quote_ident(tabris) ||';';
    1717    execute(sql);
    1818    sql := 'CREATE TABLE ' || quote_ident(tabris) || ' (id serial, query TEXT, invalidity INTEGER);';
    19         sql := 'select ''select count(*) from '' || quote_ident(f_table_schema) || ''.'' || quote_ident(f_table_name) || '' where ST_IsValid('' || f_geometry_column || '')=false;'' as query from public.geometry_columns';
     19    execute(sql);
     20    sql := 'select ''select count(*) from '' || quote_ident(f_table_schema) || ''.'' || quote_ident(f_table_name) || '' where ST_IsValid('' || f_geometry_column || '')=false;'' as query from public.geometry_columns order by f_table_schema,f_table_name LIMIT 3';
    2021
    21         FOR _rec1 IN execute (sql)
    22                 LOOP
    23             raise notice 'executing: %', _rec1.query;
    24             execute(_rec1.query) into ris;
    25             sql := 'insert into ' || quote_ident(tabris) || ' (query, invalidity) values(' || _rec1.query || ',' || ris || ');';
    26                 END LOOP;
    27 
    28         RETURN;
     22    FOR _rec1 IN execute (sql)
     23       LOOP
     24           raise notice 'executing: %', _rec1.query;
     25           execute(_rec1.query) into ris;
     26           sql := 'insert into ' || quote_ident(tabris) || ' (query, invalidity) values(' || quote_literal(_rec1.query) || ',' || ris || ');';
     27           execute(sql);
     28       END LOOP;
     29    RETURN;
    2930END;
    3031$$ LANGUAGE 'plpgsql' STRICT;