ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r807234 - in /ant/core/trunk: WHATSNEW docs/manual/CoreTasks/sql.html src/main/org/apache/tools/ant/taskdefs/SQLExec.java
Date Mon, 24 Aug 2009 14:24:52 GMT
Author: bodewig
Date: Mon Aug 24 14:24:51 2009
New Revision: 807234

URL: http://svn.apache.org/viewvc?rev=807234&view=rev
Log:
rowcountproperty for <sql>.  PR 40923

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/CoreTasks/sql.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=807234&r1=807233&r2=807234&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Aug 24 14:24:51 2009
@@ -901,6 +901,10 @@
    can be set if an error/warning occurs.
    Bugzilla Report 38807.
 
+ * <sql> has a new attribute rowcountproperty that can be used to set
+   a property to the number of rows affected by a task execution.
+   Bugzilla Report 40923.
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/docs/manual/CoreTasks/sql.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/sql.html?rev=807234&r1=807233&r2=807234&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/sql.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/sql.html Mon Aug 24 14:24:51 2009
@@ -268,6 +268,13 @@
     warning.  <em>Since Ant 1.8.0</em></td>
   <td align="center" valign="top">No</td>
 </tr>
+<tr>
+  <td valign="top">rowcountproperty</td>
+  <td valign="top">The name of a property to set to the number of rows
+    updated by the first statement/transaction that actually returned
+    a row count.  <em>Since Ant 1.8.0</em></td>
+  <td align="center" valign="top">No</td>
+</tr>
 </table>
 
 <h3>Parameters specified as nested elements</h3>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java?rev=807234&r1=807233&r2=807234&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java Mon Aug 24 14:24:51
2009
@@ -263,6 +263,13 @@
     private String warningProperty = null;
 
     /**
+     * The name of the property that receives the number of rows
+     * returned
+     * @since Ant 1.8.0
+     */
+    private String rowCountProperty = null;
+
+    /**
      * Set the name of the SQL file to be run.
      * Required unless statements are enclosed in the build file
      * @param srcFile the file containing the SQL command.
@@ -556,6 +563,15 @@
     }
 
     /**
+     * Sets a given property to the number of rows in the first
+     * statement that returned a row count.
+     * @since Ant 1.8.0
+     */
+    public void setRowCountProperty(String rowCountProperty) {
+        this.rowCountProperty = rowCountProperty;
+    }
+
+    /**
      * Load the sql file and then execute it
      * @throws BuildException on error.
      */
@@ -778,6 +794,9 @@
             getStatement().clearWarnings();
 
             log(updateCountTotal + " rows affected", Project.MSG_VERBOSE);
+            if (updateCountTotal != -1) {
+                setRowCountProperty(updateCountTotal);
+            }
 
             if (print && showtrailers) {
                 out.println(updateCountTotal + " rows affected");
@@ -1102,16 +1121,20 @@
     }
 
     protected final void setErrorProperty() {
-        setProperty(errorProperty);
+        setProperty(errorProperty, "true");
     }
 
     protected final void setWarningProperty() {
-        setProperty(warningProperty);
+        setProperty(warningProperty, "true");
+    }
+
+    protected final void setRowCountProperty(int rowCount) {
+        setProperty(rowCountProperty, Integer.toString(rowCount));
     }
 
-    private void setProperty(String name) {
+    private void setProperty(String name, String value) {
         if (name != null) {
-            getProject().setNewProperty(name, "true");
+            getProject().setNewProperty(name, value);
         }
     }
 }



Mime
View raw message