Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bat file command for Write exact plsql query output into csv file

I want to execute query from batch file and put exact output of query into csv file. Like: my query is : select sysdate from dual. Output of this :

Sysdate
23-feb-2013

So, in csv it stored as

sysdate
22-feb-2013

DB: Oracle 11g OS: windows 7

Kindly plz help me to achieve this ..

like image 793
Water Avatar asked Dec 17 '25 18:12

Water


1 Answers

c:\myfolder\mybatch.bat:

call sqlplus oracleuser/oraclepwd@oracledb @c:\myfolder\myquery.sql

c:\myfolder\myquery.sql:

set head off
set feed off
set pagesize 0
spool c:\myfolder\myresult.csv
prompt sysdate
select to_char(sysdate, 'dd-mon-yyyy') from dual;
spool off
set head on
set feed 6
quit
like image 130
Donato Szilagyi Avatar answered Dec 20 '25 09:12

Donato Szilagyi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!