Index: openacs-4/packages/contacts-lite/sql/postgresql/contacts-plsql.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts-lite/sql/postgresql/contacts-plsql.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/contacts-lite/sql/postgresql/contacts-plsql.sql	20 Jan 2021 21:01:04 -0000	1.2
+++ openacs-4/packages/contacts-lite/sql/postgresql/contacts-plsql.sql	20 Jan 2021 21:07:14 -0000	1.3
@@ -2,55 +2,63 @@
 
 select acs_object_type__drop_type('contact', TRUE);
 
-create function inline_0 () 
-returns integer as '  
-begin 
+CREATE OR REPLACE FUNCTION inline_0 ()  RETURNS integer AS $$  
+BEGIN 
     PERFORM acs_object_type__create_type (  
-  ''contact'', -- object_type  
-  ''Contact'', -- pretty_name 
-  ''Contacts'', -- pretty_plural 
-  ''acs_object'',   -- supertype 
-  ''contacts'', -- table_name 
-  ''contact_id'', -- id_column 
+  'contact', -- object_type  
+  'Contact', -- pretty_name 
+  'Contacts', -- pretty_plural 
+  'acs_object',   -- supertype 
+  'contacts', -- table_name 
+  'contact_id', -- id_column 
   null, -- package_name 
-  ''f'', -- abstract_p 
+  'f', -- abstract_p 
   null, -- type_extension_table 
   null -- name_method 
   ); 
 
      return 0;  
-end;' language 'plpgsql'; 
+END;
+$$ LANGUAGE plpgsql; 
 
 select inline_0 (); 
 
 drop function inline_0 ();
 
-create or replace function contact__new (varchar, varchar, varchar, varchar, varchar, 
-    varchar, varchar, varchar, integer, integer, text, varchar, varchar, integer,varchar,integer,integer) 
-returns integer as ' 
-declare 
-  p_affix alias for $1; -- default 
-  p_given_name alias for $2; -- default 
-  p_family_name alias for $3; -- default 
-  p_middle_name alias for $4; -- default 
-  p_suffix alias for $5; -- default 
-  p_formatted_name alias for $6; -- default 
-  p_preferred_given_name alias for $7; -- default 
-  p_company_name alias for $8; -- default 
-  p_company_type_id alias for $9; -- default 
-  p_category_id alias for $10; -- default 
-  p_notes alias for $11; -- default 
-  p_email alias for $12;
-  p_title alias for $13;
-  p_creation_user alias for $14;
-  p_creation_ip alias for $15;
-  p_context_id alias for $16;
-  p_contact_id alias for $17;
+
+
+-- added
+select define_function_args('contact__new','affix,given_name,family_name,middle_name,suffix,formatted_name,preferred_given_name,company_name,company_type_id,category_id,notes,email,title,creation_user,creation_ip,context_id,contact_id');
+
+--
+-- procedure contact__new/17
+--
+CREATE OR REPLACE FUNCTION contact__new(
+   p_affix varchar,                -- default
+   p_given_name varchar,           -- default
+   p_family_name varchar,          -- default
+   p_middle_name varchar,          -- default
+   p_suffix varchar,               -- default
+   p_formatted_name varchar,       -- default
+   p_preferred_given_name varchar, -- default
+   p_company_name varchar,         -- default
+   p_company_type_id integer,      -- default
+   p_category_id integer,          -- default
+   p_notes text,                   -- default
+   p_email varchar,
+   p_title varchar,
+   p_creation_user integer,
+   p_creation_ip varchar,
+   p_context_id integer,
+   p_contact_id integer
+
+) RETURNS integer AS $$
+DECLARE 
   v_contact_id contacts.contact_id%TYPE; 
-begin 
+BEGIN 
   v_contact_id := acs_object__new (  
     p_contact_id,  
-    ''contact'', 
+    'contact', 
     now(), 
     p_creation_user, 
     p_creation_ip, 
@@ -71,43 +79,49 @@
   PERFORM acs_permission__grant_permission (
      v_contact_id,
      p_creation_user,
-     ''admin''
+     'admin'
   );
 
   return v_contact_id;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 -- need for non-complete import
-create or replace function contact__new (varchar, varchar, varchar, varchar, 
-    varchar, integer, integer,varchar, integer,varchar,integer) 
-returns integer as ' 
-declare 
-  p_given_name alias for $1; -- default 
-  p_family_name alias for $2; -- default 
-  p_middle_name alias for $3; -- default 
-  p_formatted_name alias for $4; -- default 
-  p_company_name alias for $5; -- default 
-  p_company_type_id alias for $6; -- default 
-  p_category_id alias for $7; -- default 
-  p_email alias for $8;
-  p_creation_user alias for $9;
-  p_creation_ip alias for $10;
-  p_context_id alias for $11;
 
+
+--
+-- procedure contact__new/11
+--
+CREATE OR REPLACE FUNCTION contact__new(
+   p_given_name varchar,      -- default
+   p_family_name varchar,     -- default
+   p_middle_name varchar,     -- default
+   p_formatted_name varchar,  -- default
+   p_company_name varchar,    -- default
+   p_company_type_id integer, -- default
+   p_category_id integer,     -- default
+   p_email varchar,
+   p_creation_user integer,
+   p_creation_ip varchar,
+   p_context_id integer
+
+) RETURNS integer AS $$
+DECLARE 
+
   v_contact_id contacts.contact_id%TYPE; 
   v_formatted_name contacts.formatted_name%TYPE;
-begin 
+BEGIN 
         if p_formatted_name is null 
         then
-          v_formatted_name := p_given_name || '' '' || p_family_name;
+          v_formatted_name := p_given_name || ' ' || p_family_name;
         else
           v_formatted_name := p_formatted_name;
         end if;  
 
   v_contact_id := acs_object__new (  
     null,  
-    ''contact'', 
+    'contact', 
     now(), 
     p_creation_user, 
     p_creation_ip, 
@@ -118,50 +132,56 @@
     (given_name, family_name, middle_name, formatted_name, 
      preferred_given_name, company_name, company_type_id,email, category_id, contact_id) 
   values
-    (p_given_name, p_family_name, p_middle_name,p_given_name || '' '' || p_family_name, 
+    (p_given_name, p_family_name, p_middle_name,p_given_name || ' ' || p_family_name, 
      p_given_name, p_company_name, p_company_type_id, p_email,p_category_id, v_contact_id);
 
 
   PERFORM acs_permission__grant_permission (
      v_contact_id,
      p_creation_user,
-     ''admin''
+     'admin'
   );
 
   return v_contact_id;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create or replace function contact__new (varchar, varchar, varchar, varchar, 
-    varchar, integer, integer,varchar, integer,varchar,integer,integer) 
-returns integer as ' 
-declare 
-  p_given_name alias for $1; -- default 
-  p_family_name alias for $2; -- default 
-  p_middle_name alias for $3; -- default 
-  p_formatted_name alias for $4; -- default 
-  p_company_name alias for $5; -- default 
-  p_company_type_id alias for $6; -- default 
-  p_category_id alias for $7; -- default 
-  p_email alias for $8;
-  p_creation_user alias for $9;
-  p_creation_ip alias for $10;
-  p_context_id alias for $11;
-  p_contact_id alias for $12;
 
+
+--
+-- procedure contact__new/12
+--
+CREATE OR REPLACE FUNCTION contact__new(
+   p_given_name varchar,      -- default
+   p_family_name varchar,     -- default
+   p_middle_name varchar,     -- default
+   p_formatted_name varchar,  -- default
+   p_company_name varchar,    -- default
+   p_company_type_id integer, -- default
+   p_category_id integer,     -- default
+   p_email varchar,
+   p_creation_user integer,
+   p_creation_ip varchar,
+   p_context_id integer,
+   p_contact_id integer
+
+) RETURNS integer AS $$
+DECLARE 
+
   v_contact_id contacts.contact_id%TYPE; 
   v_formatted_name contacts.formatted_name%TYPE;
-begin 
+BEGIN 
         if p_formatted_name is null 
         then
-          v_formatted_name := p_given_name || '' '' || p_family_name;
+          v_formatted_name := p_given_name || ' ' || p_family_name;
         else
           v_formatted_name := p_formatted_name;
         end if;  
 
   v_contact_id := acs_object__new (  
     p_contact_id,  
-    ''contact'', 
+    'contact', 
     now(), 
     p_creation_user, 
     p_creation_ip, 
@@ -172,60 +192,78 @@
     (given_name, family_name, middle_name, formatted_name, 
      preferred_given_name, company_name, company_type_id,email, category_id, contact_id) 
   values
-    (p_given_name, p_family_name, p_middle_name,p_given_name || '' '' || p_family_name, 
+    (p_given_name, p_family_name, p_middle_name,p_given_name || ' ' || p_family_name, 
      p_given_name, p_company_name, p_company_type_id, p_email,p_category_id, v_contact_id);
 
 
   PERFORM acs_permission__grant_permission (
      v_contact_id,
      p_creation_user,
-     ''admin''
+     'admin'
   );
 
   return v_contact_id;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 
-create or replace function contact__del (integer) 
-returns integer as ' 
-declare 
- p_contact_id    alias for $1; 
+
+
+-- added
+select define_function_args('contact__del','contact_id');
+
+--
+-- procedure contact__del/1
+--
+CREATE OR REPLACE FUNCTION contact__del(
+   p_contact_id integer
+) RETURNS integer AS $$
+DECLARE 
  v_return integer := 0;  
-begin 
+BEGIN 
 
    delete from acs_permissions 
      where object_id = p_contact_id; 
 
    delete from contacts 
      where contact_id = p_contact_id;
 
-   raise NOTICE ''Deleting contact...'';
+   raise NOTICE 'Deleting contact...';
 
    return v_return;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create or replace function contact__set (varchar, varchar, varchar, varchar, varchar, 
-    varchar, varchar, varchar, integer, integer, text, varchar, varchar, integer) 
-returns integer as ' 
-declare 
-  p_affix alias for $1; -- default 
-  p_given_name alias for $2; -- default 
-  p_family_name alias for $3; -- default 
-  p_middle_name alias for $4; -- default 
-  p_suffix alias for $5; -- default 
-  p_formatted_name alias for $6; -- default 
-  p_preferred_given_name alias for $7; -- default 
-  p_company_name alias for $8; -- default 
-  p_company_type_id alias for $9; -- default 
-  p_category_id alias for $10; -- default 
-  p_notes alias for $11; -- default 
-  p_email alias for $12;
-  p_title alias for $13;
-  p_contact_id alias for $14; -- default  
+
+
+-- added
+select define_function_args('contact__set','affix,given_name,family_name,middle_name,suffix,formatted_name,preferred_given_name,company_name,company_type_id,category_id,notes,email,title,contact_id');
+
+--
+-- procedure contact__set/14
+--
+CREATE OR REPLACE FUNCTION contact__set(
+   p_affix varchar,                -- default
+   p_given_name varchar,           -- default
+   p_family_name varchar,          -- default
+   p_middle_name varchar,          -- default
+   p_suffix varchar,               -- default
+   p_formatted_name varchar,       -- default
+   p_preferred_given_name varchar, -- default
+   p_company_name varchar,         -- default
+   p_company_type_id integer,      -- default
+   p_category_id integer,          -- default
+   p_notes text,                   -- default
+   p_email varchar,
+   p_title varchar,
+   p_contact_id integer            -- default
+
+) RETURNS integer AS $$
+DECLARE 
   v_return integer := 0; 
-begin 
+BEGIN 
 
   update contacts
   set family_name          = p_family_name,
@@ -243,9 +281,10 @@
       notes                = p_notes
   where contact_id = p_contact_id;
 
-  raise NOTICE ''Updating Contacts'';
+  raise NOTICE 'Updating Contacts';
 
   return v_return;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
