shell - How can store sqlplus query in a file in formatted manner and display it to console up vote -


i trying write script connect database , store query output in file in formatted manner

my expected file below:

last                         monthly name                          salary  commission ------------------------- ----------  ---------- russell                        14000         .4 partners                       13500         .3 errazuriz                      12000         .3 cambrault                      11000         .3 zlotkey                        10500         .2 

so far have tried this.

sqlplus user/password@(tns entry) << eof set head off; set feed off; set trimspool on; set linesize 32767; set pagesize 32767; set echo off; set termout off; set verify off; set newpage none; set verify off; spool file_name.csv select * customer; spool off  exit; eof 

i trying display csv file console. but, not in formatted style.

how can achieve ?

you need add in , seperator e.g.

sqlplus user/password@(tns entry) << eof set head off; set feed off; set trimspool on; set linesize 32767; set pagesize 32767; set echo off; set termout off; set verify off; set newpage none; set verify off; spool file_name.csv select last_name  || ',' || monthly_salary || ',' || commission customer; spool off  exit; eof 

or can add

set colsep ,  

to script instead.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -