report-sql.pl: a script to generate SQL for an existing report