Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用ant运行包含set define off的sql文件_Ant - Fatal编程技术网

如何使用ant运行包含set define off的sql文件

如何使用ant运行包含set define off的sql文件,ant,Ant,我有一个dbobject.file,它依次调用几个dml、ddl和PRC。 我试图使用ant执行此文件,但它只需要sql语句,对set define和spool抛出错误。它使用sqlplus工作,但我想使用ant运行,因此调用此dbobject文件应执行dmls和DDL set define off spool dbobjects.log prompt calling D:\Pst1\Intel\tag\txt1.dml @"D:\Pst1\Intel\tag\txt1.dml" prompt

我有一个dbobject.file,它依次调用几个dml、ddl和PRC。 我试图使用ant执行此文件,但它只需要sql语句,对set define和spool抛出错误。它使用sqlplus工作,但我想使用ant运行,因此调用此dbobject文件应执行dmls和DDL

set define off
spool dbobjects.log
prompt calling D:\Pst1\Intel\tag\txt1.dml
@"D:\Pst1\Intel\tag\txt1.dml"
prompt calling D:\Pst\Intel\tag\txt2.dml
@"D:\Pst\Intel\tag\txt2.dml"
set define on

提前感谢。

从您的问题听起来,您好像在试图找出如何将Oracle sqlplus脚本转换为脚本

spool
set
都不是SQL命令,它们不会影响服务器,而是更改sqlplus在本地的操作方式。所以在蚂蚁的上下文中,它们没有任何意义。如果要在脚本中打印结果,可以使用
output=
属性执行大致类似的操作

如果您将sqlplus脚本转换为Ant,我希望它看起来像这样:

<sql driver="org.database.jdbcDriver" url="jdbc:database-url" userid="sa" password="pass"
    src="txt1.dml"
    output="dbobjects.log" />
<sql driver="org.database.jdbcDriver" url="jdbc:database-url" userid="sa" password="pass"
    src="txt2.dml"
    output="dbobjects.log"
    append="true" />

这将对数据库执行txt1.dml和txt2.dml作为一组SQL文件,并将生成的任何结果集保存到dbobjects.log中

这可能不适用于所有情况,尤其是当您依赖sqlplus提供的任何内容(如报表格式或嵌套导入)时。在这种情况下,您需要重写源文件以仅包含SQL