title: How to Generate Sqlplus to csv file?
body: <p>i am trying to generate the csv file out of oracle SQLPLUS by shell script, I am getting headers repeated multiple times and also null values are coming at the end of the line,</p>
  
  <pre><code>echo "****************************************************************"
  
  echo "Started may at : " $(date +"%r")
  
  sqlplus -s ETLUSER/ETL@//10.135.23.232:1521/ODS&lt;&lt;EOF &gt;/dev/null
  
  SPOOL wfa_may.csv
  
  SELECT MAC_ADDRESS ||','||
  CRM_BP_ID    || ',' || 
  EVENT_TIMESTAMP  || ',' || 
  ACCT_INPUT_OCTETS || ',' || 
  ACCT_OUTPUT_OCTETS || ',' || 
  ACCT_INPUT_PACKETS || ',' || 
  ACCT_OUTPUT_PACKETS || ',' || 
  ACCT_SESSION_TIME || ',' || 
  NAS_IDENTIFIER || ',' || 
  EXTRACTION_DATE || ',' || 
  RECORD_DATE || ',' || 
  LAST_MODIFIED_DATE || ',' || 
  ETL_BATCH_ID || ',' || 
  ETL_PROCESS_ID || ',' || 
  RECORD_LOAD_TIMESTAMP FROM DBAS.S_WFA_ACCOUNTING_MSG where to_char(EVENT_TIMESTAMP,'MON') = 'MAY';
  
  exit
  
  EOF
  
  echo "Ended may at : " $(date +"%r")
  
  echo  "****************************************************************"
  </code></pre>
  
  <p>from NAS_IDENTIFIER i am not able to find any values displayed in file.</p>
  
  <p>Can anyone help me whats wrong ?</p>