--
-- membership_rel__new/7
--
create or replace function membership_rel__new(
  integer,
  character varying,
  integer,
  integer,
  character varying,
  integer,
  character varying
) returns int4 as $$

declare
  new__rel_id            alias for $1;  -- default null  
  rel_type               alias for $2;  -- default 'membership_rel'
  object_id_one          alias for $3;  
  object_id_two          alias for $4;  
  new__member_state      alias for $5;  -- default 'approved'
  creation_user          alias for $6;  -- default null
  creation_ip            alias for $7;  -- default null
  v_rel_id               integer;       
begin
    v_rel_id := acs_rel__new (
      new__rel_id,
      rel_type,
      object_id_one,
      object_id_two,
      object_id_one,
      creation_user,
      creation_ip
    );

    insert into membership_rels
     (rel_id, member_state)
    values
     (v_rel_id, new__member_state);

    return v_rel_id;
   
end;$$ language plpgsql;


--
-- membership_rel__new/2
--
create or replace function membership_rel__new(
  integer,
  integer
) returns int4 as $$

declare
  object_id_one          alias for $1;  
  object_id_two          alias for $2;  
begin
        return membership_rel__new(null,
                                   'membership_rel',
                                   object_id_one,
                                   object_id_two,
                                   'approved',
                                   null,
                                   null);
end;$$ language plpgsql;