0

I need to run the same damn Oracle query daily (and export the output, which I can do from the sql file itself). I'd like to automate using Windows Task Scheduler but it only opens the script, and it doesn't run it.

Is this feasible or is there an easier way?

Blake Shurtz
  • 321
  • 3
  • 13
  • 1
    What is the the command you are running. Assuming you are running something like `sqlcl un/pw@db @the_script.sql` and it is not running the sql in the script, is the SQL statment in teh script terminated by a `;` or `/`? – TenG Jun 15 '21 at 22:47
  • 1
    First check if you are able to make connection to database. Then we can debug why query is not running. – Atif Jun 16 '21 at 05:55

1 Answers1

1

Your description isn't very descriptive (we don't know how exactly you did that), but - here's a suggestion:

  • create a .bat script (let's call it a.bat) which will call your .sql (let's call it a.sql) script. Only one line in it:

    sqlplus scott/tiger@orcl @a.sql
    
  • a.sql is ... well, what it is, for example

    prompt Number of rows in EMP table
    
    select count(*) from emp;
    

Create a job in Task Scheduler which will start a program (a.bat).

I've just tried it (using that simple example I posted above) and got the result (saying that there are 14 rows in the table), so I hope you'll get it as well.

Littlefoot
  • 131,892
  • 15
  • 35
  • 57