LP#1596595: Stamping upgrade scripts for hold targeter refactoring
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 1020.schema.batch_settings_by_org.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('1020', :eg_version);
4
5 CREATE OR REPLACE FUNCTION actor.org_unit_ancestor_setting_batch_by_org(
6     setting_name TEXT, org_ids INTEGER[]) 
7     RETURNS SETOF actor.org_unit_setting AS 
8 $FUNK$
9 DECLARE
10     setting RECORD;
11     org_id INTEGER;
12 BEGIN
13     /*  Returns one actor.org_unit_setting row per org unit ID provided.
14         When no setting exists for a given org unit, the setting row
15         will contain all empty values. */
16     FOREACH org_id IN ARRAY org_ids LOOP
17         SELECT INTO setting * FROM 
18             actor.org_unit_ancestor_setting(setting_name, org_id);
19         RETURN NEXT setting;
20     END LOOP;
21     RETURN;
22 END;
23 $FUNK$ LANGUAGE plpgsql STABLE;
24
25 COMMIT;
26