serial.issuance
|
Cascading Deletes: Deleting rows from this table will cascade to: serial.caption_and_pattern, serial.subscription. |
|
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('serial.issuance_id_seq'::regclass) |
|
creator FK |
|
No |
||
editor FK |
|
No |
||
create_date |
|
No |
now() |
|
edit_date |
|
No |
now() |
|
subscription FK |
|
No |
||
label |
|
Yes |
||
date_published |
|
Yes |
||
caption_and_pattern FK |
|
Yes |
||
holding_code |
|
Yes |
||
holding_type |
|
Yes |
||
holding_link_id |
|
Yes |
Foreign Keys
| Column(s) | References | On Delete | On Update | Deferrable | Constraint |
|---|---|---|---|---|---|
|
CASCADE |
NO ACTION |
DEFERRED |
|
|
|
NO ACTION |
NO ACTION |
DEFERRED |
|
|
|
NO ACTION |
NO ACTION |
DEFERRED |
|
|
|
CASCADE |
NO ACTION |
DEFERRED |
|
Check Constraints
-
issuance_holding_code_check:CHECK -
issuance_holding_code_check1:CHECK -
valid_holding_type:CHECK
Indexes
| Index | Method | Definition |
|---|---|---|
|
btree |
|
|
btree |
|
|
btree |
|
|
btree |
|
Triggers
| Trigger | Timing | Event | Level | Function |
|---|---|---|---|---|
|
AFTER |
INSERT OR UPDATE |
ROW |
Trigger Bodies
materialize_holding_code
Function: serial.materialize_holding_code()
Timing: AFTER INSERT OR UPDATE ROW
use strict;
use MARC::Field;
use JSON::XS;
if (not defined $_TD->{new}{holding_code}) {
elog(WARNING, 'NULL in "holding_code" column of serial.issuance allowed for now, but may not be useful');
return;
}
# Do nothing if holding_code has not changed...
if ($_TD->{new}{holding_code} eq $_TD->{old}{holding_code}) {
# ... unless the following internal flag is set.
my $flag_rv = spi_exec_query(q{
SELECT * FROM config.internal_flag
WHERE name = 'serial.rematerialize_on_same_holding_code' AND enabled
}, 1);
return unless $flag_rv->{processed};
}
my $holding_code = (new JSON::XS)->decode($_TD->{new}{holding_code});
my $field = new MARC::Field('999', @$holding_code); # tag doesnt matter
my $dstmt = spi_prepare(
'DELETE FROM serial.materialized_holding_code WHERE issuance = $1',
'INT'
);
spi_exec_prepared($dstmt, $_TD->{new}{id});
my $istmt = spi_prepare(
q{
INSERT INTO serial.materialized_holding_code (
issuance, subfield, value
) VALUES ($1, $2, $3)
}, qw{INT CHAR TEXT}
);
foreach ($field->subfields) {
spi_exec_prepared(
$istmt,
$_TD->{new}{id},
$_->[0],
$_->[1]
);
}
return;