Start a new topic

Unexpected export behaviour on multiple results to single file

Hej


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:

  1. It is configured to export the SQL used as well, but only the last executed SQL is exported.
  2. The results are not exported one by one, but sort of aggregated, i.e. the header is only written once and the actual result sets follow then one after another. For my queries, this is not a problem even a bit nicer, but I wonder what if the results set structures of the different queries is not the same?
While both of the points might be intended, the documentation does not give information about those behaviours and to me they are not intuitive. Btw, this behaviour is present at 11.0.5 too.

Varma hälsningar

Thiemo
csv
xml
sql

I expected to get all SQL statements executed after switching on export, before or after the respective result set according to the settings.

Hi Thiemo!


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.

Hej Ulf


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.


Varma hälsningar


Thiemo

Login or Signup to post a comment