title: SQL - Update not working inside a cursor loop
body: <p>I have three tables namely <code>Issue</code>, <code>IssueReports</code> and <code>Location</code> with the below structure.</p>
  
  <p>Issue and Location has Many-to-one relationship. Issue and IssueReports are not physically linked but can have some common fields.</p>
  
  <pre><code>IssueReports
  -------------
  ID (Number); 
  Issue_Number (Varchar); 
  Issue_Loc_Name (Varchar)
  and some other fields for the report....
  
  Issue
  -----------------
  ID (Number);
  IssueNumber (Varchar);
  Issue_Loc_Id (Number)
  
  Location
  -----------------
  ID (Number);
  Loc_Name (Varchar)
  </code></pre>
  
  <p>I want to update <code>Issue_Loc_Name</code> field in multiple rows of <code>IssueReports</code> with <code>Loc_Name</code> where the <code>IssueNumber</code> of Issue table and <code>IssueNumber</code> of <code>IssueReport</code> table are equal.</p>
  
  <p>I have written the below procedure to update multiple records based on the condition given above, but what I get is the same value for all the <code>Issue_Loc_name</code> of multiple rows of the table <code>IssueReport</code>.</p>
  
  <pre><code>DECLARE
     IR_LOCNAME    VARCHAR2(10);
     IRNUM_TO_SEARCH VARCHAR2(10);
     ISNUM_TOSEARCH VARCHAR2(10);
     Cursor c1 is select ir.Issue_Number, is.IssueNumber, loc.loc_name
      from IssueReports ir, Issue is, Location loc
      where loc.id = is.Issue_Loc_Id
                  AND ir.Issue_Number = is.IssueNumber;      
  BEGIN
     OPEN c1;
     LOOP
        FETCH c1 INTO IRNUM_TO_SEARCH, ISNUM_TOSEARCH, IR_LOCNAME;
        DBMS_OUTPUT.put_line(IRNUM_TO_SEARCH || ' ' || ISNUM_TOSEARCH || ' ' || IR_LOCNAME);
        EXIT WHEN c1%NOTFOUND;
        UPDATE IssueReports SET Issue_Loc_Name = IR_LOCNAME;
               WHERE IRNUM_TO_SEARCH = ISNUM_TOSEARCH;
     END LOOP;
     CLOSE C1;
  END;
  /
  </code></pre>
  
  <p>Is there something wrong in my cursor? I am using Oracle 11G.</p>
  
  <p>Best Regards,
  MouliPC.</p>