name holdings,
XMLATTRIBUTES(
CASE WHEN $8 THEN 'http://open-ils.org/spec/holdings/v1' ELSE NULL END AS xmlns,
- CASE WHEN ('bre' = ANY ('{acn,auri}'::TEXT[] || $5)) THEN 'tag:open-ils.org:U2@bre/' || $1 || '/' || $3 ELSE NULL END AS id
+ CASE WHEN ('bre' = ANY ($5)) THEN 'tag:open-ils.org:U2@bre/' || $1 || '/' || $3 ELSE NULL END AS id
),
XMLELEMENT(
name counts,
),
CASE
WHEN ('bmp' = ANY ($5)) THEN
- XMLELEMENT( name monograph_parts,
- XMLAGG((SELECT unapi.bmp( id, 'xml', 'monograph_part', evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($5,'bre'), 'holdings_xml'), $3, $4, $6, $7, FALSE) FROM biblio.monograph_part WHERE record = $1))
+ XMLELEMENT(
+ name monograph_parts,
+ (SELECT XMLAGG(bmp) FROM (
+ SELECT unapi.bmp( id, 'xml', 'monograph_part', evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($5,'bre'), 'holdings_xml'), $3, $4, $6, $7, FALSE)
+ FROM biblio.monograph_part
+ WHERE record = $1
+ )x)
)
ELSE NULL
END,
- CASE WHEN ('acn' = ANY ('{acn,auri}'::TEXT[] || $5)) THEN
- XMLELEMENT(
- name volumes,
- (SELECT XMLAGG(acn) FROM (
- SELECT unapi.acn(acn.id,'xml','volume',array_remove_item_by_value( evergreen.array_remove_item_by_value('{acn,auri}'::TEXT[] || $5,'holdings_xml'),'bre'), $3, $4, $6, $7, FALSE)
- FROM asset.call_number acn
- WHERE acn.record = $1
- AND EXISTS (
- SELECT 1
- FROM asset.copy acp
- JOIN actor.org_unit_descendants(
- $2,
- (COALESCE(
- $4,
- (SELECT aout.depth
- FROM actor.org_unit_type aout
- JOIN actor.org_unit aou ON (aou.ou_type = aout.id AND aou.id = $2)
- )
- ))
- ) aoud ON (acp.circ_lib = aoud.id)
- LIMIT 1
- )
- ORDER BY label_sortkey
- LIMIT $6
- OFFSET $7
- )x)
- )
- ELSE NULL END,
- CASE WHEN ('ssub' = ANY ('{acn,auri}'::TEXT[] || $5)) THEN
+ XMLELEMENT(
+ name volumes,
+ (SELECT XMLAGG(acn) FROM (
+ SELECT unapi.acn(acn.id,'xml','volume',array_remove_item_by_value( evergreen.array_remove_item_by_value($5,'holdings_xml'),'bre'), $3, $4, $6, $7, FALSE)
+ FROM asset.call_number acn
+ WHERE acn.record = $1
+ AND EXISTS (
+ SELECT 1
+ FROM asset.copy acp
+ JOIN actor.org_unit_descendants(
+ $2,
+ (COALESCE(
+ $4,
+ (SELECT aout.depth
+ FROM actor.org_unit_type aout
+ JOIN actor.org_unit aou ON (aou.ou_type = aout.id AND aou.id = $2)
+ )
+ ))
+ ) aoud ON (acp.circ_lib = aoud.id)
+ LIMIT 1
+ )
+ ORDER BY label_sortkey
+ LIMIT $6
+ OFFSET $7
+ )x)
+ ),
+ CASE WHEN ('ssub' = ANY ($5)) THEN
XMLELEMENT(
name subscriptions,
(SELECT XMLAGG(ssub) FROM (
XMLELEMENT( name distributions,
CASE
WHEN ('sdist' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.sdist( id, 'xml', 'distribution', evergreen.array_remove_item_by_value($4,'ssub'), $5, $6, $7, $8, FALSE) FROM serial.distribution WHERE subscription = ssub.id))
+ (SELECT XMLAGG(sdist) FROM (
+ SELECT unapi.sdist( id, 'xml', 'distribution', evergreen.array_remove_item_by_value($4,'ssub'), $5, $6, $7, $8, FALSE)
+ FROM serial.distribution
+ WHERE subscription = ssub.id
+ )x)
ELSE NULL
END
)
XMLELEMENT( name streams,
CASE
WHEN ('sstr' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.sstr( id, 'xml', 'stream', evergreen.array_remove_item_by_value($4,'sdist'), $5, $6, $7, $8, FALSE) FROM serial.stream WHERE distribution = sdist.id))
+ (SELECT XMLAGG(sstr) FROM (
+ SELECT unapi.sstr( id, 'xml', 'stream', evergreen.array_remove_item_by_value($4,'sdist'), $5, $6, $7, $8, FALSE)
+ FROM serial.stream
+ WHERE distribution = sdist.id
+ )x)
ELSE NULL
END
),
XMLELEMENT( name summaries,
CASE
WHEN ('ssum' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.sbsum( id, 'xml', 'serial_summary', evergreen.array_remove_item_by_value($4,'sdist'), $5, $6, $7, $8, FALSE) FROM serial.basic_summary WHERE distribution = sdist.id))
+ (SELECT XMLAGG(sbsum) FROM (
+ SELECT unapi.sbsum( id, 'xml', 'serial_summary', evergreen.array_remove_item_by_value($4,'sdist'), $5, $6, $7, $8, FALSE)
+ FROM serial.basic_summary
+ WHERE distribution = sdist.id
+ )x)
ELSE NULL
END,
CASE
WHEN ('ssum' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.sisum( id, 'xml', 'serial_summary', evergreen.array_remove_item_by_value($4,'sdist'), $5, $6, $7, $8, FALSE) FROM serial.index_summary WHERE distribution = sdist.id))
+ (SELECT XMLAGG(sisum) FROM (
+ SELECT unapi.sisum( id, 'xml', 'serial_summary', evergreen.array_remove_item_by_value($4,'sdist'), $5, $6, $7, $8, FALSE)
+ FROM serial.index_summary
+ WHERE distribution = sdist.id
+ )x)
ELSE NULL
END,
CASE
WHEN ('ssum' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.sssum( id, 'xml', 'serial_summary', evergreen.array_remove_item_by_value($4,'sdist'), $5, $6, $7, $8, FALSE) FROM serial.supplement_summary WHERE distribution = sdist.id))
+ (SELECT XMLAGG(sssum) FROM (
+ SELECT unapi.sssum( id, 'xml', 'serial_summary', evergreen.array_remove_item_by_value($4,'sdist'), $5, $6, $7, $8, FALSE)
+ FROM serial.supplement_summary
+ WHERE distribution = sdist.id
+ )x)
ELSE NULL
END
)
XMLELEMENT( name items,
CASE
WHEN ('sitem' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.sitem( id, 'xml', 'serial_item', evergreen.array_remove_item_by_value($4,'sstr'), $5, $6, $7, $8, FALSE) FROM serial.item WHERE stream = sstr.id))
+ (SELECT XMLAGG(sitem) FROM (
+ SELECT unapi.sitem( id, 'xml', 'serial_item', evergreen.array_remove_item_by_value($4,'sstr'), $5, $6, $7, $8, FALSE)
+ FROM serial.item
+ WHERE stream = sstr.id
+ )x)
ELSE NULL
END
)
XMLELEMENT( name items,
CASE
WHEN ('sitem' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.sitem( id, 'xml', 'serial_item', evergreen.array_remove_item_by_value($4,'siss'), $5, $6, $7, $8, FALSE) FROM serial.item WHERE issuance = sstr.id))
+ (SELECT XMLAGG(sitem) FROM (
+ SELECT unapi.sitem( id, 'xml', 'serial_item', evergreen.array_remove_item_by_value($4,'siss'), $5, $6, $7, $8, FALSE)
+ FROM serial.item
+ WHERE issuance = sstr.id
+ )x)
ELSE NULL
END
)
-- XMLELEMENT( name notes,
-- CASE
-- WHEN ('acpn' = ANY ($4)) THEN
--- XMLAGG((SELECT unapi.acpn( id, 'xml', 'copy_note', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8) FROM asset.copy_note WHERE owning_copy = cp.id AND pub))
+-- (SELECT XMLAGG(acpn) FROM (
+-- SELECT unapi.acpn( id, 'xml', 'copy_note', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8)
+-- FROM asset.copy_note
+-- WHERE owning_copy = cp.id AND pub
+-- )x)
-- ELSE NULL
-- END
-- )
XMLELEMENT( name copy_notes,
CASE
WHEN ('acpn' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.acpn( id, 'xml', 'copy_note', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8, FALSE) FROM asset.copy_note WHERE owning_copy = cp.id AND pub))
+ (SELECT XMLAGG(acpn) FROM (
+ SELECT unapi.acpn( id, 'xml', 'copy_note', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8, FALSE)
+ FROM asset.copy_note
+ WHERE owning_copy = cp.id AND pub
+ )x)
ELSE NULL
END
),
XMLELEMENT( name statcats,
CASE
WHEN ('ascecm' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.ascecm( stat_cat_entry, 'xml', 'statcat', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8, FALSE) FROM asset.stat_cat_entry_copy_map WHERE owning_copy = cp.id))
+ (SELECT XMLAGG(ascecm) FROM (
+ SELECT unapi.ascecm( stat_cat_entry, 'xml', 'statcat', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8, FALSE)
+ FROM asset.stat_cat_entry_copy_map
+ WHERE owning_copy = cp.id
+ )x)
ELSE NULL
END
),
XMLELEMENT( name foreign_records,
CASE
WHEN ('bre' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.bre(peer_record,'marcxml','record','{}'::TEXT[], $5, $6, $7, $8, FALSE) FROM biblio.peer_bib_copy_map WHERE target_copy = cp.id))
+ (SELECT XMLAGG(bre) FROM (
+ SELECT unapi.bre(peer_record,'marcxml','record','{}'::TEXT[], $5, $6, $7, $8, FALSE)
+ FROM biblio.peer_bib_copy_map
+ WHERE target_copy = cp.id
+ )x)
ELSE NULL
END
CASE
WHEN ('bmp' = ANY ($4)) THEN
XMLELEMENT( name monograph_parts,
- XMLAGG((SELECT unapi.bmp( part, 'xml', 'monograph_part', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8, FALSE) FROM asset.copy_part_map WHERE target_copy = cp.id))
+ (SELECT XMLAGG(bmp) FROM (
+ SELECT unapi.bmp( part, 'xml', 'monograph_part', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8, FALSE)
+ FROM asset.copy_part_map
+ WHERE target_copy = cp.id
+ )x)
)
ELSE NULL
END
XMLELEMENT( name copy_notes,
CASE
WHEN ('acpn' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.acpn( id, 'xml', 'copy_note', evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($4,'acp'),'sunit'), $5, $6, $7, $8, FALSE) FROM asset.copy_note WHERE owning_copy = cp.id AND pub))
+ (SELECT XMLAGG(acpn) FROM (
+ SELECT unapi.acpn( id, 'xml', 'copy_note', evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($4,'acp'),'sunit'), $5, $6, $7, $8, FALSE)
+ FROM asset.copy_note
+ WHERE owning_copy = cp.id AND pub
+ )x)
ELSE NULL
END
),
XMLELEMENT( name statcats,
CASE
WHEN ('ascecm' = ANY ($4)) THEN
- XMLAGG((SELECT unapi.acpn( stat_cat_entry, 'xml', 'statcat', evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($4,'acp'),'sunit'), $5, $6, $7, $8, FALSE) FROM asset.stat_cat_entry_copy_map WHERE owning_copy = cp.id))
+ (SELECT XMLAGG(ascecm) FROM (
+ SELECT unapi.ascecm( stat_cat_entry, 'xml', 'statcat', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8, FALSE)
+ FROM asset.stat_cat_entry_copy_map
+ WHERE owning_copy = cp.id
+ )x)
ELSE NULL
END
- )
+ ),
+ XMLELEMENT( name foreign_records,
+ CASE
+ WHEN ('bre' = ANY ($4)) THEN
+ (SELECT XMLAGG(bre) FROM (
+ SELECT unapi.bre(peer_record,'marcxml','record','{}'::TEXT[], $5, $6, $7, $8, FALSE)
+ FROM biblio.peer_bib_copy_map
+ WHERE target_copy = cp.id
+ )x)
+ ELSE NULL
+ END
+
+ ),
+ CASE
+ WHEN ('bmp' = ANY ($4)) THEN
+ XMLELEMENT( name monograph_parts,
+ (SELECT XMLAGG(bmp) FROM (
+ SELECT unapi.bmp( part, 'xml', 'monograph_part', evergreen.array_remove_item_by_value($4,'acp'), $5, $6, $7, $8, FALSE)
+ FROM asset.copy_part_map
+ WHERE target_copy = cp.id
+ )x)
+ )
+ ELSE NULL
+ END
)
FROM serial.unit cp
WHERE id = $1