ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guttula, Mohan" <MGutt...@tiaa-cref.org>
Subject Looping through a file contents and dynamically add <transaction> for each line in the file to <SQL> task
Date Thu, 06 Apr 2006 20:05:26 GMT
Hello All,

 

I have a "sample.sql" file (this file contents change dynamically) that
contains the following lines:

------

release\Country.sql

release\State.sql

release\City.sql

-------

 

<target name="sql-oracle">

<sql

                        driver="oracle.jdbc.driver.OracleDriver"

                        delimiter="/"

                        delimitertype="row"

                        keepformat="true"

 
url="jdbc:oracle:thin:@${machine_name}:1521:${database_Instance_name}"

                        userid="${user_name}"

                        password="${password}"

                        >

                        <transaction src=" release\Country.sql"/>

<transaction src=" release\State.sql"/>

<transaction src=" release\City.sql"/>

                        <classpath>

                                    <pathelement
location="C:/oracle/ora92/jdbc/lib/classes12.jar"/>      

                                    <fileset
dir="C:/apache-ant-1.6.5/lib">

                                    <include name="**/*.jar"/>

                                    </fileset>

                        </classpath>

            </sql>

</target>

 

I have found following loop through logic from
http://www.ant-tasks.com/msg/17209.html

-----

<macrodef name="foreach-line">

<attribute name="file" />

                        <attribute name="var" default="line" />

                        <element name="body" implicit="true" />

                        <sequential>

                                    <loadfile property="lines4@{file}"
srcfile="@{file}" />

                                    <for delimiter="${line.separator}"
param="@{var}" list="${lines4@{file}}">

                                                <sequential>

                                                            <body />

                                                </sequential>

                                    </for>

                        </sequential>

</macrodef>

-----

 

How can I use the above "microdef" and dynamically add <transaction> for
each line in "sample.sql" to the target "sql-oracle" ( I have to follow
order of the lines in the "sample.sql")?

Is there a better way to achieve what I want using some other task? 

 

Thanks,

Mohan

 



**************************************************************
This message, including any attachments, contains confidential information intended for a
specific individual and purpose, and is protected by law.  If you are not the intended recipient,
please contact sender immediately by reply e-mail and destroy all copies.  You are hereby
notified that any disclosure, copying, or distribution of this message, or the taking of any
action based on it, is strictly prohibited.
TIAA-CREF
**************************************************************


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message