ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: Looping through a file contents and dynamically add <transaction> for each line in the file to <SQL> task
Date Fri, 07 Apr 2006 11:19:03 GMT
1. Create a child project
  - input: the names of the sql files
  - create a project.xml file containing just that target
2. use <antcall> to call that (new) project

Jan 

>-----Urspr√ľngliche Nachricht-----
>Von: Guttula, Mohan [mailto:MGuttula@tiaa-cref.org] 
>Gesendet: Donnerstag, 6. April 2006 22:05
>An: user@ant.apache.org
>Betreff: Looping through a file contents and dynamically add 
><transaction> for each line in the file to <SQL> task
>
>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
>**************************************************************
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message