actor.stat_cat

User Statistical Catagories

Local data collected about Users is placed into a Statistical Catagory. Here’s where those catagories are defined.

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.

Cascading Deletes: Deleting rows from this table will cascade to: actor.org_unit.

Deferrable Constraints: The following FK constraints are deferrable — they are checked at transaction end, not statement end: actor_stat_cat_owner_fkey, stat_cat_sip_field_fkey.

Columns

Column Type Nullable Default Notes

id PK

integer

No

nextval('actor.stat_cat_id_seq'::regclass)

owner FK

integer

No

actor.org_unit(id)

name

text

No

opac_visible

boolean

No

false

usr_summary

boolean

No

false

sip_field FK

character(2)

Yes

actor.stat_cat_sip_fields(field)

sip_format

text

Yes

checkout_archive

boolean

No

false

required

boolean

No

false

allow_freetext

boolean

No

true

Primary Key

(id)

Foreign Keys

Column(s) References On Delete On Update Deferrable Constraint

owner

actor.org_unit(id)

CASCADE

NO ACTION

DEFERRED

actor_stat_cat_owner_fkey

sip_field

actor.stat_cat_sip_fields(field)

SET NULL

CASCADE

DEFERRED

stat_cat_sip_field_fkey

Unique Constraints

  • sc_once_per_owner: (owner, name)

Indexes

Index Method Definition

stat_cat_pkey PK

btree

CREATE UNIQUE INDEX stat_cat_pkey ON actor.stat_cat USING btree (id)

sc_once_per_owner UNIQUE

btree

CREATE UNIQUE INDEX sc_once_per_owner ON actor.stat_cat USING btree (owner, name)

Triggers

Trigger Timing Event Level Function

actor_stat_cat_sip_update_trigger

BEFORE

INSERT OR UPDATE

ROW

actor.stat_cat_check()

Trigger Bodies

actor_stat_cat_sip_update_trigger

Function: actor.stat_cat_check()
Timing: BEFORE INSERT OR UPDATE ROW

This trigger modifies the row before it is written (returns a modified NEW).

DECLARE
    sipfield actor.stat_cat_sip_fields%ROWTYPE;
    use_count INT;
BEGIN
    IF NEW.sip_field IS NOT NULL THEN
        SELECT INTO sipfield * FROM actor.stat_cat_sip_fields WHERE field = NEW.sip_field;
        IF sipfield.one_only THEN
            SELECT INTO use_count count(id) FROM actor.stat_cat WHERE sip_field = NEW.sip_field AND id != NEW.id;
            IF use_count > 0 THEN
                RAISE EXCEPTION 'Sip field cannot be used twice';
            END IF;
        END IF;
    END IF;
    RETURN NEW;
END;

Referenced By

The following tables have foreign keys pointing to actor.stat_cat (3 referencing table(s)):

Table Referencing Column(s) Referenced Column(s) Constraint

actor.stat_cat_entry

stat_cat

id

actor_stat_cat_entry_stat_cat_fkey

actor.stat_cat_entry_default

stat_cat

id

stat_cat_entry_default_stat_cat_fkey

actor.stat_cat_entry_usr_map

stat_cat

id

actor_sceum_sc_fkey