title: Oracle: conditionally run a SELECT within a WITH clause
body: <p>We have a fairly lengthy stored proc (Oracle 12) that contains as series of WITH clauses that build on one another in this fashion:</p>
  
  <pre><code>WITH temp1 AS (SELECT ... FROM tableA WHERE ...),
  WITH temp2 AS (SELECT ... FROM temp1, tableB WHERE ...),
  WITH temp3 AS (SELECT ... FROM temp2, tableC WHERE ...),
  </code></pre>
  
  <p>with a final SELECT being done from the temp3 entity</p>
  
  <pre><code>SELECT ... FROM temp3;
  </code></pre>
  
  <p>This works but recently we've been asked to 'bookend' the final select so that it has a dummy first row, and a dummy last row. Ie if 'temp3' contains three rows then the final SELECT would return 5 rows including the two dummy rows. However if temp3 contains no data then the two dummy rows should not appear either and user gets back an empty record set.</p>
  
  <p>How could we go about bookending the final select if temp3 contains data, but return an empty recordset if temp3 has now rows?</p>