Index: openacs-4/packages/bulk-mail/sql/postgresql/upgrade/upgrade-0.1a-0.4.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/upgrade/upgrade-0.1a-0.4.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/bulk-mail/sql/postgresql/upgrade/upgrade-0.1a-0.4.sql	26 Feb 2004 15:29:00 -0000	1.2
+++ openacs-4/packages/bulk-mail/sql/postgresql/upgrade/upgrade-0.1a-0.4.sql	27 Oct 2014 16:41:06 -0000	1.3
@@ -96,35 +96,45 @@
 -- @version $Id$
 --
 
-select define_function_args('bulk_mail__new','bulk_mail_id,package_id,send_date,date_format,status;pending,from_addr,subject,reply_to,extra_headers,message,query,creation_date;now(),creation_user,creation_ip,context_id');
 
-create or replace function bulk_mail__new (integer, integer, varchar, varchar, varchar, varchar, varchar, varchar, varchar, text, varchar, timestamptz, integer, varchar, integer)
-returns integer as '
-declare
-    bulk_mail__new__bulk_mail_id alias for $1; -- default to null
-    bulk_mail__new__package_id alias for $2;
-    bulk_mail__new__send_date alias for $3; -- default to null
-    bulk_mail__new__date_format alias for $4; -- default to "YYYY MM DD HH24 MI SS"
-    bulk_mail__new__status alias for $5; -- default to "pending"
-    bulk_mail__new__from_addr alias for $6;
-    bulk_mail__new__subject alias for $7; -- default to null
-    bulk_mail__new__reply_to alias for $8; -- default to null
-    bulk_mail__new__extra_headers alias for $9; -- default to null
-    bulk_mail__new__message alias for $10;
-    bulk_mail__new__query alias for $11;
-    bulk_mail__new__creation_date alias for $12; -- default to now()
-    bulk_mail__new__creation_user alias for $13; -- default to null
-    bulk_mail__new__creation_ip alias for $14; -- default to null
-    bulk_mail__new__context_id alias for $15; -- default to null
+-- old define_function_args('bulk_mail__new','bulk_mail_id,package_id,send_date,date_format,status;pending,from_addr,subject,reply_to,extra_headers,message,query,creation_date;now(),creation_user,creation_ip,context_id')
+-- new
+select define_function_args('bulk_mail__new','bulk_mail_id;null,package_id,send_date;null,date_format;to "YYYY MM DD HH24 MI SS",status;pending,from_addr,subject;null,reply_to;null,extra_headers;null,message,query,creation_date;now(),creation_user;null,creation_ip;null,context_id;null');
+
+
+
+
+--
+-- procedure bulk_mail__new/15
+--
+CREATE OR REPLACE FUNCTION bulk_mail__new(
+   bulk_mail__new__bulk_mail_id integer,      -- default to null
+   bulk_mail__new__package_id integer,
+   bulk_mail__new__send_date varchar,         -- default to null
+   bulk_mail__new__date_format varchar,       -- default to "YYYY MM DD HH24 MI SS"
+   bulk_mail__new__status varchar,            -- default to "pending" -- default 'pending'
+   bulk_mail__new__from_addr varchar,
+   bulk_mail__new__subject varchar,           -- default to null
+   bulk_mail__new__reply_to varchar,          -- default to null
+   bulk_mail__new__extra_headers varchar,     -- default to null
+   bulk_mail__new__message text,
+   bulk_mail__new__query varchar,
+   bulk_mail__new__creation_date timestamptz, -- default to now() -- default 'now()'
+   bulk_mail__new__creation_user integer,     -- default to null
+   bulk_mail__new__creation_ip varchar,       -- default to null
+   bulk_mail__new__context_id integer         -- default to null
+
+) RETURNS integer AS $$
+DECLARE
     v_bulk_mail_id integer;
     v_send_date varchar(4000);
     v_date_format varchar(4000);
     v_status varchar(100);
-begin
+BEGIN
 
     v_bulk_mail_id := acs_object__new(
         bulk_mail__new__bulk_mail_id,
-        ''bulk_mail_message'',
+        'bulk_mail_message',
         bulk_mail__new__creation_date,
         bulk_mail__new__creation_user,
         bulk_mail__new__creation_ip,
@@ -133,7 +143,7 @@
 
     v_date_format := bulk_mail__new__date_format;
     if v_date_format is null then
-        v_date_format := ''YYYY MM DD HH24 MI SS'';
+        v_date_format := 'YYYY MM DD HH24 MI SS';
     end if;
 
     v_send_date := bulk_mail__new__send_date;
@@ -144,7 +154,7 @@
 
     v_status := bulk_mail__new__status;
     if v_status is null then
-        v_status := ''pending'';
+        v_status := 'pending';
     end if;
 
     insert
@@ -161,21 +171,31 @@
 
     return v_bulk_mail_id;
 
-end;
-' language 'plpgsql';
+END;
 
-create or replace function bulk_mail__delete (integer)
-returns integer as '
-declare
-    bulk_mail__delete__bulk_mail_id alias for $1;
-begin
+$$ LANGUAGE plpgsql;
 
+
+
+-- added
+select define_function_args('bulk_mail__delete','bulk_mail_id');
+
+--
+-- procedure bulk_mail__delete/1
+--
+CREATE OR REPLACE FUNCTION bulk_mail__delete(
+   bulk_mail__delete__bulk_mail_id integer
+) RETURNS integer AS $$
+DECLARE
+BEGIN
+
     delete
     from bulk_mail_messages
     where bulk_mail_messages.bulk_mail_id = bulk_mail__delete__bulk_mail_id;
 
     perform acs_object__delete(bulk_mail__delete__bulk_mail_id);
 
-end;
-' language 'plpgsql';
+END;
 
+$$ LANGUAGE plpgsql;
+
