如何避免$$->;$在使用ant sql任务编译存储过程体后,是否替换存储过程体?
运行ant sql任务后,我的sql过程从:如何避免$$->;$在使用ant sql任务编译存储过程体后,是否替换存储过程体?,ant,Ant,运行ant sql任务后,我的sql过程从: create or replace procedure test is begin dbms_output.put_line($$plsql_line, 'demo'); end; 进入 Ant的任务是: <target name="test"> <record name="test-log" /> <sql userid="dev" password="dev"
create or replace procedure test
is
begin
dbms_output.put_line($$plsql_line, 'demo');
end;
进入
Ant的任务是:
<target name="test">
<record name="test-log" />
<sql userid="dev"
password="dev"
url="jdbc:oracle:thin:@192.168.1.1:1521:DEMODB"
keepformat="yes"
driver="oracle.jdbc.OracleDriver"
delimiter="/"
encoding="utf8"
escapeprocessing="false"
delimitertype="normal">
<fileset dir=".">
<include name="test.sql"/>
</fileset>
</sql>
</target>
如何强制Ant不将“$$”替换为“$”?请参见:
为了保持与旧Ant版本的向后兼容性,一个
在类似属性的构造之外遇到单个“$”字符
(包括一对匹配的法语大括号)将被解释
字面上也就是说,作为“$”。指定此文字的“正确”方式
然而,字符是通过使用转义机制来实现的
无条件地,以便通过指定“$$$”获得“$$”。混合
这两种方法会产生不可预测的结果,因为“$$$”会导致
“$$”
表示您需要使用$$$…
,请参阅:
<project>
<echo>
1.
create or replace procedure test
is
begin
dbms_output.put_line($$plsql_line, 'demo');
end;
</echo>
<echo>
2.
create or replace procedure test
is
begin
dbms_output.put_line($$$$plsql_line, 'demo');
end;
</echo>
</project>
--评论后编辑--
复制原始sql文件,然后使用编辑复制的文件,并使用编辑的文件运行sqltask:
<!-- copy ... -->
<replace dir="..." value="$$$$$$$$" token="$$$$">
<include name="**/*.sql"/>
</replace>
<!-- sql ... -->
问题是我有单独的.sql文件,我不想更改.sql内容,因为如果没有ant,它们将无法使用。
[echo] 1.
[echo] create or replace procedure test
[echo] is
[echo] begin
[echo] dbms_output.put_line($plsql_line, 'demo');
[echo] end;
[echo] 2.
[echo] create or replace procedure test
[echo] is
[echo] begin
[echo] dbms_output.put_line($$plsql_line, 'demo');
[echo] end;
<!-- copy ... -->
<replace dir="..." value="$$$$$$$$" token="$$$$">
<include name="**/*.sql"/>
</replace>
<!-- sql ... -->