/ db / views /
/db/views/template
1 dnl Copyright (C) 2012-2014 The Meme Factory, Inc., http://www.meme.com/
2 dnl
3 dnl This file is part of Gombe-MI.
4 dnl
5 dnl Gombe-MI is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3 of the License, or
8 dnl (at your option) any later version.
9 dnl
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 dnl GNU General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with Gombe-MI. If not, see <http://www.gnu.org/licenses/>.
17 dnl
18 dnl Functions and triggers to allow insert, update, and delete into
19 dnl the template view.
20 dnl
21 dnl Karl O. Pinc <kop@meme.com>
22 dnl
23 dnl
24 dnl m4 includes
25 include(`copyright.m4')
26 include(`constants.m4')
27 include(`macros.m4')
28 include(`viewmacros.m4')
29 dnl
30
31 SELECT 'template_insert_func()';
32 CREATE OR REPLACE FUNCTION template_insert_func()
33 RETURNS trigger
34 LANGUAGE plpgsql
35 SECURITY DEFINER
36 gmi_function_set_search_path
37 AS $$
38 -- For triggers instead of insert into the template view.
39 --
40 -- GPL_notice(` --', `2014', `The Meme Factory, Inc. http://www.meme.com/')
41 --
42 -- Remarks:
43 --
44 -- Bugs:
45
46 DECLARE
47 return_value template%ROWTYPE;
48
49 BEGIN
50
51 RETURN return_value;
52 END;
53 $$;
54
55 SELECT 'template_update_func()';
56 CREATE OR REPLACE FUNCTION template_update_func()
57 RETURNS trigger
58 LANGUAGE plpgsql
59 SECURITY DEFINER
60 gmi_function_set_search_path
61 AS $$
62 -- For triggers instead of update of the template view.
63 --
64 -- GPL_notice(` --', `2014', `The Meme Factory, Inc. http://www.meme.com/')
65 --
66 -- Remarks:
67 --
68 -- Bugs:
69
70 DECLARE
71 return_value template%ROWTYPE;
72
73 BEGIN
74
75 RETURN return_value;
76 END;
77 $$;
78
79 SELECT 'template_delete_func()';
80 CREATE OR REPLACE FUNCTION template_delete_func()
81 RETURNS trigger
82 LANGUAGE plpgsql
83 SECURITY DEFINER
84 gmi_function_set_search_path
85 AS $$
86 -- For triggers instead of delete of the template view.
87 --
88 -- GPL_notice(` --', `2014', `The Meme Factory, Inc. http://www.meme.com/')
89 --
90 -- Remarks:
91 --
92 -- Bugs:
93
94 DECLARE
95 return_value template%ROWTYPE;
96
97 BEGIN
98
99 RETURN return_value;
100 END;
101 $$;
102
103
104 SELECT 'template_insert_trigger' AS trigger;
105 CREATE TRIGGER template_insert_trigger
106 INSTEAD OF INSERT
107 ON template FOR EACH ROW
108 EXECUTE PROCEDURE template_insert_func();
109
110 SELECT 'template_update_trigger' AS trigger;
111 CREATE TRIGGER template_update_trigger
112 INSTEAD OF UPDATE
113 ON template FOR EACH ROW
114 EXECUTE PROCEDURE template_update_func();
115
116 SELECT 'template_delete_trigger' AS trigger;
117 CREATE TRIGGER template_delete_trigger
118 INSTEAD OF DELETE
119 ON template FOR EACH ROW
120 EXECUTE PROCEDURE template_delete_func();