Information Technology Reference
In-Depth Information
…
CREATE PROCEDURE beerCount(OUT count INT)
BEGIN
SELECT count(0) INTO count FROM beer;
END
//
Technically Speaking…
You may find it easier to organize your targets and scripts by
database definition type (such as a table, view, and function) or
by subsystem (e.g., Property and Application).
Manipulating Your Database
Once you've created a database from a build script, you'll need to provide
initial data (e.g., lookup tables) and test data for testing code that relies
on the database. This is where you supply the test data for your particular
environment or testing context. What's more, you may also find your-
self needing to use different SQL data files to support different envi-
ronments, like development, test, QA, and production environments.
The example in Listing 5-4 shows an Ant script pointing to a SQL
file, whose contents are inserted as test data into a database.
build-database.xml: Manipulating Your Database Using an
LISTING 5-4
Ant Script
<target name="db:insert" depends="filterSqlFiles" description="Insert
data">
<sql
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/brewery"
userid="brewery"
password="brewery"
classpathref="db.lib.path"
src="${filtered.sql.dir}/database-manipulation.sql"
delimiter=";"/>
</target>
The SQL script in Listing 5-5 represents test data. This is the script
that is referenced in Listing 5-4. In a typical script, you'll have many
more records than the three shown in Listing 5-5. Our intent is to give
you an idea of what the SQL scripts often execute. Tools like DbUnit
Search WWH ::




Custom Search