3 INSERT INTO config.upgrade_log (version) VALUES ('0369'); -- miker
5 CREATE OR REPLACE FUNCTION asset.opac_ou_record_copy_count (org INT, record BIGINT) RETURNS TABLE (depth INT, org_unit INT, visible BIGINT, available BIGINT, unshadow BIGINT, transcendant INT) AS $f$
10 SELECT 1 INTO trans FROM biblio.record_entry b JOIN config.bib_source src ON (b.source = src.id) WHERE src.transcendant AND b.id = record;
12 FOR ans IN SELECT u.id, t.depth FROM actor.org_unit_ancestors(org) AS u JOIN actor.org_unit_type t ON (u.ou_type = t.id) LOOP
17 SUM( CASE WHEN cp.status IN (0,7,12) THEN 1 ELSE 0 END ),
21 actor.org_unit_descendants(ans.id) d
22 JOIN asset.opac_visible_copies av ON (av.record = record AND av.circ_lib = d.id)
23 JOIN asset.copy cp ON (cp.id = av.id)
27 RETURN QUERY SELECT ans.depth, ans.id, 0::BIGINT, 0::BIGINT, 0::BIGINT, trans;