title: Exact fetch returns more than requested number of rows
body: <p>I'm trying to create a procedure to pass in the customer number and return the number of purchases and total value for purchases within the last year.  If there are no purchases, return zero for number and total and also return the number of contacts the salesmen had with that customer in the last year.</p>
  
  <p>I'm calling it as follows:</p>
  
  <pre><code>DECLARE 
        a_Var NUMBER;
        b_Var NUMBER;
        C_Var NUMBER;
        D_Var NUMBER;    
  BEGIN
        three_pr(001116,a_Var, b_Var);
  
      IF a_Var &gt; 0 THEN
          DBMS_OUTPUT.PUT_LINE('the number of purchases :' || a_Var);
          DBMS_OUTPUT.PUT_LINE('the total value of purchase :' || b_Var);
  
      ELSE
  
          SELECT ContactID,Count(contactID)
          INTO
               C_Var,D_Var
          FROM    DD_Contacts
          WHERE  DateofContact  between to_date ('2012/01/01', 'yyyy/mm/dd')
                 AND to_date ('2012/12/31', 'yyyy/mm/dd')
        Group By ContactID;
  
         DBMS_OUTPUT.PUT_LINE (C_Var||D_Var);
  
      END IF;
  
  END;
  /
  </code></pre>
  
  <p>When using the above code I get the error:</p>
  
  <blockquote>
    <p>ORA-01422: exact fetch returns more than requested number of rows ORA-06512: at line 16</p>
  </blockquote>
  
  <p>and here's the procedure:</p>
  
  <pre><code>CREATE or REPLACE PROCEDURE three_pr
  
  (par_CustomerID IN NUMBER, par_sumpurchase OUT Number,par_totalvalue OUT Number)
  IS
  BEGIN
  
          SELECT 
              COUNT(O.OrderID),SUM(Price*Quantity)
          INTO par_sumpurchase,par_totalvalue
              FROM DD_Orders O JOIN DD_OrderLine OL ON O.OrderID = OL.OrderID
              WHERE  DatePurchase  between to_date ('2012/01/01', 'yyyy/mm/dd')
              AND to_date ('2012/12/31', 'yyyy/mm/dd')
              AND CustomerID = par_CustomerID;
  
  END;
  /
  </code></pre>