title: Mixing DDL and DML statements in a single script
body: <p>I'm writing a script that will add an ID column to a table, including all the sequences and triggers to keep it automatically up to date. It will perform the following:</p>
  
  <ul>
  <li>Add a column to a table</li>
  <li>Create a sequence</li>
  <li>Create a trigger</li>
  <li><strong>Update existing rows to use sequence values</strong></li>
  <li>Set the field to not nullable</li>
  </ul>
  
  <p>The problem I have is with the line in bold - it would be an <code>UPDATE</code> statement in a DDL script. The error I get is:</p>
  
  <blockquote>
    <p>PLS-00103: Encountered the symbol "UPDATE"</p>
  </blockquote>
  
  <p>I've tried wrapping the <code>UPDATE</code> in a <code>BEGIN</code> and <code>END</code> block, with no success.</p>
  
  <p>Is it possible to include an <code>UPDATE</code> statement in a DDL script?</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>ALTER TABLE RETAILER ADD (RETAILER_ID NUMBER );
  
  CREATE SEQUENCE RETAILER_ID_SEQ;
  
  CREATE OR REPLACE TRIGGER RETAILER_ADD_TRG
  BEFORE INSERT ON RETAILER
  FOR EACH ROW
  BEGIN
    SELECT RETAILER_ID_SEQ.NEXTVAL INTO :new.RETAILER_ID FROM dual;
  END;
  
  -- Doesn't like this part...
  UPDATE RETAILER SET RETAILER_ID = RETAILER_ID_SEQ.NEXTVAL;
  COMMIT;
  
  ALTER TABLE RETAILER MODIFY (RETAILER_ID NOT NULL);
  </code></pre>