.sql文件不返回在CSV文件中的列标题 [英] .sql file not returning the column headers in csv file
问题描述
下面code是在批处理文件脚本(.bat文件),它调用SQL文件。
The below code is in batch file script(.bat file) which calls the sql file.
del C:\SREE\csvfile.csv
sqlplus SERVERNAME/Test123@ldptstb @C:\SREE\sree.sql
set from_email="SENDER_EMAIL_ID"
set to_email="TO_EMAIL_ID"
set cc_email="CC_EMAIL_ID"
set email_message="Csv file from application server"
set body_email=C:\SREE\sree.txt
set sendmail=C:\Interface\sqlldr\common\SENDMAIL.VBS
set interface_log=C:\SREE\csvfile.csv
cscript %sendmail% -F %from_email% -T %to_email% -C %cc_email% -S %email_message% -B %body_email% -A %interface_log% -O "ATTACHFILE" -A %body_email% -O "FILEASTEXT"
exit
这在下面的内容中.sql文件code,其执行SQL查询和存储数据为CSV文件:
This below content in .sql file code which executes the SQL Query and stores the data into csv file:
set pagesize 0
set heading on
set feedback off
set trimspool on
set linesize 32767
set termout off
set verify off
set colsep ","
spool C:\SREE\csvfile.csv
SELECT Name, ID, Email, Role, Status FROM csvfile
exit
的输出保存在csv文件和获取电子邮件文件。
The output is stored in csv file and getting this file in email.
但theproblem是我没有在CSV文件中得到的列名。我曾在许多情况下试图让名称为csv文件一个cloumn标题。
But theproblem is I am not getting the Column Names in the csv file. I had tried in many scenarios to get the names as a cloumn headings in csv file.
任何人都请帮我用code获得CSV文件中的列名..谢谢了... ...
Anyone please help me out with the code to get the column names in the csv file.. thanks in advance...
推荐答案
在设置页面大小0
的标题是燮pressed :
SET PAGES [IZE] {14 | N} 结果
设置输出的每一页上的行数。您可以设置 PAGESIZE
零共进晚餐preSS所有的标题,分页符,标题,最初的空行,和其他格式的信息。
SET PAGES[IZE] {14 | n}
Sets the number of lines on each page of output. You can setPAGESIZE
to zero to suppress all headings, page breaks, titles, the initial blank line, and other formatting information.
是这样的话,即使你再明确在
集的标题。
That's the case even if you then explicitly set headings on
.
您可以设置页面大小
来的东西非常大的,而不是,或可能更有益因为你可能真的不希望破折号的分隔线,自己与他们产生:
You can either set pagesize
to something very large instead, or possibly more helpfully as you probably don't really want the separator line of dashes, generate them yourself with:
PROMPT Name,ID,Email,Role,Status
...在你的选择
语句。
这篇关于.sql文件不返回在CSV文件中的列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!