Mercurial > gemma
view schema/updates/1101/01.improve_del_import.sql @ 5560:f2204f91d286
Join the log lines of imports to the log exports to recover data from them.
Used in SR export to extract information that where in the meta json
but now are only found in the log.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 09 Feb 2022 18:34:40 +0100 |
parents | 52f7264265bb |
children |
line wrap: on
line source
CREATE OR REPLACE FUNCTION import.del_import(imp_id int) RETURNS void AS $$ DECLARE tmp RECORD; BEGIN FOR tmp IN SELECT relation, array_agg(key) AS keys FROM import.track_imports WHERE import_id = imp_id AND NOT deletion GROUP BY relation LOOP EXECUTE format('DELETE FROM %s WHERE id = ANY($1)', tmp.relation) USING tmp.keys; END LOOP; END; $$ LANGUAGE plpgsql;