I expected to get all SQL statements executed after switching on export, before or after the respective result set according to the settings.
Regarding the header written only once there is a special parameter for this CsvIncludeColumnHeaderPerResult which I believe is false in your case.
Changing it to true will produce a header for each result.
Regarding the SQL for subsequent queries is missing is a result of the headers not being written. Specifying CsvIncludeColumnHeaderPerResult=true you should get the SQL also for the other results.
I agree that this could be documented better. Also agree that the behaviour is not that intuitive. Especially that having CsvIncludeSQL specified the SQL for the first select is included regardless of CsvIncludeColumnHeader but the SQL for subsequent selects are only included if CsvIncludeColumnHeaderPerResult =true
I will create a ticket to look into this.
Thanks for getting at my issue quickly. I, indeed, overlooked CsvIncludeColumnHeaderPerResult. I wonder whether the double role of the option is actually a good idea. Having it set to false will cause only one of the SQL used to export data to a csv file even though there have been used several. It might be misleading if some tries to reproduce the results. I guess this is what one wants to achieve with spooling the SQL too: reproducibility of the results. One might be able to recreate SQLs if they are only distinguished by parametrisation of the spooled one, but for anything else one is quite lost.
I have a script (attached perpare_ogg_gdoversion_masterdbmodif_problem_detection.sql) that runs a number of queries of which I want to export (config attached with csv_semicol_with_sql.xml) appending the result into a file (attached ogg_gdoversion_masterdbmodif_problem_detection.csv). While this principally works, the result astonishes me in two ways: