1

在 Apache Ant 中,我想替换文件中的字符串,但仅限于字符串的特定出现。我有一个 for 循环,我想只替换循环号出现(第一个循环找到第一个出现,第二个循环找到第二个字符串出现)与它关联的 for 循环参数值。

<exec executable="${postgres-bin-dir}/psql" outputproperty="update-primary-keys-values-@table">
   <arg line="-A -t --host ${source-target-comparison-hostname} --port 5432 --username 'postgres' -d ${source-target-comparison-databasename} -c &quot;array_to_string(ARRAY(select ${primary-keys-@{table}} from stage.@{table} t where t not in (select t from public.@{table} t) and t.${primary-keys-@{table}} not in (select ${primary-keys-@{table}} from stage.@{table} where ${primary-keys-@{table}} not in (select ${primary-keys-@{table}} from public.@{table})) order by ${primary-keys-@{table}}), ',')&quot;"/>
</exec>

<for list="${update-primary-keys-values-@table}" param="keys-values">
    <replace file="${updates-dir}/updates@{table}.sql" token=");" value=") WHERE ${primary-keys-@{table}} = @{keys-values};"/>
</for>
4

0 回答 0