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 [EMAIL PROTECTED]  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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to