ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 20261] - Add a Sql task parameter to set the output column delimiter
Date Sun, 16 May 2004 16:15:58 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=20261>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=20261

Add a Sql task parameter to set the output column delimiter





------- Additional Comments From derwerbebriefkasten@gmx.de  2004-05-16 16:15 -------
The output file contains the columns selected by src (SQL statements)
separated by comma. In some cases I need a different sparator, e.g.
DB2 7.x on OS/390 needs comma plus SPACE as separator if I use
the output file to create SQL insert statements.  

There are only a very few loc to change in class SQLExec:

-->let comma be a private string 
     /**
     * Print output delimiter.
     */
    private String outputDelimiter = ",";

-->create the setter for outputDelimiter
    /**
     * Set the delimiter that separates the columns in the output. Defaults to 
&quot;;,&quot;;
     * optional
     *
     * <p>For example, set this to ", " for DB2 (OS/390).</p>
     * 
     * @param outputDelimiter
     */
    public void setOutputDelimiter(String outputDelimiter) {
        this.outputDelimiter = outputDelimiter;
    }

-->change 2 lines in the printResults() method
...
            if (showheaders) {
                for (int col = 1; col < columnCount; col++) {
                     line.append(md.getColumnName(col));
<<del<<                line.append(",");
>>ins>>                line.append(outputDelimiter);
                }
                line.append(md.getColumnName(columnCount));
                out.println(line);
                line = new StringBuffer();
            }
            while (rs.next()) {
                boolean first = true;
                for (int col = 1; col <= columnCount; col++) {
                    String columnValue = rs.getString(col);
                    if (columnValue != null) {
                        columnValue = columnValue.trim();
                    }

                    if (first) {
                        first = false;
                    } else {
<<del<<                line.append(",");
>>ins>>                line.append(outputDelimiter);
                    }
                    line.append(columnValue);
                }
                out.println(line);
                line = new StringBuffer();
            }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message