Org unit setting value lookup for batches of org units, instead of the
traditional batches by setting name.
Perl live test included.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
--- /dev/null
+BEGIN;
+
+CREATE OR REPLACE FUNCTION actor.org_unit_ancestor_setting_batch_by_org(
+ setting_name TEXT, org_ids INTEGER[])
+ RETURNS SETOF actor.org_unit_setting AS
+$FUNK$
+DECLARE
+ setting RECORD;
+ org_id INTEGER;
+BEGIN
+ /* Returns one actor.org_unit_setting row per org unit ID provided.
+ When no setting exists for a given org unit, the setting row
+ will contain all empty values. */
+ FOREACH org_id IN ARRAY org_ids LOOP
+ SELECT INTO setting * FROM
+ actor.org_unit_ancestor_setting(setting_name, org_id);
+ RETURN NEXT setting;
+ END LOOP;
+ RETURN;
+END;
+$FUNK$ LANGUAGE plpgsql STABLE;
+
+COMMIT;
+