Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-schedule.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-schedule.sql,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/acs-content-repository/sql/postgresql/content-schedule.sql	4 Jun 2006 00:45:23 -0000	1.9
+++ openacs-4/packages/acs-content-repository/sql/postgresql/content-schedule.sql	7 Jul 2011 10:46:02 -0000	1.10
@@ -12,13 +12,14 @@
 
 -- prompt *** Preparing for scheduled updates to live content...
 
-create function cr_scheduled_release_tr () returns opaque as '
-begin
+CREATE OR REPLACE FUNCTION cr_scheduled_release_tr () RETURNS trigger AS $$
+BEGIN
 
-   raise EXCEPTION ''-20000: Inserts are not allowed into cr_scheduled_release_job.'';
+   raise EXCEPTION '-20000: Inserts are not allowed into cr_scheduled_release_job.';
 
   return new;
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 create trigger cr_scheduled_release_tr 
 before insert on cr_scheduled_release_job
@@ -29,16 +30,23 @@
 -- Update the publishing status for items that are due to be released
 -- or expired.
 
-create function cr_scheduled_release_exec () returns integer as '
-declare
+
+
+--
+-- procedure cr_scheduled_release_exec/0
+--
+CREATE OR REPLACE FUNCTION cr_scheduled_release_exec(
+
+) RETURNS integer AS $$
+DECLARE
   exec__last_exec             timestamptz;
   exec__this_exec             timestamptz default current_timestamp;
   exec__items_released        integer default 0;
   exec__items_expired         integer default 0;
   exec__err_num               integer;  -- sqlcode
   exec__err_msg               varchar;  -- substr(sqlerrm, 1, 500);
   item_rec                    record;
-begin
+BEGIN
 
     select last_exec into exec__last_exec from cr_scheduled_release_job;
 
@@ -53,7 +61,7 @@
     LOOP
       -- update publish status
       update cr_items
-	set publish_status = ''live''
+	set publish_status = 'live'
       where
 	item_id = item_rec.item_id;
       exec__items_released := exec__items_released + 1;
@@ -70,7 +78,7 @@
     LOOP
       -- update publish status
       update cr_items
-	set publish_status = ''expired''
+	set publish_status = 'expired'
       where
 	item_id = item_rec.item_id;
 
@@ -96,10 +104,11 @@
 
   -- Table was growing without bound (OpenACS DanW)
   delete from cr_scheduled_release_log
-  where exec_date < now() - ''4 week''::interval;
+  where exec_date < now() - '4 week'::interval;
 
   -- Reset the last time of execution to start of processing
   update cr_scheduled_release_job set last_exec = exec__this_exec;
 
   return 0;
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
