--
-- party__new/8
--
create or replace function party__new(
  integer,
  character varying,
  timestamp with time zone,
  integer,
  character varying,
  character varying,
  character varying,
  integer
) returns int4 as $$

declare
  new__party_id               alias for $1;  -- default null  
  new__object_type            alias for $2;  -- default 'party'
  new__creation_date          alias for $3;  -- default now()
  new__creation_user          alias for $4;  -- default null
  new__creation_ip            alias for $5;  -- default null
  new__email                  alias for $6;  
  new__url                    alias for $7;  -- default null
  new__context_id             alias for $8;  -- default null
  v_party_id                  parties.party_id%TYPE;
begin
  v_party_id :=
   acs_object__new(new__party_id, new__object_type, new__creation_date, 
                   new__creation_user, new__creation_ip, new__context_id,
                   't', new__email, null);

  insert into parties
   (party_id, email, url)
  values
   (v_party_id, lower(new__email), new__url);

  return v_party_id;
  
end;$$ language plpgsql;