Goal:
Create a species list that is automatically updated in the same fashion to reflect daily changes to our Biotics database.
Solution:
Script the desired query and run it as a Scheduled Task to export the results to a .csv file. NOTE: If spatial data is desired, see this solution.
Requirement:
The Oracle client has been installed (according to this solution) and configured (according to this article) on the machine the Scheduled Task will run.
Batch File:
Create a batch file (.bat) which logs into SQL Plus as the desired Oracle user (biotics_report) and calls the desired query. Following is an example of the text to include in the batch file (.bat) where the query (query.sql) is saved in C:\Temp. Update the file location/name and PASSWORD:
Query File:
Attached is an example query.sql file which queries the element_subnational table. Just update the select statement, as appropriate, to query the desired data.
Create a scheduled task
Create a scheduled task to run the script daily, to automatically update the data.
- From the Windows Search on the Taskbar, type in Task Scheduler, and open the Task Scheduler.
- Within the Task Scheduler, Create Task.
- Within Create Task, on the General tab, name the task (ie. Download and Publish Biotics spatial layers).
- From the Triggers tab, select New.
- Within New Trigger, indicate to run the task Daily (or as often as preferred) and select the time the task should be run. NOTE: The computer has to be on to run the task, so make sure you indicate the time accordingly. Click OK.
- From the Actions tab, click New.
- Within New Action, Start a program and navigate to the the batch file script. Click OK.
- From the Conditions tab, indicate to Wake the computer to run this task.
- Click OK to save the scheduled task.