External table for directory
Georg, April 24, 2006 - 4:42 pm UTC
Maybe you can create one additional file with the file names of the data files inside and setup an external table on this "dir file". Then you have access to all the filenames from sql.
Move loaded files to processed folder
Manuel Vidigal, April 13, 2009 - 7:31 am UTC
Hi Tom,
We use perl scripts to do the steps above, only because we have a step 3 - after processing the files in the database, if everything goes smoothly, we need to move the processed files to another directory so they don't get processed twice.
What do you think is the best and safest approach?
1 - Keep using the perl script
2 - Use a java stored procedure to give an OS Command to move the file?
3 - Is there a better way to do this?
I'm asking you this, because I've been doing some tests with the java stored procedure, and it won't give me any error when there's already a file with the same name on the processed folder.
Thanks in advance.
April 13, 2009 - 5:29 pm UTC
how about (3)
you are in a database
database remember things
remember that you did this file so as to not process it again?
... I'm asking you this, because I've been doing some tests with the java stored procedure, and it won't give me any error when there's already a file with the same name on the processed folder. ...
then you have a bug in your java stored procedure, java would return an error if you call their api to move a file. Or are you just running an OS command (which is really hard to figure out "did it work or not")
Processed folder
Manuel Vidigal, April 13, 2009 - 6:35 pm UTC
Yes, I was testing the OS command. Although I don't know Java, I will try to find an example of a java stored procedure that uses the api to move a file.
Another reason for the processed folder, is that every other day we need to clean out the processed files.
If you really needed to move the files to another folder, would you do it with the java api?
April 14, 2009 - 10:01 am UTC
but, like I said, you have a database
a database remembers things
utl_file can remove a file.
therefore, you could remember what you have processed IN THE DATABASE (and do not process it again) and the database could clean out the processed files (dbms_job, dbms_scheduler - whatever - to get a job to run, determine what has been processed using the DATABASE, clean it out)
I don't think you need to move anything. It makes it all less transactional (file system will NOT rollback).
I think you want to
a) process input
b) remember that you processed input
c) commit;
all nice and transactional - no mess, no muss, no fuss. And no code external from the database itself.
Thanx for your time
Manuel Vidigal, April 14, 2009 - 10:50 am UTC