1 #!/bin/ksh
2
3 for tableName in `cat table.lst`
4 do
5 echo "set echo off" > t1.sql
6 echo "set heading off" >> t1.sql
7 echo "set pagesize 0" >> t1.sql
8 echo "set verify off" >> t1.sql
9 echo "set feedback off" >> t1.sql
10 echo "set linesize 130" >> t1.sql
11 echo "set trimspool on" >> t1.sql
12 echo "define tableName=$tableName" >> t1.sql
13 echo "spool t2.sql" >> t1.sql
14 echo "select 'set echo off' from dual;" >> t1.sql
15 echo "select 'set heading off' from dual;" >> t1.sql
16 echo "select 'set pagesize 0' from dual;" >> t1.sql
17 echo "select 'set verify off' from dual;" >> t1.sql
18 echo "select 'set feedback off' from dual;" >> t1.sql
19 echo "select 'set linesize 130' from dual;" >> t1.sql
20 echo "select 'set trimspool on' from dual;" >> t1.sql
21 echo "select 'spool &tableName.csv' from dual;" >> t1.sql
22 echo "select 'select ' from sys.dual;" >> t1.sql
23 echo "select decode(column_id,1,column_name, '||'',''||'||column_name)" >> t1.sql
24 echo "from sys.dba_tab_columns" >> t1.sql
25 echo "where table_name = '&tableName'" >> t1.sql
26 echo "order by column_id;" >> t1.sql
27 echo "select 'from &tableName;'" >> t1.sql
28 echo "from sys.dual;" >> t1.sql
29 echo "select 'spool off' from dual;" >> t1.sql
30 echo "spool off" >> t1.sql
31
32 sqlplus -S vep/rkaus60 < t1.sql
33
34 sqlplus -S vep/rkaus60 < t2.sql
35 done |