serial Functions
This page documents all 2 function(s) in the serial schema.
Function Index
| Function | Return Type | Language | Volatility | Security |
|---|---|---|---|---|
|
plperlu |
VOLATILE |
||
|
plpgsql |
VOLATILE |
materialize_holding_code
Signature: serial.materialize_holding_code()
Returns: trigger
Language |
plperlu |
Volatility |
VOLATILE |
Strict |
No |
Security Definer |
No |
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;
pattern_templates_visible_to
Signature: serial.pattern_templates_visible_to(org_unit integer)
Returns: SETOF serial.pattern_template
Language |
plpgsql |
Volatility |
VOLATILE |
Strict |
No |
Security Definer |
No |
BEGIN
RETURN QUERY SELECT *
FROM serial.pattern_template spt
WHERE (
SELECT ARRAY_AGG(id)
FROM actor.org_unit_descendants(spt.owning_lib, spt.share_depth)
) @@ org_unit::TEXT::QUERY_INT;
END;