简体   繁体   中英

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 ..

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM