-- -- rel_segment__get/2 -- create or replace function rel_segment__get( integer, character varying ) returns int4 as $$ declare get__group_id alias for $1; get__rel_type alias for $2; begin return min(segment_id) from rel_segments where group_id = get__group_id and rel_type = get__rel_type; end;$$ language plpgsql;