2 * Copyright (C) 2008 Equinox Software, Inc.
3 * Mike Rylander <miker@esilibrary.com.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
19 -- Handy management functions for the new materialized reporting view
21 CREATE OR REPLACE FUNCTION reporter.disable_materialized_simple_record_trigger () RETURNS VOID AS $$
22 DROP TRIGGER zzz_update_materialized_simple_record_tgr ON metabib.full_rec;
25 CREATE OR REPLACE FUNCTION reporter.enable_materialized_simple_record_trigger () RETURNS VOID AS $$
27 TRUNCATE TABLE reporter.materialized_simple_record;
29 INSERT INTO reporter.materialized_simple_record
30 (id,fingerprint,quality,tcn_source,tcn_value,title,author,publisher,pubdate,isbn,issn)
31 SELECT DISTINCT ON (id) * FROM reporter.old_super_simple_record;
33 CREATE TRIGGER zzz_update_materialized_simple_record_tgr
34 AFTER INSERT OR UPDATE OR DELETE ON metabib.full_rec
35 FOR EACH ROW EXECUTE PROCEDURE reporter.simple_rec_sync();
39 CREATE OR REPLACE FUNCTION reporter.refresh_materialized_simple_record () RETURNS VOID AS $$
40 SELECT reporter.disable_materialized_simple_record_trigger();
41 SELECT reporter.enable_materialized_simple_record_trigger();