-- orders2.sql

CREATE OR REPLACE PROCEDURE count_po2(
  total OUT NUMBER,
  start_dt DATE DEFAULT '01-JAN-96',
  end_dt DATE DEFAULT NULL)
AS
BEGIN
  IF end_dt IS NULL THEN
    SELECT count(po_number)
      INTO total
      FROM po_header
     WHERE order_date >= start_dt;
  ELSE
    SELECT count(po_number)
      INTO total
      FROM po_header
     WHERE order_date BETWEEN start_dt AND end_dt;
  END IF;
END count_po2;
/
