<div dir="ltr"><div>Hi devs,<br><br></div>Bug 17196 is on its way to master, that means that some SQL reports from our wiki will be obsolete.<br><div><div><br><a href="https://wiki.koha-community.org/wiki/SQL_Reports_Library#Query_MARC">https://wiki.koha-community.org/wiki/SQL_Reports_Library#Query_MARC</a><br><br>We need to provide to libraries the examples of equivalent reports to help them updating their custom reports.<br><br>It seems very easy to update the reports from the wiki, but we will need to propose the 2 versions (with and without the biblioitems.marcxml field).<br>As the marcxml will be moved to the biblio_metadata.metadata field, the reports are very easy to update, for instance:<br><br></div><div>1/ Simple request on the biblioitems table:<br><br>    SELECT biblionumber, ExtractValue(marcxml, 'count(//datafield[@tag="505"])') AS count505<br>    FROM biblioitems<br>    HAVING count505 > 1;<br><br>Will become:<br><br>    SELECT biblionumber, ExtractValue(metadata, 'count(//datafield[@tag="505"])') AS count505<br>    FROM biblio_metadata<br>    HAVING count505 > 1; <br><br>2/ With info from the biblio table:<br><br>    SELECT biblionumber, substring( ExtractValue(marcxml,'//controlfield[@tag="008"]'), 8,4 ) AS 'PUB DATE', title<br>    FROM biblioitems<br>    INNER JOIN biblio USING (biblionumber)<br>    WHERE biblionumber = 14;<br><br>Will become:<br><br>    SELECT biblionumber, substring( ExtractValue(metadata,'//controlfield[@tag="008"]'), 8,4 ) AS 'PUB DATE', title<br>    FROM biblio_metadata<br>    INNER JOIN biblio USING (biblionumber)<br>    WHERE biblionumber = 14;<br><br></div><div>3/ Move complex query:<br><br></div><div>    SELECT concat(b.title, ' ', ExtractValue(m.marcxml, '//datafield[@tag="245"]/subfield[@code="b"]')) AS title, b.author, count(h.reservedate) AS 'holds'<br>    FROM biblio b<br>    LEFT JOIN biblioitems m USING (biblionumber)<br>    LEFT JOIN reserves h ON (b.biblionumber=h.biblionumber)<br>    GROUP BY b.biblionumber<br>    HAVING count(h.reservedate) >= 42;<br><br></div><div>Will become:<br></div><div><br>    SELECT concat(b.title, ' ', ExtractValue(m.metadata, '//datafield[@tag="245"]/subfield[@code="b"]')) AS title, b.author, count(h.reservedate) AS 'holds'<br>    FROM biblio b<br>    LEFT JOIN biblio_metadata m USING (biblionumber)<br>    LEFT JOIN reserves h ON (b.biblionumber=h.biblionumber)<br>    GROUP BY b.biblionumber<br>    HAVING count(h.reservedate) >= 42;<br><br></div><div>So basilly "biblioitems" becomes "biblio_metadata" and marcxml becomes "metadata".<br></div><div>We could almost script it!<br></div><div>The only difficulty I see is when we will need infos from the biblioitems table, we will need to add a join on biblio_metadata.<br><br><br></div><div>I was going to add the biblio_metadata version on the wiki, but, the first example of ExtractValue is completely wrong. It says that 2 queries are equivalent ("they are equivalent") and that "they return the whole 952 field". Which is totally wrong.<br><br></div><div>The work is a bit more complex than expected apparently, this wiki page need to be updated and cleaned first. Then we will be able to provide equivalent queries.<br></div><div><br></div><div>Cheers,<br></div><div>Jonathan</div></div></div>