I’m trying to figure out how to automate set variables, execute multiple queries that contain the variables, store the results in an excel file as tabs in the same file which is named after the values of the variables.
The queries (the first two) are stored as a file "level 1 debug.sql"in a project “car-model-monitoring”.
I think I get how to execute each query separately and export each result to an excel file but I want to set the variables once then execute multiple queries using those variables.
Manually, the steps are:
- connect to remote database
- open Project Manager
- open query file
- set variables
- execute queries with “F5”
- export each query result to a tab in a file labelled
- email file to email list
query file with variables yy, mm1, dd1, mm2, dd2, x:
SELECT aarowkey, logtimestamp, tripdate, trip_usage.format_fz_trip(tripnum) astripnum, depcity, arrcity, etd, eta, platenum, actype, passenger, crew,cavailflag, comment, status
FROM make-of-carallocationtable a
JOIN platenuminfotable t on (a.platenum = t.plate_num)
WHERE tripdate between @user_start_date and @user_end_date
AND platenum LIKE @car-model_str
ORDER BY platenum, etd desc;
WHERE (date(logtimestamp) BETWEEN @user_start_date AND@user_end_date)
and (platenum like @car-model_str)
ORDER BY platenum DESC, logtimestamp DESC;