actor.org_unit
|
Hub Table: This table is referenced by 137 foreign keys across the database. It is a central structural table — changes to rows here have wide-reaching effects. Consider all dependent schemas before deleting or modifying rows. |
|
Data-Modifying Triggers: This table has BEFORE ROW trigger(s) that modify row data before write. Values you INSERT or UPDATE may differ from what is actually stored. See the Triggers section below. |
|
Deferrable Constraints: The following FK constraints are deferrable — they are checked at transaction end, not statement end: |
|
Trigger Side Effects: Writing to this table automatically triggers writes to other tables:
|
Columns
| Column | Type | Nullable | Default | Notes |
|---|---|---|---|---|
id PK |
|
No |
nextval('actor.org_unit_id_seq'::regclass) |
|
parent_ou FK |
|
Yes |
||
ou_type FK |
|
No |
||
ill_address FK |
|
Yes |
||
holds_address FK |
|
Yes |
||
mailing_address FK |
|
Yes |
||
billing_address FK |
|
Yes |
||
shortname |
|
No |
||
name |
|
No |
||
|
Yes |
|||
phone |
|
Yes |
||
opac_visible |
|
No |
true |
|
fiscal_calendar FK |
|
No |
1 |
Foreign Keys
| Column(s) | References | On Delete | On Update | Deferrable | Constraint |
|---|---|---|---|---|---|
|
NO ACTION |
NO ACTION |
DEFERRED |
|
|
|
NO ACTION |
NO ACTION |
DEFERRED |
|
|
|
NO ACTION |
NO ACTION |
DEFERRED |
|
|
|
NO ACTION |
NO ACTION |
DEFERRED |
|
|
|
NO ACTION |
NO ACTION |
DEFERRED |
|
|
|
NO ACTION |
NO ACTION |
DEFERRED |
|
|
|
NO ACTION |
NO ACTION |
DEFERRED |
|
Indexes
| Index | Method | Definition |
|---|---|---|
|
btree |
|
|
btree |
|
|
btree |
|
|
btree |
|
|
btree |
|
|
btree |
|
|
btree |
|
|
btree |
|
|
btree |
|
Triggers
| Trigger | Timing | Event | Level | Function |
|---|---|---|---|---|
|
BEFORE |
INSERT OR UPDATE |
ROW |
|
|
AFTER |
DELETE OR UPDATE |
ROW |
|
|
AFTER |
INSERT OR DELETE OR UPDATE |
ROW |
Trigger Bodies
actor_org_unit_parent_protect_trigger
Function: actor.org_unit_parent_protect()
Timing: BEFORE INSERT OR UPDATE ROW
|
This trigger modifies the row before it is written (returns a modified |
DECLARE
current_aou actor.org_unit%ROWTYPE;
seen_ous INT[];
depth_count INT;
BEGIN
current_aou := NEW;
depth_count := 0;
seen_ous := ARRAY[NEW.id];
IF (TG_OP = 'UPDATE') THEN
IF (NEW.parent_ou IS NOT DISTINCT FROM OLD.parent_ou) THEN
RETURN NEW; -- Doing an UPDATE with no change, just return it
END IF;
END IF;
LOOP
IF current_aou.parent_ou IS NULL THEN -- Top of the org tree?
RETURN NEW; -- No loop. Carry on.
END IF;
IF current_aou.parent_ou = ANY(seen_ous) THEN -- Parent is one we have seen?
RAISE 'OU LOOP: Saw % twice', current_aou.parent_ou; -- LOOP! ABORT!
END IF;
-- Get the next one!
SELECT INTO current_aou * FROM actor.org_unit WHERE id = current_aou.parent_ou;
seen_ous := seen_ous || current_aou.id;
depth_count := depth_count + 1;
IF depth_count = 100 THEN
RAISE 'OU CHECK TOO DEEP';
END IF;
END LOOP;
RETURN NEW;
END;
audit_actor_org_unit_update_trigger
Function: auditor.audit_actor_org_unit_func()
Timing: AFTER DELETE OR UPDATE ROW
BEGIN
INSERT INTO auditor.actor_org_unit_history ( audit_id, audit_time, audit_action, audit_user, audit_ws, id, parent_ou, ou_type, ill_address, holds_address, mailing_address, billing_address, shortname, name, email, phone, opac_visible, fiscal_calendar )
SELECT nextval('auditor.actor_org_unit_pkey_seq'),
now(),
SUBSTR(TG_OP,1,1),
eg_user,
eg_ws,
OLD.id, OLD.parent_ou, OLD.ou_type, OLD.ill_address, OLD.holds_address, OLD.mailing_address, OLD.billing_address, OLD.shortname, OLD.name, OLD.email, OLD.phone, OLD.opac_visible, OLD.fiscal_calendar
FROM auditor.get_audit_info();
RETURN NULL;
END;
proximity_update_tgr
Function: actor.org_unit_prox_update()
Timing: AFTER INSERT OR DELETE OR UPDATE ROW
BEGIN
IF TG_OP = 'DELETE' THEN
DELETE FROM actor.org_unit_proximity WHERE (from_org = OLD.id or to_org= OLD.id);
END IF;
IF TG_OP = 'UPDATE' THEN
IF NEW.parent_ou <> OLD.parent_ou THEN
DELETE FROM actor.org_unit_proximity WHERE (from_org = OLD.id or to_org= OLD.id);
INSERT INTO actor.org_unit_proximity (from_org, to_org, prox)
SELECT l.id, r.id, actor.org_unit_proximity(l.id,r.id)
FROM actor.org_unit l, actor.org_unit r
WHERE (l.id = NEW.id or r.id = NEW.id);
END IF;
END IF;
IF TG_OP = 'INSERT' THEN
INSERT INTO actor.org_unit_proximity (from_org, to_org, prox)
SELECT l.id, r.id, actor.org_unit_proximity(l.id,r.id)
FROM actor.org_unit l, actor.org_unit r
WHERE (l.id = NEW.id or r.id = NEW.id);
END IF;
RETURN null;
END;
Referenced By
The following tables have foreign keys pointing to actor.org_unit (137 referencing table(s)):
| Table | Referencing Column(s) | Referenced Column(s) | Constraint |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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