Ant, SQL, and variables

M

Matthew Zimmer

Hey all,
after way too many builds for my company, I finally got around to
writing a build script using Ant a few weeks ago. It works great, but
there is one thing left that I would like to be able to do. Everything
is automated except for updating our bug tracking program with a new
version number. I've figured out the sql statements that I would need
to be able to do this, but can't seem to figure out how to temporarily
store results of a select statement in a variable.

Here's what I figured out for the ant sql statement:

<target name="updateDatabase">
<sql
classpath="mysql-connector-java-3.0.8-stable-bin.jar"
driver="org.gjt.mm.mysql.Driver"
url="jdbc:mysql://bugtrackerLocation"
userid="myUserID"
password="myPassword"
print="yes"update MyTable set id=id+1;
select * from MyTable;
insert into MyTableTwo (id, version) values(X, BuildVersion);
</sql>
</target>

The update call simply increments the id in the table that I have to use
for the bug tracker. I then need to take that id and insert into the
second table along with my BuildVersion (which I get from a properties
file). I know that the statement "select * from MyTable" gets the value
that I need since it prints out correctly. However, I don't know how to
take the result of the sql, store it in some variable X and use it in
the insert statement. Is there any way to do this? I think I might be
able to write the result to an output file by changing the "output"
variable of sql to a file, but then would need to figure out how to do
some more of the reading in stuff. A local variable sounds so much nicer!

Anyway, does anybody have any idea how I can accomplish this?
Thanks,
Matthew Zimmer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top