view schema/updates/1008/01.import-delete.sql @ 5677:a57be8bfb6ea sr-v2

More suited file names.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 11 Feb 2024 09:51:21 +0100
parents 4f2f34f5d14d
children
line wrap: on
line source

DROP FUNCTION  import.del_import();

CREATE OR REPLACE FUNCTION import.del_import(imp_id int) RETURNS void AS
$$
DECLARE
    tmp RECORD;
BEGIN
    FOR tmp IN
        SELECT * FROM import.track_imports WHERE import_id = imp_id AND NOT deletion
    LOOP
        EXECUTE format('DELETE FROM %s WHERE id = $1', tmp.relation) USING tmp.key;
    END LOOP;
END;
$$
LANGUAGE plpgsql;