Shashi337
Shashi337

Reputation: 11

Deletion of files from a directory in oracle stored procedure

I am trying to identify all files in a particular directory and delete them. I know that there is a Java procedure for this but I am looking for something in pure PL/SQL.

If I am not able to get the list of files and delete them, then I would not mind deleting/dropping the directory and creating it again. If someone can guide me on this it will be of great help.

Upvotes: 1

Views: 12352

Answers (2)

Toru
Toru

Reputation: 905

You can use a scheduler job for creating a directory listing: http://www.oracle-base.com/articles/11g/scheduler-enhancements-11gr1.php#returning_stdout_and_stderr

Upvotes: 1

hol
hol

Reputation: 8423

I have used the following not too long ago and it worked very well for me

http://plsqlexecoscomm.sourceforge.net/

It is as easy as this

select os_command.exec_clob('/bin/ls -la /home/oracle') COMMAND from dual

You could write a PL/SQL routine that scans line by line through the received clob of the ls command and issue a rm shell command.

Upvotes: 1

Related Questions