title: PL/SQL Error Return Multiple Rows
body: <p>I want to store some results in a temp table after I update a table but it is giving me an error for categories/book types that have multiple entries. Everything works fine when I try to do it with a book type that has one entry. Can someone tell me how I would fix this, I think it's got something to do with not having a filter although I'm not sure how I would do that.</p>
  
  <pre><code>DROP PROCEDURE UpdateAdvance;
  CREATE OR REPLACE PROCEDURE UpdateAdvance (
    p_BookType          titles.category%TYPE,
    p_NewAdvance        advance_temptable.new_advance%TYPE) AS
    CURSOR titles_cur IS
    SELECT *
    FROM titles
    WHERE category=p_BookType
    FOR UPDATE OF advance;
    titles_rec titles_cur%ROWTYPE;
    v_OldAdvance        titles.advance%TYPE;
    v_TitleID           titles.title_id%TYPE;
    v_Title             titles.title%TYPE;
  BEGIN
    SELECT advance, title_id, title
      INTO v_OldAdvance, v_TitleID, v_Title
      FROM titles
      WHERE category=p_BookType;
  
    FOR titles_rec in titles_cur LOOP  
        INSERT INTO advance_temptable VALUES(advance_sequence.nextval, v_TitleID, v_Title, v_OldAdvance, p_NewAdvance);
              END LOOP; 
      COMMIT;
  END UpdateAdvance;
  </code></pre>
  
  <p>When I call it like this</p>
  
  <pre><code>BEGIN
    UpdateAdvance('psychology', 100);
  END;
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>Error starting at line : 35 in command -
  BEGIN
    UpdateAdvance('psychology', 100);
  END;
  Error report -
  ORA-01422: exact fetch returns more than requested number of rows
  ORA-06512: at "SYSTEM.UPDATEADVANCE", line 14
  ORA-06512: at line 2
  01422. 00000 -  "exact fetch returns more than requested number of rows"
  *Cause:    The number specified in exact fetch is less than the rows returned.
  *Action:   Rewrite the query or change number of rows requested
  </code></pre>
  
  <hr>
  
  <p>Applied solution and here is what I now have working.</p>
  
  <pre><code>DROP PROCEDURE UpdateAdvance;
  CREATE OR REPLACE PROCEDURE UpdateAdvance (
    p_BookType          titles.category%TYPE,
    p_NewAdvance        advance_temptable.new_advance%TYPE) AS
  BEGIN
    INSERT INTO advance_temptable 
    select advance_sequence.nextval, title_id, title, advance, p_NewAdvance
    FROM titles
    WHERE category=p_BookType;
      COMMIT;
  END UpdateAdvance;
  
  BEGIN
    UpdateAdvance('psychology', 100);
  END;
  </code></pre>