Home » Infrastructure » Unix » PL/SQL procedure that reads from a directory
PL/SQL procedure that reads from a directory [message #300942] Mon, 18 February 2008 15:53 Go to next message
shree_z
Messages: 75
Registered: February 2008
Member
Hi,

Can anyone please help me on this?

I need a Program that reads filenames from a directory and finds files that start with a common name (Example: P*.txt)

For each file found call a concurrent program(this concurrent program imports the file located to Oracle tables)
IF file successfully imported, THEN move it to archive directory
ELSE write a generic message
END IF
END Loop
END

Should I use Unix for this (to read the filenames from directory)?The concurrent program which we already have needs the file name as the parameter . How will I use Unix and PL/SQL hand in hand?
Any help would be appreciated.Please help!


Thanks in advance
Sree

[Updated on: Mon, 18 February 2008 15:56]

Report message to a moderator

Re: PL/SQL procedure that reads from a directory [message #300943 is a reply to message #300942] Mon, 18 February 2008 15:56 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Why do you need pl/sql here.
Just OS scripting is much easier.
Re: PL/SQL procedure that reads from a directory [message #300944 is a reply to message #300942] Mon, 18 February 2008 15:58 Go to previous messageGo to next message
shree_z
Messages: 75
Registered: February 2008
Member
Thanks for your quick response!!

How can i go ahead with the scripting?.. I am really new to this!

Thanks,
Sree

[Updated on: Mon, 18 February 2008 16:02]

Report message to a moderator

Re: PL/SQL procedure that reads from a directory [message #300947 is a reply to message #300944] Mon, 18 February 2008 16:03 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Just a partial one liner.
I will leave the archiving portion for you to fill up.

oracle@mutation#ls -lrt *.lst | awk '{print $9}' | while read fname
> do
> echo The file to passed to importing program is $fname 
> done
The file to passed to importing program is store_tbs.lst
The file to passed to importing program is mitusers.lst
The file to passed to importing program is A.lst
The file to passed to importing program is cr_report_indx.lst
The file to passed to importing program is gr_sand.lst
The file to passed to importing program is ind.lst
The file to passed to importing program is gr.lst
The file to passed to importing program is tr_ta.lst
The file to passed to importing program is tr_target.lst
The file to passed to importing program is cr_index.lst
The file to passed to importing program is gr_lawson.lst
The file to passed to importing program is cr_kr.lst
The file to passed to importing program is cr_tk.lst
The file to passed to importing program is trunc_tf80.lst
The file to passed to importing program is kr.lst
The file to passed to importing program is budget.lst
The file to passed to importing program is 1.lst
The file to passed to importing program is dum2.lst
The file to passed to importing program is test.lst
The file to passed to importing program is dummy.lst
Re: PL/SQL procedure that reads from a directory [message #300949 is a reply to message #300947] Mon, 18 February 2008 16:07 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Just a reminder.
the exact position of filename in ls -lrt may differ with flavors of unix.
Re: PL/SQL procedure that reads from a directory [message #300951 is a reply to message #300947] Mon, 18 February 2008 16:13 Go to previous messageGo to next message
shree_z
Messages: 75
Registered: February 2008
Member
Thank you for your help. I appreciate !

how can I pass this file name as parameter to the concurrent program(stored procedure) which actually imports the file ?

Thanks,
Sree

Re: PL/SQL procedure that reads from a directory [message #300952 is a reply to message #300951] Mon, 18 February 2008 16:19 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
>>(stored procedure) which actually imports the file ?
Now you are introducing new terms. I thought you were importing the file with export/import.
Just search the forum ( a few threads below)
http://www.orafaq.com/forum/t/97308/42800/



Re: PL/SQL procedure that reads from a directory [message #300953 is a reply to message #300952] Mon, 18 February 2008 16:38 Go to previous message
shree_z
Messages: 75
Registered: February 2008
Member
Thanks for your help!

Thank you,
Sree
Previous Topic: Output from a Command
Next Topic: Invoking Oracle stored procedure in unix shell script
Goto Forum:
  


Current Time: Sun Nov 24 21:21:09 CST 2024