Index: SQLExec.java =================================================================== --- SQLExec.java (revision 381936) +++ SQLExec.java (working copy) @@ -84,8 +84,6 @@ } } - - private int goodSql = 0; private int totalSql = 0; @@ -146,7 +144,6 @@ */ private File output = null; - /** * Action to perform if an error is found **/ @@ -175,6 +172,16 @@ private boolean escapeProcessing = true; /** + * The name of the property to set in the event of an error + */ + private String errorProperty = null; + + /** + * The name of the property to set in the event of a warning + */ + private String warningProperty = null; + + /** * Set the name of the SQL file to be run. * Required unless statements are enclosed in the build file */ @@ -273,7 +280,6 @@ this.append = append; } - /** * Action to perform when statement fails: continue, stop, or abort * optional; default "abort" @@ -302,6 +308,26 @@ } /** + * Property to set to "true" if a statement throws an error. + * + * @param errorProperty the name of the property to set in the + * event of an error. + */ + public void setErrorProperty(String errorProperty) { + this.errorProperty = errorProperty; + } + + /** + * Property to set to "true" if a statement produces a warning. + * + * @param warningProperty the name of the property to set in the + * event of a warning. + */ + public void setWarningProperty(String warningProperty) { + this.warningProperty = warningProperty; + } + + /** * Load the sql file and then execute it */ public void execute() throws BuildException { @@ -478,7 +504,6 @@ } } - /** * Exec the sql statement. */ @@ -528,12 +553,18 @@ SQLWarning warning = conn.getWarnings(); while (warning != null) { log(warning + " sql warning", Project.MSG_VERBOSE); + if (warningProperty != null && !warningProperty.trim().equals("")) { + getProject().setNewProperty(warningProperty.trim(), "true"); + } warning = warning.getNextWarning(); } conn.clearWarnings(); goodSql++; } catch (SQLException e) { log("Failed to execute: " + sql, Project.MSG_ERR); + if (errorProperty != null && !errorProperty.trim().equals("")) { + getProject().setNewProperty(errorProperty.trim(), "true"); + } if (!onError.equals("continue")) { throw e; } @@ -629,14 +660,16 @@ private String tSqlCommand = ""; /** - * + * Set the source file attribute. + * @param src the source file */ public void setSrc(File src) { this.tSrcFile = src; } /** - * + * Set inline text + * @param sql the inline text */ public void addText(String sql) { this.tSqlCommand += sql;