title: Oracle query to gets all COLUMN_NAMES during run-time and then fetch value from each ROW w.r.t. each column
body: <p>I want an Oracle sql query, which on runtime gets all COLUMN_NAMES from a particular TABLE and then use those COLUMN_NAMES to fetch value from each ROW,considering that I don't know the number and name of COLUMNS within the TABLE.</p>
  
  <p>TABLE1:</p>
  
  <pre><code>COLUMN_1, COLUMN_2, COLUMN_3, COLUMN_4
  
  value11 value12 value13 value14
  
  value21 value22 value23 value24
  ...
  </code></pre>
  
  <p>As a result of a sql query I am expecting an Insert statement corresponding to each row as follows:</p>
  
  <pre><code>INSERT INTO TABLE1 VALUES (value11,value12,value13,value14);
  
  INSERT INTO TABLE1 VALUES (value21,value22,value23,value24);
  </code></pre>
  
  <p>...</p>
  
  <p><strong>My approach so far is as follows</strong>:</p>
  
  <p><strong>QUERY 1</strong> </p>
  
  <p><code>SELECT 'INSERT INTO TABLE1 VALUES (' ||COLUMN_1 ||',' ||COLUMN_2 ||',' ||COLUMN_3 ||',' ||COLUMN_4 ||');' AS INSERTSCRIPT FROM TABLE1 ORDER BY COLUMN_1;</code></p>
  
  <p>Using this I get the desired insert statments, but the problem is "I want to avoid specifying the column names manually for each TABLE (as there are more than hundreds of such TABLES)".</p>
  
  <p><strong>So I have been trying next with</strong>:</p>
  
  <p><strong>QUERY 2</strong>)  </p>
  
  <p><code>SELECT LISTAGG(COLUMN_NAME, ', ') WITHIN GROUP (ORDER BY COLUMN_ID) FROM USER_TAB_COLS WHERE TABLE_NAME = 'TABLE1';</code></p>
  
  <p>which lists the columns as <code>COLUMN_1, COLUMN_2, COLUMN_3, COLUMN_4</code> but the problem is that I am not able to use this result in the QUERY_1</p>
  
  <p>Thanks in Advance!</p>