4 Replies Latest reply on Apr 2, 2021 4:15 PM by Arya Nymeria

    Same source and target table to read and update? Can we?

    Arya Nymeria Active Member

      Hello friends, I have a requirement in such a way that I have to use the target table as source to get the key value and update the same table. The reason being is i need to pull the file date from stage table. Apparently i have to identify a record that exists in history table but not in stage table. so I am using the below sql.

       

      SELECT

      KEY,

      (SELECT FILE_DT FROM STAGE where rownum=1) AS FILE_DT

      FROM

      HISTORY H

      WHERE NOT EXISTS

      (SELECT HPC_NUM, NAME FROM STAGE S

        WHERE

      H.HPC_NUM =S.HPC_CODE

         AND

         H.NAME=S.NAME

         );

      So to avoid any locks because the data gets read and write to the same table, how to avoid table or db lock?

        This content has been marked as final.  Show 4 replies