create or replace
PROCEDURE showb58resp(
	in_network   IN sensitivity.net%TYPE,
        in_station   IN sensitivity.sta%TYPE,
        in_location  IN sensitivity.location%TYPE,
        in_channel   IN sensitivity.seedchan%TYPE,
        starttime    IN varchar2,
        endtime      IN varchar2,
        in_stage     IN sensitivity.stage_seq%TYPE
 )
IS
	sens_gain    sensitivity.sensitivity%TYPE;
	frequency    sensitivity.frequency%TYPE;

	CURSOR cr_sensitivity IS
		SELECT sensitivity, frequency
		FROM   Sensitivity
		WHERE
		net = in_network AND 
		sta = in_station AND 
		location = in_location AND
		seedchan = in_channel AND
		to_date(starttime,'MM/DD/YYYY HH24:MI:SS') >= ondate AND
		to_date(starttime,'MM/DD/YYYY HH24:MI:SS') < offdate AND
		stage_seq = in_stage;

BEGIN
	DBMS_OUTPUT.enable(1000000);

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

	FETCH cr_sensitivity into sens_gain, frequency;

	DBMS_OUTPUT.PUT_LINE('#');
	DBMS_OUTPUT.PUT_LINE('#                  +-----------------------------------+');
	DBMS_OUTPUT.PUT_LINE('#                  |      Channel Sensitivity/Gain     |' );
	DBMS_OUTPUT.PUT_LINE('#                  |        '
				|| rpad(in_network,2,' ')
				|| '  ' || rpad(in_station,5,' ')
				|| '  ' || rpad(in_location,2,' ')
				|| '  ' || in_channel || '         |' );
	DBMS_OUTPUT.PUT_LINE('#                  |     ' || to_char(to_date(starttime,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY') || ' to '
								|| to_char(to_date(endtime,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY') || '      |' );
	DBMS_OUTPUT.PUT_LINE('#                  +-----------------------------------+');
	DBMS_OUTPUT.PUT_LINE('#');
	DBMS_OUTPUT.PUT_LINE( 'B058F03     Stage sequence number:                 ' || in_stage );
	DBMS_OUTPUT.PUT_LINE( 'B058F04     Sensitivity:                          ' || to_char(sens_gain,'S0.99999EEEE') );
	DBMS_OUTPUT.PUT_LINE( 'B058F05     Frequency of sensitivity:             ' || to_char(frequency,'S0.99999EEEE') );
	DBMS_OUTPUT.PUT_LINE( 'B058F06     Number of calibrations:                0' );

	close cr_sensitivity;
END;
