I am running a query on my database with Navicat and I am using the ORDER BY CASE to print out the results in a specific order. I would like to insert a carriage return between each result, but I am not finding any information on how to do that. Ideally, I would like to have a record returned, a blank row of cells, then the next record printed below that.
Any help would be greatly appreciated.
Probably as many other community members, I don't use Navicat. I Googled for it - looks like GUI tools I've seen (SQL Developer, TOAD) with nice features. I doubt it is capable of doing what you want out of the box.
You didn't say what you plan to do with such an output - maybe spool it into a (CSV?) file? If so, there's a workaround: use SQL*Plus whose
SET RECSEPsetting does exactly that, with no effort at all.This is default:
Setting I mentioned:
Cool, isn't it?
Otherwise, a workaround that doesn't exactly add carriage return, but adds empty rows. To do that, I used several CTEs:
your_queryis your (my) current query with two additional columns:rnwhich returns row number, sorted by column(s) you wantcntwhich returns total number of rows returned by your querycounteris a row generator, generating as many rows as your query returns (in my example, my query returned 4 rows;countercreates 4 rows as well)tempunions these two queries:rnfrom counter, while other columns arenull. Visually, it'll return result you wanted (empty rows)rnResult:
If you wonder how it looks in GUI, here it is (from SQL Developer):