Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Saturday 6 September 2014

Executing Windows command from Oracle Script

We can execute windows command from Oracle script. To achieve this we have a command called HOST which execute the command on host and again return to the Oracle prompt.

Let's take a scenario, you have to delete file automatically from windows directory while you are running the Oracle script and you don't want manual intervention. You can use HOST command to do so.

Say, you have 5 procedure that you needs to execute, but after executing 3 procedure you need to DELETE the file from the windows directory, to do this you can perform steps shown below:-

SQL> EXEC PROCEDURE_1;
      procedure executed successfully.
SQL> EXEC PROCEDURE_2;
      procedure executed successfully.
SQL> EXEC PROCEDURE_3;
      procedure executed successfully.
SQL> HOST 'DEL D:/CHANCHAL/TEST.CSV'
SQL> EXEC PROCEDURE_4;
      procedure executed successfully.
SQL> EXEC PROCEDURE_5;
      procedure executed successfully.


Like shown above, you can perform many other windows operations like creating windows directory, file , rename file and many more.....

No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.