title: SQLPlus conditional execution with variable from query
body: <p>I have a batch file which has many steps in it that will get executed one by one.</p>
  
  <p>However, to be able to make it more flexible, I want to include a condition check in <code>SQLPlus</code>.</p>
  
  <p>Something like, to get the conditional variables' value from a query first and store is in say <code>v_variable</code>. Then use it for some checks like</p>
  
  <pre><code>IF v_variable = 'Y' THEN
  --DO SOME DDL
  ELSE
  --DO OTHER DDL
  END IF
  </code></pre>
  
  <p>I have to repeat this block in many places in the batch file and I can't do it through a PL/SQL somehow.</p>
  
  <p>I am trying to use this <code>COLUMN</code> command in <code>SQLPlus</code> but somehow not getting the variable value to get saved.</p>
  
  <pre><code>COLUMN VARIABLE1 NEW_VALUE V_VARIABLE1
  
  SELECT PARAM_VAL AS VARIABLE1 FROM TABLE_T WHERE PARAM_TYPE =  'XYZ'; 
  -- This query will only throw one record.
  
  DEFINE V_VARIABLE1
  </code></pre>
  
  <p>Is that absolutely wrong? What do we do to see if the <code>V_VARIABLE1</code> is getting the value coming from the query?</p>
  
  <p>And even after I get it right I am clueless on the <code>IF-ELSE</code> part. Can anybody help here? I am interested in solution that works for SQLPlus.</p>