title: Record Processing If Record Exists UPDATE, INSERT in PLSQL
body: <pre><code>I have three tables:
  
  CUSTOMER                   Columns (Tracking)                            
  Reference              Columns (Ref_Tracking, Project)
  PROJECT                     Columns(Project)
  </code></pre>
  
  <p>I need to check Reference to see if records in a column (Tracking) from CUSTOMER exist in Reference (Ref_Tracking).  Then Check if the associated record from Reference (Project) Exists in PROJECT (Project).</p>
  
  <pre><code>If they exist UPDATE PROJECT 
  SET PROJECT.NAME = CURSOR VARIABLES 
          ETC
          ETC
  
  If they do not exist
  INSERT INTO REFERENCE
  VALUES (CURSOR VALUES)
  </code></pre>
  
  <p>I have a cursor that is looping through with all the variables for Customer Table.</p>
  
  <p>I have tried below but no data is being populated I am not sure what I am doing wrong, Or if there is a better way to do it.  Im learning pl/sql so not sure if I am on the right track.</p>
  
  <pre><code>    CREATE OR REPLACE PROCEDURE P1
      AS
        V_NAME            CUSTOMER.NAME%TYPE;
        V_TRACKING        CUSTOMER.TRACKING%TYPE;
        V_ADDRESS         CUSTOMER.ADDRESS%TYPE;
        V_CITY            CUSTOMER.CITY%TYPE;
        V_STATE           CUSTOMER.STATE%TYPE;
        V_NUMBER          CUSTOMER.NUMBER%TYPE;
        V_ Ref            Reference.REF_TRACKING%TYPE := NULL;
        V_Project         REFERENCE.PROJECT%TYPE := NULL;
        V_Project_2       PROJECT.PROJECT%TYPE := NULL;
  
        CURSOR C01
           IS
              SELECT  C.Name,
                      C.Tracking,
                      C.Address,
                      C.City,
                      C.State,
                      C.Number
                FROM  Customer
               WHERE  C.Number = Another_Table;
      BEGIN
        FOR fetchc01 IN C01 
        LOOP
          BEGIN
            Select Ref_Tracking, R.Project, P.Project
              Into V_ Ref, V_Project, V_Project_2
              From Customer C, Reference R, Project P
             Where R.Project = P.Project
               AND Tracking = Ref_Tracking;
          EXCEPTION
             WHEN TOO_MANY_ROWS
             THEN
                NULL;
             WHEN NO_DATA_FOUND
             THEN
                NULL;
          END;
  
          BEGIN
            IF V_Ref = fetch01.Tracking
            Then 
              Insert Into Sample_Project
                VALUES (V_Name, V_Tracking, V_Location)
          END
       END LOOP;
     END;
  </code></pre>