History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SQL-22
Type: Improvement Improvement
Status: In Progress In Progress
Priority: Trivial Trivial
Assignee: Bob Swift
Reporter: Mark Derricutt
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Confluence SQL Plugin

Add CSV Output Format

Created: 10/Jul/07 09:49 PM   Updated: 25/Apr/08 09:52 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Labels:


 Description  « Hide
One of our users was asking if it was possible to output the results of an SQL Macro in CSV format rather than as a wiki table.

Then using table=false the results of the query are rendered as one long line, with no separators, i.e.

{sql:jndi=prod/bulletinmail|table=false}
select user_id, '|', user_name, '|' from user_details where user_status = 1
{sql}

produces:

1736|gareth.bewley|661|simon.warren|2482|BennRH|

Using the '|' is a hack to demonstrate the lack of delimiters. Ideally, what the user wants to get back is something more like:

user_id, user_name
1736, gareth.bewley
661, simon.warren
2482, BennRH


 All   Comments   Work Log   Change History   FishEye   Crucible   Related Builds      Sort Order: Ascending order - Click to sort in descending order
Bob Swift - 10/Jul/07 10:14 PM
So, using the table=false approach would work if it did a line separator for each row. Then the query could put in commas or whatever it wanted. Would that be sufficient to satisfy the requirement? Would just need an additional parameter to request the line separator for each row. Come to think about it, that probably should have been the default behavior for table=false - too late now for compatibility with current behavior.

Mark Derricutt - 10/Jul/07 11:40 PM
A recordSeparator and fieldSeparator parameter would work fine - both defaulting to an empty character would match the current behavior (afaik). Adding fieldSeparator would allow the queries to remain cleaner.

Bob Swift - 25/Apr/08 09:52 PM
This has been mostly implemented in 3.4.0, however, it will not be documented until next release. Consider it a beta for now. Since table=false, no headings are provided.

For output = html use: endColumn=,|endRow=" <br> "
For output = wiki use: endColumn=,|endRow=" \\\\ "