1 CREATE OR REPLACE FUNCTION unapi.mra ( obj_id BIGINT, format TEXT, ename TEXT, includes TEXT[], org TEXT, depth INT DEFAULT NULL, slimit HSTORE DEFAULT NULL, soffset HSTORE DEFAULT NULL, include_xmlns BOOL DEFAULT TRUE ) RETURNS XML AS $F$
5 CASE WHEN $9 THEN 'http://open-ils.org/spec/indexing/v1' ELSE NULL END AS xmlns,
6 'tag:open-ils.org:U2@mra/' || mra.id AS id,
7 'tag:open-ils.org:U2@bre/' || mra.id AS record
10 FROM (SELECT XMLELEMENT(
14 cvm.value AS "coded-value",
21 FROM EACH(mra.attrs) AS x
22 JOIN config.record_attr_definition rad ON (x.key = rad.name)
23 LEFT JOIN config.coded_value_map cvm ON (cvm.ctype = x.key AND code = x.value)
27 FROM metabib.record_attr mra
29 $F$ LANGUAGE SQL STABLE;