create or replace PROCEDURE LIST_PARTIES AS
  CURSOR parties_cursor is
   SELECT party_id, party_name
   from sos.parties
   order by party_id;
  prev char(2);
BEGIN
  prev := '??';
  for p in parties_cursor loop
    if p.party_id <> prev then
      if prev <> '??' then
        dbms_output.new_line;
      end if;
      dbms_output.put(p.party_id || ': ');
    else
      dbms_output.put(', ');
    end if;
    dbms_output.put(p.party_name);
    prev := p.party_id;
  end loop;
  dbms_output.new_line;
END LIST_PARTIES;