title: Best way to dynamically get column names from oracle tables
body: <p>We are using an extractor application that will export data from the database to csv files. Based on some condition variable it extracts data from different tables, and for some conditions we have to use UNION ALL as the data has to be extracted from more than one table. So to satisfy the UNION ALL condition we are using nulls to match the number of columns. </p>
  
  <p>Right now all the queries in the system are pre-built based on the condition variable. The problem is whenever there is change in the table projection (i.e new column added, existing column modified, column dropped) we have to manually change the code in the application. </p>
  
  <p>Can you please give some suggestions how to extract the column names dynamically so that any changes in the table structure do not require change in the code?</p>
  
  <hr>
  
  <p>My concern is the condition that decides which table to query. The variable condition is 
  like </p>
  
  <ul>
  <li>if the condition is A, then load from TableX</li>
  <li>if the condition is B  then load from TableA and TableY.</li>
  </ul>
  
  <p>We must know from which table we need to get data.  Once we know the table it is  straightforward to query the column names from the data dictionary.  But there is one more condition, which is that some columns need to be excluded, and these columns are different for each table. </p>
  
  <p>I am trying to solve the problem only for dynamically generating the list columns. But my manager told me to make solution on the conceptual level rather than just fixing. This is a very big system with providers and consumers constantly loading and consuming data. So he wanted solution that can be general. </p>
  
  <p>So what is the best way for storing condition, tablename, excluded columns?  One way is storing in database.   Are there any other ways? If yes what is the best?  As I have to give at least a couple of ideas before finalizing.  </p>
  
  <p>Thanks, </p>