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
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