]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/1.2.2.0-1.2.2.1-upgrade-db.sql
Add fund column to acq.invoice_item.
[working/Evergreen.git] / Open-ILS / src / sql / Pg / 1.2.2.0-1.2.2.1-upgrade-db.sql
1 /*
2  * Copyright (C) 2008  Equinox Software, Inc.
3  * Mike Rylander <miker@esilibrary.com.com>
4  *
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.
9  *
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.
14  *
15  */
16
17 BEGIN;
18
19 -- Handy management functions for the new materialized reporting view
20
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;
23 $$ LANGUAGE SQL;
24
25 CREATE OR REPLACE FUNCTION reporter.enable_materialized_simple_record_trigger () RETURNS VOID AS $$
26
27     TRUNCATE TABLE reporter.materialized_simple_record;
28
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;
32
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();
36
37 $$ LANGUAGE SQL;
38
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();
42 $$ LANGUAGE SQL;
43
44 COMMIT;