我怎样才能读取一个SQL查询的输出到一只蚂蚁的财产? [英] How can I read output of an sql query into an ant property?
问题描述
我要养活一个简单的SQL查询的结果(是这样的:从SERVICE_PACK
选择SP_NUMBER),我我的ant脚本中运行(使用 SQL
任务)回蚂蚁资产(如 service.pack.number
)。
I would like to feed the result of a simple SQL query (something like: select SP_NUMBER from SERVICE_PACK
) which I run inside my ant script (using the sql
task) back into an ant property (e.g. service.pack.number
).
的 SQL
任务可以输出到文件,但有一个更直接的方法?
The sql
task can output to a file, but is there a more direct way?
推荐答案
虽然我早就preferred不是创建一个文件,我最终与以下解决方案了:
Although I would have preferred not creating a file, I eventually went with the following solution:
在SQL任务称为如下:
The sql task is called as follows
<sql ... print="yes" output="temp.properties"
expandProperties="true" showheaders="false" showtrailers="false" >
<![CDATA[
select 'current.sp.version=' || NAME from SERVICE_PACK;
select 'current.major.version=' || NAME from VERSION;
]]>
</sql>
生成的属性文件将包含:
The generated properties file will contain:
current.sp.version=03
current.major.version=5
然后你只需装入特性文件并将其删除:
Then you just load the properties file and delete it:
<property file="temp.properties" />
<delete file="temp.properties" />
<echo message="Current service pack version: ${current.sp.version}" />
<echo message="Current major version: ${current.major.version}" />
这工作,一切都是正确的,在Ant脚本(即使它不是世界上prettiest的事!)。
This works, and everything is right there in the ant script (even if it's not the prettiest thing in the world!).
这篇关于我怎样才能读取一个SQL查询的输出到一只蚂蚁的财产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!