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

declare
        nam     alias for $1;
        sid1    alias for $2;
        side    alias for $3;
        sid2    alias for $4;
begin
        return rel_constraint__new(null,
                                   'rel_constraint',
                                   nam,
                                   sid1,
                                   side,
                                   sid2,
                                   null,
                                   null,
                                   null
                                   );                                   
end;$$ language plpgsql;


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

declare
  new__constraint_id          alias for $1;  -- default null  
  new__constraint_type        alias for $2;  -- default 'rel_constraint'
  new__constraint_name        alias for $3;  
  new__rel_segment            alias for $4;  
  new__rel_side               alias for $5;  -- default 'two'
  new__required_rel_segment   alias for $6;  
  new__context_id             alias for $7;  -- default null
  new__creation_user          alias for $8;  -- default null
  new__creation_ip            alias for $9;  -- default null
  v_constraint_id             rel_constraints.constraint_id%TYPE;
begin
    v_constraint_id := acs_object__new (
      new__constraint_id,
      new__constraint_type,
      now(),
      new__creation_user,
      new__creation_ip,
      new__context_id,
      't',
      new__constraint_name,
      null
    );

    insert into rel_constraints
     (constraint_id, constraint_name, 
      rel_segment, rel_side, required_rel_segment)
    values
     (v_constraint_id, new__constraint_name, 
      new__rel_segment, new__rel_side, new__required_rel_segment);

     return v_constraint_id;
   
end;$$ language plpgsql;