Index: openacs-4/packages/views/sql/postgresql/views-triggers.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/views/sql/postgresql/views-triggers.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/views/sql/postgresql/views-triggers.sql	1 Aug 2007 08:59:56 -0000	1.3
+++ openacs-4/packages/views/sql/postgresql/views-triggers.sql	2 Nov 2013 16:15:13 -0000	1.4
@@ -12,8 +12,8 @@
 -- License.  Full text of the license is available from the GNU Project:
 -- http://www.fsf.org/copyleft/gpl.html
 
-create function views_views_ins_tr () returns opaque as '
-begin
+CREATE OR REPLACE FUNCTION views_views_ins_tr () RETURNS trigger AS $$
+BEGIN
     if not exists (select 1 from view_aggregates where object_id = new.object_id) then 
         INSERT  INTO view_aggregates (object_id,views_count,unique_views,last_viewed) 
         VALUES (new.object_id,1,1,now());
@@ -24,21 +24,23 @@
     end if;
 
     return new;
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 create trigger views_views_ins_tr 
 after insert on views_views
 for each row
 execute procedure views_views_ins_tr();
 
-create function views_views_upd_tr () returns opaque as '
-begin
+CREATE OR REPLACE FUNCTION views_views_upd_tr () RETURNS trigger AS $$
+BEGIN
     UPDATE view_aggregates 
        SET views_count = views_count + 1, last_viewed = now() 
      WHERE object_id = new.object_id;
 
     return new;
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 create trigger views_views_upd_tr
 after update on views_views
@@ -47,8 +49,8 @@
 
 -- XXXJCD: Should there be a delete trigger?
 
-create or replace function views_by_type_ins_tr () returns opaque as '
-begin
+CREATE OR REPLACE FUNCTION views_by_type_ins_tr () RETURNS trigger AS $$
+BEGIN
     if not exists (select 1 from view_aggregates_by_type where object_id = new.object_id and view_type = new.view_type) then 
         INSERT INTO view_aggregates_by_type (object_id,view_type,views_count,unique_views,last_viewed) 
         VALUES (new.object_id,new.view_type,1,1,now());
@@ -60,22 +62,24 @@
     end if;
 
     return new;
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 create trigger views_by_type_ins_tr 
 after insert on views_by_type
 for each row
 execute procedure views_by_type_ins_tr();
 
-create or replace function views_by_type_upd_tr () returns opaque as '
-begin
+CREATE OR REPLACE FUNCTION views_by_type_upd_tr () RETURNS trigger AS $$
+BEGIN
     UPDATE view_aggregates_by_type 
        SET views_count = views_count + 1, last_viewed = now() 
      WHERE object_id = new.object_id
        AND view_type = new.view_type;
 
     return new;
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 create trigger views_by_type_upd_tr
 after update on views_by_type
