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

declare
  new__person_id              alias for $1;  -- default null  
  new__object_type            alias for $2;  -- default 'person'
  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__first_names            alias for $8; 
  new__last_name              alias for $9;  
  new__context_id             alias for $10; -- default null 
  v_person_id                 persons.person_id%TYPE;
begin
  v_person_id :=
   party__new(new__person_id, new__object_type,
             new__creation_date, new__creation_user, new__creation_ip,
             new__email, new__url, new__context_id);

  update acs_objects
  set title = new__first_names || ' ' || new__last_name
  where object_id = v_person_id;

  insert into persons
   (person_id, first_names, last_name)
  values
   (v_person_id, new__first_names, new__last_name);

  return v_person_id;
  
end;$$ language plpgsql;