<?xml version="1.0" encoding="UTF-8"?><database name="egdb3_14_1" schema="reporter" type="PostgreSQL - 15.10 (Ubuntu 15.10-1.pgdg24.04+1)">
   <sequences>
      <sequence increment="1" name="output_folder_id_seq" startValue="1"/>
      <sequence increment="1" name="report_folder_id_seq" startValue="1"/>
      <sequence increment="1" name="report_id_seq" startValue="1"/>
      <sequence increment="1" name="schedule_id_seq" startValue="1"/>
      <sequence increment="1" name="template_folder_id_seq" startValue="1"/>
      <sequence increment="1" name="template_id_seq" startValue="1"/>
   </sequences>
   <tables>
      <table name="asset_call_number_dewey" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT call_number.id AS call_number,&#10;    call_number_dewey(call_number.label) AS dewey,&#10;        CASE&#10;            WHEN (call_number_dewey(call_number.label) ~ '^[0-9]+\.?[0-9]*$'::text) THEN btrim(to_char(((10)::double precision * floor(((call_number_dewey(call_number.label))::double precision / (10)::double precision))), '000'::text))&#10;            ELSE NULL::text&#10;        END AS dewey_block_tens,&#10;        CASE&#10;            WHEN (call_number_dewey(call_number.label) ~ '^[0-9]+\.?[0-9]*$'::text) THEN btrim(to_char(((100)::double precision * floor(((call_number_dewey(call_number.label))::double precision / (100)::double precision))), '000'::text))&#10;            ELSE NULL::text&#10;        END AS dewey_block_hundreds,&#10;        CASE&#10;            WHEN (call_number_dewey(call_number.label) ~ '^[0-9]+\.?[0-9]*$'::text) THEN ((btrim(to_char(((10)::double precision * floor(((call_number_dewey(call_number.label))::double precision / (10)::double precision))), '000'::text)) || '-'::text) || btrim(to_char((((10)::double precision * floor(((call_number_dewey(call_number.label))::double precision / (10)::double precision))) + (9)::double precision), '000'::text)))&#10;            ELSE NULL::text&#10;        END AS dewey_range_tens,&#10;        CASE&#10;            WHEN (call_number_dewey(call_number.label) ~ '^[0-9]+\.?[0-9]*$'::text) THEN ((btrim(to_char(((100)::double precision * floor(((call_number_dewey(call_number.label))::double precision / (100)::double precision))), '000'::text)) || '-'::text) || btrim(to_char((((100)::double precision * floor(((call_number_dewey(call_number.label))::double precision / (100)::double precision))) + (99)::double precision), '000'::text)))&#10;            ELSE NULL::text&#10;        END AS dewey_range_hundreds&#10;   FROM asset.call_number&#10;  WHERE (call_number_dewey(call_number.label) ~ '^[0-9]'::text);">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="call_number" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="dewey" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="dewey_block_tens" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="dewey_block_hundreds" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="dewey_range_tens" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="dewey_range_hundreds" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="circ_type" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT circulation.id,&#10;        CASE&#10;            WHEN (circulation.opac_renewal OR circulation.phone_renewal OR circulation.desk_renewal OR circulation.auto_renewal) THEN 'RENEWAL'::text&#10;            ELSE 'CHECKOUT'::text&#10;        END AS type&#10;   FROM action.circulation;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="materialized_simple_record"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="type" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="completed_reports" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT s.id AS run,&#10;    r.id AS report,&#10;    t.id AS template,&#10;    t.owner AS template_owner,&#10;    r.owner AS report_owner,&#10;    s.runner,&#10;    t.folder AS template_folder,&#10;    r.folder AS report_folder,&#10;    s.folder AS output_folder,&#10;    r.name AS report_name,&#10;    t.name AS template_name,&#10;    s.start_time,&#10;    s.run_time,&#10;    s.complete_time,&#10;    s.error_code,&#10;    s.error_text&#10;   FROM ((reporter.schedule s&#10;     JOIN reporter.report r ON ((r.id = s.report)))&#10;     JOIN reporter.template t ON ((t.id = r.template)))&#10;  WHERE (s.complete_time IS NOT NULL);">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="run" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="report" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="template" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="template_owner" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="report_owner" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="runner" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="template_folder" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="report_folder" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="output_folder" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="report_name" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="template_name" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="11" name="start_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="run_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="complete_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="error_code" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="error_text" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="currently_running" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT s.id,&#10;    c.barcode AS runner_barcode,&#10;    r.name,&#10;    s.run_time,&#10;    (s.run_time - now()) AS scheduled_wait_time&#10;   FROM (((reporter.schedule s&#10;     JOIN reporter.report r ON ((r.id = s.report)))&#10;     JOIN actor.usr u ON ((s.runner = u.id)))&#10;     JOIN actor.card c ON ((c.id = u.card)))&#10;  WHERE ((s.start_time IS NOT NULL) AND (s.complete_time IS NULL));">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="runner_barcode" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="name" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="3" name="run_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="scheduled_wait_time" nullable="true" remarks="" size="49" type="interval" typeCode="1111"/>
      </table>
      <table name="demographic" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT u.id,&#10;    u.dob,&#10;        CASE&#10;            WHEN (u.dob IS NULL) THEN 'Adult'::text&#10;            WHEN (age((u.dob)::timestamp with time zone) &gt; '18 years'::interval) THEN 'Adult'::text&#10;            ELSE 'Juvenile'::text&#10;        END AS general_division,&#10;        CASE&#10;            WHEN (u.dob IS NULL) THEN 'No Date of Birth Entered'::text&#10;            WHEN ((age((u.dob)::timestamp with time zone) &gt;= '00:00:00'::interval) AND (age((u.dob)::timestamp with time zone) &lt; '6 years'::interval)) THEN 'Child 0-5 Years Old'::text&#10;            WHEN ((age((u.dob)::timestamp with time zone) &gt;= '6 years'::interval) AND (age((u.dob)::timestamp with time zone) &lt; '13 years'::interval)) THEN 'Child 6-12 Years Old'::text&#10;            WHEN ((age((u.dob)::timestamp with time zone) &gt;= '13 years'::interval) AND (age((u.dob)::timestamp with time zone) &lt; '18 years'::interval)) THEN 'Teen 13-17 Years Old'::text&#10;            WHEN ((age((u.dob)::timestamp with time zone) &gt;= '18 years'::interval) AND (age((u.dob)::timestamp with time zone) &lt; '26 years'::interval)) THEN 'Adult 18-25 Years Old'::text&#10;            WHEN ((age((u.dob)::timestamp with time zone) &gt;= '26 years'::interval) AND (age((u.dob)::timestamp with time zone) &lt; '50 years'::interval)) THEN 'Adult 26-49 Years Old'::text&#10;            WHEN ((age((u.dob)::timestamp with time zone) &gt;= '50 years'::interval) AND (age((u.dob)::timestamp with time zone) &lt; '60 years'::interval)) THEN 'Adult 50-59 Years Old'::text&#10;            WHEN ((age((u.dob)::timestamp with time zone) &gt;= '60 years'::interval) AND (age((u.dob)::timestamp with time zone) &lt; '70 years'::interval)) THEN 'Adult 60-69 Years Old'::text&#10;            WHEN (age((u.dob)::timestamp with time zone) &gt;= '70 years'::interval) THEN 'Adult 70+'::text&#10;            ELSE NULL::text&#10;        END AS age_division&#10;   FROM actor.usr u;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="dob" nullable="true" remarks="" size="13" type="date" typeCode="91"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="general_division" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="age_division" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="hold_request_record" numRows="265" remarks="" schema="reporter" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="target" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="hold_type" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="bib_record" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="reporter_hold_request_record_pkey_idx" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="reporter_hold_request_record_bib_record_idx" unique="false">
            <column ascending="true" name="bib_record"/>
         </index>
      </table>
      <table name="materialized_simple_record" numRows="344" remarks="" schema="reporter" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <child column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="circ_type"/>
            <child column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="old_super_simple_record"/>
            <child column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="overdue_circs"/>
            <child column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="simple_record"/>
            <child column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="super_simple_record"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="fingerprint" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="quality" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="tcn_source" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="tcn_value" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="title" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="author" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="publisher" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="pubdate" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="isbn" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="issn" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="materialized_simple_record_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="old_super_simple_record" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT r.id,&#10;    r.fingerprint,&#10;    r.quality,&#10;    r.tcn_source,&#10;    r.tcn_value,&#10;    oils_json_to_text(d.title) AS title,&#10;    oils_json_to_text(d.author) AS author,&#10;    oils_json_to_text(d.publisher) AS publisher,&#10;    oils_json_to_text(d.pubdate) AS pubdate,&#10;        CASE&#10;            WHEN (d.isbn = 'null'::text) THEN NULL::text[]&#10;            ELSE ( SELECT ARRAY( SELECT json_array_elements_text((d.isbn)::json) AS json_array_elements_text) AS &quot;array&quot;)&#10;        END AS isbn,&#10;        CASE&#10;            WHEN (d.issn = 'null'::text) THEN NULL::text[]&#10;            ELSE ( SELECT ARRAY( SELECT json_array_elements_text((d.issn)::json) AS json_array_elements_text) AS &quot;array&quot;)&#10;        END AS issn&#10;   FROM (biblio.record_entry r&#10;     JOIN metabib.wide_display_entry d ON ((r.id = d.source)));">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="materialized_simple_record"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="fingerprint" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="quality" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="tcn_source" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="tcn_value" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="title" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="author" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="publisher" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="pubdate" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="isbn" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="issn" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
      </table>
      <table name="output_folder" remarks="" schema="reporter" type="TABLE">
         <column autoUpdated="true" defaultValue="nextval('reporter.output_folder_id_seq'::regclass)" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="serial" typeCode="4">
            <child column="parent" foreignKey="output_folder_parent_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="output_folder"/>
            <child column="folder" foreignKey="schedule_folder_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="schedule"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="parent" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="output_folder_parent_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="output_folder"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="owner" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="output_folder_owner_fkey" implied="false" onDeleteCascade="false" schema="actor" table="usr"/>
         </column>
         <column autoUpdated="false" defaultValue="now()" digits="6" id="3" name="create_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="5" name="shared" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="6" name="simple_reporter" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="share_with" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="output_folder_share_with_fkey" implied="false" onDeleteCascade="false" schema="actor" table="org_unit"/>
         </column>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="output_folder_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="rpt_output_fldr_owner_idx" unique="false">
            <column ascending="true" name="owner"/>
         </index>
         <index name="rpt_output_folder_once_idx" unique="true">
            <column ascending="true" name="name"/>
            <column ascending="true" name="owner"/>
            <column ascending="true" name="simple_reporter"/>
         </index>
         <index name="rpt_output_folder_once_parent_idx" unique="true">
            <column ascending="true" name="name"/>
            <column ascending="true" name="parent"/>
         </index>
      </table>
      <table name="overdue_circs" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT circulation.id,&#10;    circulation.usr,&#10;    circulation.xact_start,&#10;    circulation.xact_finish,&#10;    circulation.unrecovered,&#10;    circulation.target_copy,&#10;    circulation.circ_lib,&#10;    circulation.circ_staff,&#10;    circulation.checkin_staff,&#10;    circulation.checkin_lib,&#10;    circulation.renewal_remaining,&#10;    circulation.grace_period,&#10;    circulation.due_date,&#10;    circulation.stop_fines_time,&#10;    circulation.checkin_time,&#10;    circulation.create_time,&#10;    circulation.duration,&#10;    circulation.fine_interval,&#10;    circulation.recurring_fine,&#10;    circulation.max_fine,&#10;    circulation.phone_renewal,&#10;    circulation.desk_renewal,&#10;    circulation.opac_renewal,&#10;    circulation.duration_rule,&#10;    circulation.recurring_fine_rule,&#10;    circulation.max_fine_rule,&#10;    circulation.stop_fines,&#10;    circulation.workstation,&#10;    circulation.checkin_workstation,&#10;    circulation.copy_location,&#10;    circulation.checkin_scan_time,&#10;    circulation.auto_renewal,&#10;    circulation.auto_renewal_remaining,&#10;    circulation.parent_circ&#10;   FROM action.circulation&#10;  WHERE ((circulation.checkin_time IS NULL) AND ((circulation.stop_fines &lt;&gt; ALL (ARRAY['LOST'::text, 'CLAIMSRETURNED'::text])) OR (circulation.stop_fines IS NULL)) AND (circulation.due_date &lt; now()));">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="materialized_simple_record"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="usr" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="2" name="xact_start" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="3" name="xact_finish" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="unrecovered" nullable="true" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="target_copy" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="circ_lib" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="circ_staff" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="checkin_staff" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="checkin_lib" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="renewal_remaining" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="11" name="grace_period" nullable="true" remarks="" size="49" type="interval" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="due_date" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="stop_fines_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="14" name="checkin_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="15" name="create_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="16" name="duration" nullable="true" remarks="" size="49" type="interval" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="17" name="fine_interval" nullable="true" remarks="" size="49" type="interval" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="2" id="18" name="recurring_fine" nullable="true" remarks="" size="6" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="2" id="19" name="max_fine" nullable="true" remarks="" size="6" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="20" name="phone_renewal" nullable="true" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="21" name="desk_renewal" nullable="true" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="22" name="opac_renewal" nullable="true" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="23" name="duration_rule" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="24" name="recurring_fine_rule" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="25" name="max_fine_rule" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="26" name="stop_fines" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="27" name="workstation" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="28" name="checkin_workstation" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="29" name="copy_location" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="30" name="checkin_scan_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="31" name="auto_renewal" nullable="true" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="32" name="auto_renewal_remaining" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="33" name="parent_circ" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
      </table>
      <table name="overdue_reports" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT s.id,&#10;    c.barcode AS runner_barcode,&#10;    r.name,&#10;    s.run_time,&#10;    (s.run_time - now()) AS scheduled_wait_time&#10;   FROM (((reporter.schedule s&#10;     JOIN reporter.report r ON ((r.id = s.report)))&#10;     JOIN actor.usr u ON ((s.runner = u.id)))&#10;     JOIN actor.card c ON ((c.id = u.card)))&#10;  WHERE ((s.start_time IS NULL) AND (s.run_time &lt; now()));">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="runner_barcode" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="name" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="3" name="run_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="scheduled_wait_time" nullable="true" remarks="" size="49" type="interval" typeCode="1111"/>
      </table>
      <table name="pending_reports" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT s.id,&#10;    c.barcode AS runner_barcode,&#10;    r.name,&#10;    s.run_time,&#10;    (s.run_time - now()) AS scheduled_wait_time&#10;   FROM (((reporter.schedule s&#10;     JOIN reporter.report r ON ((r.id = s.report)))&#10;     JOIN actor.usr u ON ((s.runner = u.id)))&#10;     JOIN actor.card c ON ((c.id = u.card)))&#10;  WHERE (s.start_time IS NULL);">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="runner_barcode" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="name" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="3" name="run_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="scheduled_wait_time" nullable="true" remarks="" size="49" type="interval" typeCode="1111"/>
      </table>
      <table name="report" remarks="" schema="reporter" type="TABLE">
         <column autoUpdated="true" defaultValue="nextval('reporter.report_id_seq'::regclass)" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="serial" typeCode="4">
            <child column="report" foreignKey="schedule_report_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="schedule"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="owner" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="report_owner_fkey" implied="false" onDeleteCascade="false" schema="actor" table="usr"/>
         </column>
         <column autoUpdated="false" defaultValue="now()" digits="6" id="2" name="create_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="''::text" digits="0" id="3" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="''::text" digits="0" id="4" name="description" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="template" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="report_template_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="template"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="data" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="folder" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="report_folder_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="report_folder"/>
         </column>
         <column autoUpdated="false" defaultValue="false" digits="0" id="8" name="recur" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="9" name="recurrence" nullable="true" remarks="" size="49" type="interval" typeCode="1111"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="report_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="rpt_rpt_fldr_idx" unique="false">
            <column ascending="true" name="folder"/>
         </index>
         <index name="rpt_rpt_owner_idx" unique="false">
            <column ascending="true" name="owner"/>
         </index>
         <index name="rtp_report_folder_once_idx" unique="true">
            <column ascending="true" name="name"/>
            <column ascending="true" name="folder"/>
         </index>
      </table>
      <table name="report_folder" remarks="" schema="reporter" type="TABLE">
         <column autoUpdated="true" defaultValue="nextval('reporter.report_folder_id_seq'::regclass)" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="serial" typeCode="4">
            <child column="folder" foreignKey="report_folder_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="report"/>
            <child column="parent" foreignKey="report_folder_parent_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="report_folder"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="parent" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="report_folder_parent_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="report_folder"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="owner" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="report_folder_owner_fkey" implied="false" onDeleteCascade="false" schema="actor" table="usr"/>
         </column>
         <column autoUpdated="false" defaultValue="now()" digits="6" id="3" name="create_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="5" name="shared" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="6" name="simple_reporter" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="share_with" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="report_folder_share_with_fkey" implied="false" onDeleteCascade="false" schema="actor" table="org_unit"/>
         </column>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="report_folder_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="rpt_report_folder_once_idx" unique="true">
            <column ascending="true" name="name"/>
            <column ascending="true" name="owner"/>
            <column ascending="true" name="simple_reporter"/>
         </index>
         <index name="rpt_report_folder_once_parent_idx" unique="true">
            <column ascending="true" name="name"/>
            <column ascending="true" name="parent"/>
         </index>
         <index name="rpt_rpt_fldr_owner_idx" unique="false">
            <column ascending="true" name="owner"/>
         </index>
      </table>
      <table name="schedule" remarks="" schema="reporter" type="TABLE">
         <column autoUpdated="true" defaultValue="nextval('reporter.schedule_id_seq'::regclass)" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="serial" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="report" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="schedule_report_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="report"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="folder" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="schedule_folder_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="output_folder"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="runner" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="schedule_runner_fkey" implied="false" onDeleteCascade="false" schema="actor" table="usr"/>
         </column>
         <column autoUpdated="false" defaultValue="now()" digits="6" id="4" name="run_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="start_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="6" name="complete_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="email" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="true" digits="0" id="8" name="excel_format" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="true" digits="0" id="9" name="html_format" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="true" digits="0" id="10" name="csv_format" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="11" name="chart_pie" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="12" name="chart_bar" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="13" name="chart_line" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="14" name="new_record_bucket" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="15" name="existing_record_bucket" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="error_code" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="error_text" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="schedule_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="rpt_sched_folder_idx" unique="false">
            <column ascending="true" name="folder"/>
         </index>
         <index name="rpt_sched_recurrence_once_idx" unique="true">
            <column ascending="true" name="report"/>
            <column ascending="true" name="folder"/>
            <column ascending="true" name="runner"/>
            <column ascending="true" name="run_time"/>
         </index>
         <index name="rpt_sched_runner_idx" unique="false">
            <column ascending="true" name="runner"/>
         </index>
      </table>
      <table name="simple_record" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT r.id,&#10;    s.metarecord,&#10;    r.fingerprint,&#10;    r.quality,&#10;    r.tcn_source,&#10;    r.tcn_value,&#10;    title.value AS title,&#10;    uniform_title.value AS uniform_title,&#10;    author.value AS author,&#10;    publisher.value AS publisher,&#10;    &quot;substring&quot;(pubdate.value, '\d+'::text) AS pubdate,&#10;    series_title.value AS series_title,&#10;    series_statement.value AS series_statement,&#10;    summary.value AS summary,&#10;    array_agg(DISTINCT replace(&quot;substring&quot;(isbn.value, '^\S+'::text), '-'::text, ''::text)) AS isbn,&#10;    array_agg(DISTINCT regexp_replace(issn.value, '^\S*(\d{4})[-\s](\d{3,4}x?)'::text, '\1 \2'::text)) AS issn,&#10;    ARRAY( SELECT DISTINCT full_rec.value&#10;           FROM metabib.full_rec&#10;          WHERE ((full_rec.tag = '650'::bpchar) AND (full_rec.subfield = 'a'::text) AND (full_rec.record = r.id))) AS topic_subject,&#10;    ARRAY( SELECT DISTINCT full_rec.value&#10;           FROM metabib.full_rec&#10;          WHERE ((full_rec.tag = '651'::bpchar) AND (full_rec.subfield = 'a'::text) AND (full_rec.record = r.id))) AS geographic_subject,&#10;    ARRAY( SELECT DISTINCT full_rec.value&#10;           FROM metabib.full_rec&#10;          WHERE ((full_rec.tag = '655'::bpchar) AND (full_rec.subfield = 'a'::text) AND (full_rec.record = r.id))) AS genre,&#10;    ARRAY( SELECT DISTINCT full_rec.value&#10;           FROM metabib.full_rec&#10;          WHERE ((full_rec.tag = '600'::bpchar) AND (full_rec.subfield = 'a'::text) AND (full_rec.record = r.id))) AS name_subject,&#10;    ARRAY( SELECT DISTINCT full_rec.value&#10;           FROM metabib.full_rec&#10;          WHERE ((full_rec.tag = '610'::bpchar) AND (full_rec.subfield = 'a'::text) AND (full_rec.record = r.id))) AS corporate_subject,&#10;    ARRAY( SELECT full_rec.value&#10;           FROM metabib.full_rec&#10;          WHERE ((full_rec.tag = '856'::bpchar) AND (full_rec.subfield = ANY (ARRAY['3'::text, 'y'::text, 'u'::text])) AND (full_rec.record = r.id))&#10;          ORDER BY&#10;                CASE&#10;                    WHEN (full_rec.subfield = ANY (ARRAY['3'::text, 'y'::text])) THEN 0&#10;                    ELSE 1&#10;                END) AS external_uri&#10;   FROM (((((((((((biblio.record_entry r&#10;     JOIN metabib.metarecord_source_map s ON ((s.source = r.id)))&#10;     LEFT JOIN metabib.full_rec uniform_title ON (((r.id = uniform_title.record) AND (uniform_title.tag = '240'::bpchar) AND (uniform_title.subfield = 'a'::text))))&#10;     LEFT JOIN metabib.full_rec title ON (((r.id = title.record) AND (title.tag = '245'::bpchar) AND (title.subfield = 'a'::text))))&#10;     LEFT JOIN metabib.full_rec author ON (((r.id = author.record) AND (author.tag = '100'::bpchar) AND (author.subfield = 'a'::text))))&#10;     LEFT JOIN metabib.full_rec publisher ON (((r.id = publisher.record) AND ((publisher.tag = '260'::bpchar) OR ((publisher.tag = '264'::bpchar) AND (publisher.ind2 = '1'::text))) AND (publisher.subfield = 'b'::text))))&#10;     LEFT JOIN metabib.full_rec pubdate ON (((r.id = pubdate.record) AND ((pubdate.tag = '260'::bpchar) OR ((pubdate.tag = '264'::bpchar) AND (pubdate.ind2 = '1'::text))) AND (pubdate.subfield = 'c'::text))))&#10;     LEFT JOIN metabib.full_rec isbn ON (((r.id = isbn.record) AND (isbn.tag = ANY (ARRAY['024'::bpchar, '020'::bpchar])) AND (isbn.subfield = ANY (ARRAY['a'::text, 'z'::text])))))&#10;     LEFT JOIN metabib.full_rec issn ON (((r.id = issn.record) AND (issn.tag = '022'::bpchar) AND (issn.subfield = 'a'::text))))&#10;     LEFT JOIN metabib.full_rec series_title ON (((r.id = series_title.record) AND (series_title.tag = ANY (ARRAY['830'::bpchar, '440'::bpchar])) AND (series_title.subfield = 'a'::text))))&#10;     LEFT JOIN metabib.full_rec series_statement ON (((r.id = series_statement.record) AND (series_statement.tag = '490'::bpchar) AND (series_statement.subfield = 'a'::text))))&#10;     LEFT JOIN metabib.full_rec summary ON (((r.id = summary.record) AND (summary.tag = '520'::bpchar) AND (summary.subfield = 'a'::text))))&#10;  GROUP BY r.id, s.metarecord, r.fingerprint, r.quality, r.tcn_source, r.tcn_value, title.value, uniform_title.value, author.value, publisher.value, (&quot;substring&quot;(pubdate.value, '\d+'::text)), series_title.value, series_statement.value, summary.value;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="materialized_simple_record"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="metarecord" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="fingerprint" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="quality" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="tcn_source" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="tcn_value" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="title" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="uniform_title" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="author" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="publisher" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="pubdate" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="series_title" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="series_statement" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="summary" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="isbn" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="issn" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="topic_subject" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="geographic_subject" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="genre" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="19" name="name_subject" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="20" name="corporate_subject" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="21" name="external_uri" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
      </table>
      <table name="super_simple_record" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT materialized_simple_record.id,&#10;    materialized_simple_record.fingerprint,&#10;    materialized_simple_record.quality,&#10;    materialized_simple_record.tcn_source,&#10;    materialized_simple_record.tcn_value,&#10;    materialized_simple_record.title,&#10;    materialized_simple_record.author,&#10;    materialized_simple_record.publisher,&#10;    materialized_simple_record.pubdate,&#10;    materialized_simple_record.isbn,&#10;    materialized_simple_record.issn&#10;   FROM reporter.materialized_simple_record;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="Implied Constraint" implied="true" onDeleteCascade="false" schema="reporter" table="materialized_simple_record"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="fingerprint" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="quality" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="tcn_source" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="tcn_value" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="title" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="author" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="publisher" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="pubdate" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="isbn" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="issn" nullable="true" remarks="" size="2147483647" type="_text" typeCode="2003"/>
      </table>
      <table name="template" remarks="" schema="reporter" type="TABLE">
         <column autoUpdated="true" defaultValue="nextval('reporter.template_id_seq'::regclass)" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="serial" typeCode="4">
            <child column="template" foreignKey="report_template_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="report"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="owner" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="template_owner_fkey" implied="false" onDeleteCascade="false" schema="actor" table="usr"/>
         </column>
         <column autoUpdated="false" defaultValue="now()" digits="6" id="2" name="create_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="''::text" digits="0" id="4" name="description" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="data" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="folder" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="template_folder_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="template_folder"/>
         </column>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="template_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="rpt_tmpl_fldr_idx" unique="false">
            <column ascending="true" name="folder"/>
         </index>
         <index name="rpt_tmpl_owner_idx" unique="false">
            <column ascending="true" name="owner"/>
         </index>
         <index name="rtp_template_folder_once_idx" unique="true">
            <column ascending="true" name="name"/>
            <column ascending="true" name="folder"/>
         </index>
      </table>
      <table name="template_folder" remarks="" schema="reporter" type="TABLE">
         <column autoUpdated="true" defaultValue="nextval('reporter.template_folder_id_seq'::regclass)" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="serial" typeCode="4">
            <child column="folder" foreignKey="template_folder_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="template"/>
            <child column="parent" foreignKey="template_folder_parent_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="template_folder"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="parent" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="template_folder_parent_fkey" implied="false" onDeleteCascade="false" schema="reporter" table="template_folder"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="owner" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="template_folder_owner_fkey" implied="false" onDeleteCascade="false" schema="actor" table="usr"/>
         </column>
         <column autoUpdated="false" defaultValue="now()" digits="6" id="3" name="create_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="5" name="shared" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="6" name="simple_reporter" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="share_with" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="template_folder_share_with_fkey" implied="false" onDeleteCascade="false" schema="actor" table="org_unit"/>
         </column>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="template_folder_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="rpt_template_folder_once_idx" unique="true">
            <column ascending="true" name="name"/>
            <column ascending="true" name="owner"/>
            <column ascending="true" name="simple_reporter"/>
         </index>
         <index name="rpt_template_folder_once_parent_idx" unique="true">
            <column ascending="true" name="name"/>
            <column ascending="true" name="parent"/>
         </index>
         <index name="rpt_tmpl_fldr_owner_idx" unique="false">
            <column ascending="true" name="owner"/>
         </index>
      </table>
      <table name="xact_billing_totals" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT b.xact,&#10;    sum(&#10;        CASE&#10;            WHEN b.voided THEN (0)::numeric&#10;            ELSE b.amount&#10;        END) AS unvoided,&#10;    sum(&#10;        CASE&#10;            WHEN b.voided THEN b.amount&#10;            ELSE (0)::numeric&#10;        END) AS voided,&#10;    sum(b.amount) AS total&#10;   FROM money.billing b&#10;  GROUP BY b.xact;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="xact" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="unvoided" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="voided" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="total" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
      </table>
      <table name="xact_paid_totals" numRows="0" remarks="" schema="reporter" type="VIEW" viewSql=" SELECT b.xact,&#10;    sum(&#10;        CASE&#10;            WHEN b.voided THEN (0)::numeric&#10;            ELSE b.amount&#10;        END) AS unvoided,&#10;    sum(&#10;        CASE&#10;            WHEN b.voided THEN b.amount&#10;            ELSE (0)::numeric&#10;        END) AS voided,&#10;    sum(b.amount) AS total&#10;   FROM money.payment b&#10;  GROUP BY b.xact;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="xact" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="unvoided" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="voided" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="total" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
      </table>
   </tables>
   <routines>
      <routine dataAccess="MODIFIES" deterministic="false" name="disable_materialized_simple_record_trigger()" returnType="void" securityType="INVOKER" type="FUNCTION">
         <comment/>
         <definition language="sql"><![CDATA[DROP TRIGGER IF EXISTS bbb_simple_rec_trigger ON biblio.record_entry;]]></definition>
         <parameters>
            <parameter mode="IN"/>
         </parameters>
      </routine>
      <routine dataAccess="MODIFIES" deterministic="false" name="enable_materialized_simple_record_trigger()" returnType="void" securityType="INVOKER" type="FUNCTION">
         <comment/>
         <definition language="sql"><![CDATA[TRUNCATE TABLE reporter.materialized_simple_record;

    INSERT INTO reporter.materialized_simple_record
        (id,fingerprint,quality,tcn_source,tcn_value,title,author,publisher,pubdate,isbn,issn)
        SELECT DISTINCT ON (id) * FROM reporter.old_super_simple_record;

    CREATE TRIGGER bbb_simple_rec_trigger
        AFTER INSERT OR UPDATE OR DELETE ON biblio.record_entry
        FOR EACH ROW EXECUTE PROCEDURE reporter.simple_rec_trigger();]]></definition>
         <parameters>
            <parameter mode="IN"/>
         </parameters>
      </routine>
      <routine dataAccess="MODIFIES" deterministic="false" name="hold_request_record_mapper()" returnType="trigger" securityType="INVOKER" type="FUNCTION">
         <comment/>
         <definition language="plpgsql"><![CDATA[BEGIN
    IF TG_OP = 'INSERT' THEN
        INSERT INTO reporter.hold_request_record (id, target, hold_type, bib_record)
        SELECT  NEW.id,
                NEW.target,
                NEW.hold_type,
                CASE
                    WHEN NEW.hold_type = 'T'
                        THEN NEW.target
                    WHEN NEW.hold_type = 'I'
                        THEN (SELECT ssub.record_entry FROM serial.subscription ssub JOIN serial.issuance si ON (si.subscription = ssub.id) WHERE si.id = NEW.target)
                    WHEN NEW.hold_type = 'V'
                        THEN (SELECT cn.record FROM asset.call_number cn WHERE cn.id = NEW.target)
                    WHEN NEW.hold_type IN ('C','R','F')
                        THEN (SELECT cn.record FROM asset.call_number cn JOIN asset.copy cp ON (cn.id = cp.call_number) WHERE cp.id = NEW.target)
                    WHEN NEW.hold_type = 'M'
                        THEN (SELECT mr.master_record FROM metabib.metarecord mr WHERE mr.id = NEW.target)
                    WHEN NEW.hold_type = 'P'
                        THEN (SELECT bmp.record FROM biblio.monograph_part bmp WHERE bmp.id = NEW.target)
                END AS bib_record;
    ELSIF TG_OP = 'UPDATE' AND (OLD.target <> NEW.target OR OLD.hold_type <> NEW.hold_type) THEN
        UPDATE  reporter.hold_request_record
          SET   target = NEW.target,
                hold_type = NEW.hold_type,
                bib_record = CASE
                    WHEN NEW.hold_type = 'T'
                        THEN NEW.target
                    WHEN NEW.hold_type = 'I'
                        THEN (SELECT ssub.record_entry FROM serial.subscription ssub JOIN serial.issuance si ON (si.subscription = ssub.id) WHERE si.id = NEW.target)
                    WHEN NEW.hold_type = 'V'
                        THEN (SELECT cn.record FROM asset.call_number cn WHERE cn.id = NEW.target)
                    WHEN NEW.hold_type IN ('C','R','F')
                        THEN (SELECT cn.record FROM asset.call_number cn JOIN asset.copy cp ON (cn.id = cp.call_number) WHERE cp.id = NEW.target)
                    WHEN NEW.hold_type = 'M'
                        THEN (SELECT mr.master_record FROM metabib.metarecord mr WHERE mr.id = NEW.target)
                    WHEN NEW.hold_type = 'P'
                        THEN (SELECT bmp.record FROM biblio.monograph_part bmp WHERE bmp.id = NEW.target)
                END
         WHERE  id = NEW.id;
    END IF;
    RETURN NEW;
END;]]></definition>
         <parameters>
            <parameter mode="IN"/>
         </parameters>
      </routine>
      <routine dataAccess="MODIFIES" deterministic="false" name="intersect_user_perm_ou(context_ou bigint, staff_id bigint, perm_code text)" returnType="boolean" securityType="INVOKER" type="FUNCTION">
         <comment/>
         <definition language="sql"><![CDATA[SELECT CASE WHEN context_ou IN (SELECT * FROM permission.usr_has_perm_at_all(staff_id::INT, perm_code)) THEN TRUE ELSE FALSE END;]]></definition>
         <parameters>
            <parameter mode="IN" name="context_ou" type="bigint"/>
            <parameter mode="IN" name="staff_id" type="bigint"/>
            <parameter mode="IN" name="perm_code" type="text"/>
         </parameters>
      </routine>
      <routine dataAccess="MODIFIES" deterministic="false" name="refresh_materialized_simple_record()" returnType="void" securityType="INVOKER" type="FUNCTION">
         <comment/>
         <definition language="sql"><![CDATA[SELECT reporter.disable_materialized_simple_record_trigger();
    SELECT reporter.enable_materialized_simple_record_trigger();]]></definition>
         <parameters>
            <parameter mode="IN"/>
         </parameters>
      </routine>
      <routine dataAccess="MODIFIES" deterministic="false" name="simple_rec_delete(r_id bigint)" returnType="boolean" securityType="INVOKER" type="FUNCTION">
         <comment/>
         <definition language="sql"><![CDATA[SELECT reporter.simple_rec_update($1, TRUE);]]></definition>
         <parameters>
            <parameter mode="IN" name="r_id" type="bigint"/>
         </parameters>
      </routine>
      <routine dataAccess="MODIFIES" deterministic="false" name="simple_rec_trigger()" returnType="trigger" securityType="INVOKER" type="FUNCTION">
         <comment/>
         <definition language="plpgsql"><![CDATA[BEGIN
    IF TG_OP = 'DELETE' THEN
        PERFORM reporter.simple_rec_delete(NEW.id);
    ELSE
        PERFORM reporter.simple_rec_update(NEW.id);
    END IF;

    RETURN NEW;
END;]]></definition>
         <parameters>
            <parameter mode="IN"/>
         </parameters>
      </routine>
      <routine dataAccess="MODIFIES" deterministic="false" name="simple_rec_update(r_id bigint)" returnType="boolean" securityType="INVOKER" type="FUNCTION">
         <comment/>
         <definition language="sql"><![CDATA[SELECT reporter.simple_rec_update($1, FALSE);]]></definition>
         <parameters>
            <parameter mode="IN" name="r_id" type="bigint"/>
         </parameters>
      </routine>
      <routine dataAccess="MODIFIES" deterministic="false" name="simple_rec_update(r_id bigint, deleted boolean)" returnType="boolean" securityType="INVOKER" type="FUNCTION">
         <comment/>
         <definition language="plpgsql"><![CDATA[BEGIN

    DELETE FROM reporter.materialized_simple_record WHERE id = r_id;

    IF NOT deleted THEN
        INSERT INTO reporter.materialized_simple_record SELECT DISTINCT ON (id) * FROM reporter.old_super_simple_record WHERE id = r_id;
    END IF;

    RETURN TRUE;

END;]]></definition>
         <parameters>
            <parameter mode="IN" name="r_id" type="bigint"/>
            <parameter mode="IN" name="deleted" type="boolean"/>
         </parameters>
      </routine>
   </routines>
</database>
