in reply to help deriving mysql query from perl script

The easiest way to find out what SQL queries your script sends to the database to look at the MySQL query log.

The other easy way is to turn on SQL tracing on your database handle in DBI.

Before turning to such heavy handed approaches, especially when you're not even sure whether the script works or not, I would rip out the "web" part of the program.

Luckily, your program is basically structured as two parts, the part above

$where_clause = "rwsurvey.type = 'LIT' and ".$where_clause;

... which mostly deals with generating the web form, and the part below, which deals with talking to the database and output. So you can just take the lower part, fix up $where_clause with the appropriate value, and you've eliminated the web server as source of errors and can inspect the error messages on the console.

Replies are listed 'Best First'.
Re^2: help deriving mysql query from perl script
by alison-g (Novice) on Jul 30, 2012 at 08:05 UTC

    Thanks Corion...

    Unfortunately "So you can just take the lower part, fix up $where_clause with the appropriate value" is just what I don't know how to do

    Sorry forgot to mention don't know MYSQL either - just enough to run other folks' queries

      Then maybe first use the other half of the program to fill/create $where_clause and then print $where_clause instead of running it against the database.

      If you don't know how to do that either, I don't know how to be of more help to you. You will have to show us the output and log entries you get when you run the modified/split program and show us the source of that split program.