acq.fund_allocation_percent
|
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: |
Columns
| Column | Type | Nullable | Default | Notes |
|---|---|---|---|---|
id PK |
|
No |
nextval('acq.fund_allocation_percent_id_seq'::regclass) |
|
funding_source FK |
|
No |
||
org FK |
|
No |
||
fund_code |
|
Yes |
||
percent |
|
No |
||
allocator FK |
|
No |
||
note |
|
Yes |
||
create_time |
|
No |
now() |
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 |
|
Indexes
| Index | Method | Definition |
|---|---|---|
|
btree |
|
|
btree |
|
Triggers
| Trigger | Timing | Event | Level | Function |
|---|---|---|---|---|
|
BEFORE |
INSERT OR UPDATE |
ROW |
|
|
AFTER |
INSERT OR UPDATE |
ROW |
Trigger Bodies
acq_fund_alloc_percent_val_trig
Function: acq.fund_alloc_percent_val()
Timing: BEFORE INSERT OR UPDATE ROW
|
This trigger modifies the row before it is written (returns a modified |
--
DECLARE
--
dummy int := 0;
--
BEGIN
SELECT
1
INTO
dummy
FROM
acq.fund
WHERE
org = NEW.org
AND code = NEW.fund_code
LIMIT 1;
--
IF dummy = 1 then
RETURN NEW;
ELSE
RAISE EXCEPTION 'No fund exists for org % and code %', NEW.org, NEW.fund_code;
END IF;
END;
acqfap_limit_100_trig
Function: acq.fap_limit_100()
Timing: AFTER INSERT OR UPDATE ROW
DECLARE
--
total_percent numeric;
--
BEGIN
SELECT
sum( percent )
INTO
total_percent
FROM
acq.fund_allocation_percent AS fap
WHERE
fap.funding_source = NEW.funding_source;
--
IF total_percent > 100 THEN
RAISE EXCEPTION 'Total percentages exceed 100 for funding_source %',
NEW.funding_source;
ELSE
RETURN NEW;
END IF;
END;