Q:

Executing all sql files in a folder with ant script (apply task)

I have a problem executing all SQL files in a folder with sqlplus command
I can run one file or first file with this code
<apply executable="sqlplus" dir="." parallel="false">
    <!-- <arg value="-S" /> -->
    <arg line="${db.user}/${db.pwd}@'${db.sid}'" />
    <arg value="@${db.run.build.script}" />  this is working, which is for executing one file
    <!-- <arg value="--e source" /> -->
    <srcfile/>
    <fileset dir="..\..\Documents\test\Database\SQL\common\test"
        casesensitive="no" description="take all sql files">
        <patternset>
            <include name="**/*.sql" />
        </patternset> 
     </fileset> 
</apply>

; but cannot proceed further with other files
I have tried various options with apply task; but still not succeed; I thought the second file hasn't "@" in the beginning that causes the problem.
any help will be highly appreciated.

A:

OK, first of all: I've never used sqlplus :-)
But based on the post I've seen here: http://www.zorbathegeek.com/161/run-multiple-sqlplus-queries-via-dos-batch-file.html I understood that it's a must to provide @ as a prefix to path to all the files that should be considered.
I see there multiple options, based on restrictions:

First check if you can provide in command line multiple of your files like this:

sqlplus [login details] @C:/<your_path>/<file1>.sql @C:/<your_path>/<file1>.sql

depending if it's possible or not, you should later decide if you need to create 1 file containing all the filenames prefixed with @ (as the example provided in the reffered site) or not

Now how to do the prepending? I think it should be simple, just try to use Ant's parhconvert described: http://ant.apache.org/manual/Tasks/pathconvert.html
<fileset dir="..\..\Documents\test\Database\SQL\common\test" id="sql.files">
      <include name="**/*.sql"/>
    </fileset>

<pathconvert pathsep=" " property="prefixed.sql.files" refid="sql.files">
      <map from="c:/" to="@c:/"/>
    </pathconvert>

(where you should replace c:/ with the string that your file paths start with. Moreover, if you will dump to file, pathsep=" " should be probably replaced with pathsep="\n" as there might be a need to have one file per line, but this needs test)
then depending on the options of all in one file or all files on cmd line, you:

either need to dump it to tmp file and run using this tmp file name
http://ant.apache.org/manual/Tasks/echo.html
In this case, the file should be later deleted
use property prefixed.sql.files directly in your apply arg value like:
<arg value="${prefixed.sql.files}" />

