title: Oracle query and output to CSV
body: <p>I would like to seek for advice on how am I going to output the oracle query to csv with same wide format output from oracle query. 
  below is the excerpt from my code </p>
  
  <pre><code>[System.Reflection.Assembly]::LoadWithPartialName("System.Data.OracleClient") | Out-Null 
  $connection = New-Object System.Data.OracleClient.OracleConnection($connectionString) 
  $command = new-Object System.Data.OracleClient.OracleCommand($queryString, $connection) 
  $connection.Open() 
  $users = $command.ExecuteReader() 
  $Counter = $users.FieldCount 
  
  $dataset = 
    @(  while ($users.Read()) { 
           for ($i = 0; $i -lt $Counter; $i++) { 
         New-Object PsObject -Property @{ Key = $users.GetName($i)
                                         Value = $users.GetValue($i)
                                       }
                                       }
      }) 
  $connection.Close() 
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>PS C:\WINDOWS\system32&gt; $dataset
  
  Key             Value          
  ---             -----          
  PRCDNAME        A123rw-T03 
  ASSY_PART1      wrwrwee-A03  
  ASSY_PART2      wrewrwe-A0CAD
  ASSY_PART3      wer         
  ASSY_PART4                     
  ASSY_PART5                     
  ASSY_PART6                     
  OUTPN_1         rgsrggs-3     
  OUTPN_2                        
  OUTPN_3                        
  OUTPN_4                        
  OUTPN_5                        
  OUTPN_6                        
  OUTPN_7                        
  OUTPN_1_ALLOC1 
  </code></pre>
  
  <p>I want to format it as below. basically I need the Key column as the header</p>
  
  <pre><code>PRCDNAME,ASSY_PART1,ASSY_PART2 ,......,
  
  A123rw-T03,wrwrwee-A03,wrewrwe-A0CAD,....,    
  </code></pre>