create or replace
PROCEDURE showPZrep(
	id_in IN poles_zeros.pz_key%TYPE,
	nbz   IN integer,
	nbp   IN integer,
	addz  IN integer
 )
IS
	rtype      pz_data.type%TYPE;
	value1     string(15);
	value2     string(15);
	value3     string(15);
	value4     string(15);
	rep1       integer;
	rep2       integer;
	lineno     integer;

	CURSOR cr_repeat_pz IS
		SELECT  type,
			to_char(r_value,'S0.99999EEEE'),
			to_char(i_value,'S0.99999EEEE')
		FROM PZ_Data
		WHERE key = id_in
		ORDER BY row_key;

BEGIN
	DBMS_OUTPUT.enable(1000000);
	rep1 := 1;
	rep2 := 1;

	IF (nbz = 0) THEN
		DBMS_OUTPUT.PUT_LINE('ZEROS   ' || addz);
		FOR Lcntr IN 1..addz
		LOOP
			DBMS_OUTPUT.PUT_LINE('        +0.00000E+00    +0.00000E+00');
		END LOOP;
	END IF;

	IF NOT cr_repeat_pz%ISOPEN THEN
		OPEN cr_repeat_pz;
	END IF;

	FETCH cr_repeat_pz into rtype, value1, value2;

	WHILE cr_repeat_pz%FOUND
	LOOP
		IF( (rep1 = 1 ) and (rtype = 'Z') ) THEN
			DBMS_OUTPUT.PUT_LINE('ZEROS   ' || to_char(nbz+addz));
			FOR Lcntr IN 1..addz
			LOOP
				DBMS_OUTPUT.PUT_LINE('        +0.00000E+00    +0.00000E+00');
			END LOOP;
			rep1 := 0;
			lineno := 0;
		END IF;
		IF( (rep2 = 1 ) and (rtype = 'P') ) THEN
			DBMS_OUTPUT.PUT_LINE('POLES   ' || nbp);
			rep2 := 0;
			lineno := 0;
		END IF;
		DBMS_OUTPUT.PUT_LINE( '       ' || value1 || '   ' || value2 );
		FETCH cr_repeat_pz into rtype, value1, value2;
		lineno := lineno + 1;
	END LOOP;
	close cr_repeat_pz;
END;
