-- -- workflow__delete_cases/1 -- create or replace function workflow__delete_cases( character varying ) returns int4 as $$ declare delete_cases__workflow_key alias for $1; case_rec record; begin for case_rec in select case_id from wf_cases where workflow_key = delete_cases__workflow_key LOOP PERFORM workflow_case__delete(case_rec.case_id); end loop; return 0; end;$$ language plpgsql;