Link to home
Start Free TrialLog in
Avatar of jung1975
jung1975

asked on

schedule to run a script

SELECT RUN_DATE,      
TO_CHAR(RUN_DATE, 'DD-MON-YYYY HH24:MI'),
TABLE_NAME, FIELD_NAME, FACILITY_ID,
RECORD_COUNT, TABLE_NUMBER
FROM record

I would like to run the above script everynight ( automated) and save the result  to \\test\c$\.txt  with timestamp(i.e \\test\c$\072507.txt). How can I do this? i am using oracle 8 on window NT

Avatar of Rich Olu
Rich Olu
Flag of United Kingdom of Great Britain and Northern Ireland image

Oracle 8??? Windows NT???
You may simply use Windows Scheduled Tasks under Control Panel.
This will run a batch file which will call your sql script.

The batch file may contain following:

sqlplus username/pwd@sid @ sqlplusscript.sql >> \\test\c$\out.txt

I'll find the timestamp thing for you shortly.
SOLUTION
Avatar of Rich Olu
Rich Olu
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jung1975
jung1975

ASKER

I create a batch file like below..
sqlplus sys/password@oracle10 as sysdba @C:\log.sql>>C:\out.txt

but only output that I am getting is (I've tried in oracle 10g):
SQL*Plus: Release 10.1.0.2.0 - Production on Wed Jul 25 20:56:47 2007

Copyright (c) 1982, 2004, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

  2  


No output.....

What am i doing wrong?
I've tried like below.. but getting the same result..

sqlplus sys/password@oracle10 as sysdba;
 @C:\log.sql >> C:\out.txt;
do i have to use the spool  command to return the outpout in log.sql script? if so, how?
Try this


sqlplus sys/password@oracle10 as sysdba "@c:\log.sql"

In the .sql file make sure you end the statement with a semi colon.

thanks.. it works but is there anyway i can just save the output of the query into .txt file  using SPOOL ?
when i run the above script ...i saw "40 characters got truncated" on the dos prompt window... what is this meesage mean?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I thought you wanted to include the timestamp in your output file? Is this no longer required? Have you tried the batch file I provided above?