How can I create a CSV file from PL/Sql in UNIX?

Can someone help me on creating a script that will manage/create a csv file from Pl/Sql using UNIX?Any advice is welcome,thank you so much,:slight_smile:

I assume you have a query and you want its output as csv.
try something like,

## create sql file
echo "
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 320
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
set TERM OFF
spool output.csv
select COL1 ||','||COL2||','||COL3 from TABLE1;
SPOOL OFF;
QUIT
" > file.sql

# connecting to database a execute the sql file
sqlplus $user/$passwd@$sid @file.sql

This is not tested. so please run for sample data first.

Oh,thank you so much anchal_khare I appreciate your help,and I'll try it.