title: Oracle Atomic Stored Procedure
body: <p>I am working on writing a stored procedure in Oracle that will refresh a table that contains denormalized data.  The outline of the procedure is:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE loadDenormalizedTable IS
  BEGIN
  
  DELETE FROM denormalizedTable;
  
  INSERT INTO
      denormalizedTable
      (
          data
      )
  SELECT DISTINCT
      data
  FROM
      normalizedTables;
  
  END;
  /
  </code></pre>
  
  <p>I want all of this to happen in a transaction so that there will always be data in the table.  Right now the delete runs and the table is empty for a few minutes until the insert is finished.  What is the best way to handle this type of table refresh without having any down time?</p>