From 693d7c89066c2913bd08ca5cefb022de793f118e Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 1 Aug 2001 15:26:22 +0000 Subject: [PATCH] Add nested to Submitted by: Tim Stephenson git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269432 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/SQLExec.java | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java index d1fd8a5c2..593f60f0a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java @@ -71,7 +71,8 @@ import java.sql.*; * Comments may be created with REM -- or //. * * @author Jeff Martin - * @author Michael McCallum + * @author Michael McCallum + * @author Tim Stephenson */ public class SQLExec extends Task { @@ -90,6 +91,8 @@ public class SQLExec extends Task { private AntClassLoader loader; + private Vector filesets = new Vector(); + /** * Database connection */ @@ -223,13 +226,21 @@ public class SQLExec extends Task { this.sqlCommand += sql; } + /** + * Adds a set of files (nested fileset attribute). + */ + public void addFileset(FileSet set) { + filesets.addElement(set); + } + + /** * Set the sql command to execute */ public Transaction createTransaction() { - Transaction t = new Transaction(); - transactions.addElement(t); - return t; + Transaction t = new Transaction(); + transactions.addElement(t); + return t; } /** @@ -269,6 +280,9 @@ public class SQLExec extends Task { /** * Set the statement delimiter. + * + *

For example, set this to "go" and delimitertype to "ROW" for + * Sybase ASE or MS SQL Server.

*/ public void setDelimiter(String delimiter) { this.delimiter = delimiter; @@ -332,11 +346,26 @@ public class SQLExec extends Task { public void execute() throws BuildException { sqlCommand = sqlCommand.trim(); - if (srcFile == null && sqlCommand.length() == 0) { + if (srcFile == null && sqlCommand.length()==0 && filesets.isEmpty()) { if (transactions.size() == 0) { - throw new BuildException("Source file, transactions or sql statement must be set!", location); + throw new BuildException("Source file or fileset, transactions or sql statement must be set!", location); } - } else { + } else { + // deal with the filesets + for (int i=0; i