create or replace procedure test is res number := 0; begin dbms_output.put_line('Test date: 10-09-2009'); res := emp_count(to_date('10-09-2009', 'dd-mm-yyyy')); dbms_output.put_line('Result: ' || res); dbms_output.put_line('Records: '); for vres in ( select * from emp_work_ranges where to_date('10-09-2009', 'dd-mm-yyyy') between employment_date and decode(dismissal_date,'',sysdate,dismissal_date) ) loop dbms_output.put_line(vres.id || ' ' || vres.emp_id || ' ' || vres.employment_date || ' ' || vres.dismissal_date); end loop; end; /