title: Oracle SQL Developer - Using Variables in Insert/Select
body: <p>Using Oracle SQL Developer.  I have the following sample working: </p>
  
  <pre><code>DECLARE
      v_next_TransId INTEGER; -- declare
  BEGIN
      select (max(Transaction_ID)+1) into v_next_TransId from xxpos.pos_transactions;
      dbms_output.Put_line(v_next_TransId); --display
  
  END;
  </code></pre>
  
  <p>Now I want to use that variable in an insert and/or select, I tried with and without a : prefix.  The sample below gives me the ORA-01008: not all variables found. </p>
  
  <pre><code>DECLARE
      v_next_TransId INTEGER; -- declare 
  BEGIN
      select (max(Transaction_ID)+1) into v_next_TransId from xxpos.pos_transactions;
      dbms_output.Put_line(v_next_TransId); --display
  
      -- insert new row will go here 
      -- commit will go here 
      -- now verify the insert worked okay 
      --select * from xxpos.pos_transactions where Transaction_ID = ( select max(Transaction_ID) from xxpos.pos_transactions )
      select * from xxpos.pos_transactions where Transaction_ID = :v_next_TransId;
  
  END;
  </code></pre>
  
  <p>Without the : in front of the variable, I get this syntax error: 
  <a href="https://i.stack.imgur.com/jGX8S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jGX8S.png" alt="enter image description here"></a></p>
  
  <p>Versions: </p>
  
  <p>Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production</p>
  
  <p>PL/SQL Release 11.2.0.4.0 - Production</p>