Index: openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql,v
diff -u -r1.7 -r1.7.4.1
--- openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql	27 Mar 2009 22:55:23 -0000	1.7
+++ openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql	18 Aug 2014 20:54:39 -0000	1.7.4.1
@@ -5,35 +5,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 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','new__bulk_mail_id;to null,new__package_id,new__send_date;to null,new__date_format;to "YYYY MM DD HH24 MI SS",new__status;pending,new__from_addr,new__subject;to null,new__reply_to;to null,new__extra_headers;to null,new__message,new__query,new__creation_date;now(),new__creation_user;to null,new__creation_ip;to null,new__context_id;to 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,
@@ -42,7 +52,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;
@@ -53,7 +63,7 @@
 
     v_status := bulk_mail__new__status;
     if v_status is null then
-        v_status := ''pending'';
+        v_status := 'pending';
     end if;
 
     insert
@@ -70,15 +80,24 @@
 
     return v_bulk_mail_id;
 
-end;
-' language 'plpgsql';
+END;
 
-create 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','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;
@@ -87,5 +106,6 @@
 
     return 0;
 
-end;
-' language 'plpgsql';
+END;
+
+$$ LANGUAGE plpgsql;
