Home » SQL & PL/SQL » SQL & PL/SQL » UTL_FILE usage
icon5.gif  UTL_FILE usage [message #209227] Wed, 13 December 2006 21:27 Go to next message
pulkit_a
Messages: 50
Registered: December 2005
Member
Hi,

I have attached a file and i am looking a way to get some data from this file using UTL_FILE

In the attached file FHEAD demotes the starting of the file.
Every FHEAD can have multiple THEAD. Every THEAD can have multiple TSHIP and TITEM. At the end there will be FTAIL which denotes the end of file.


What i want to do with this file is :---

1) Find out how many total records count exists in the file

2) Open a loop for that count

3) Then start reading each record and if it is 'THEAD' (as given in the attach file) then extact the last 4 values i.e. "8001"
form the string ""200612048001" as given in the attach file "First THEAD in the file".

4) Now find out how many TITEMS it has and for each TITEM extract the value like "4901990041416" in the file for
first THEAD-->TITEM relationship. Now i have to insert this THEAD-->TITEM relationship in one ORACLE Table.

Actually point 3 processing should be in loop becasue for 1 THEAD there can be multiple TITEMS and for that one THEAD all the related
TITEMS should be inserted into the table..


Please let me know if this can be done through UTL_FILE package...

I really be thankfull if any one can tell me how to do this with UTL_FILE

Regards
Pulkit

Re: UTL_FILE usage [message #209258 is a reply to message #209227] Thu, 14 December 2006 00:20 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
UTL_FILE only provides ways to read/write/handle files. All the logic you describe, you have to code it yourself.
So to answer your question: yes, this can be done using UTL_FILE.
You should however consider the use of an external table or of sqlloader (google for those if you don't know them).
But also with those options, writing the actual logic is up to you.
Re: UTL_FILE usage [message #209262 is a reply to message #209227] Thu, 14 December 2006 00:29 Go to previous messageGo to next message
pulkit_a
Messages: 50
Registered: December 2005
Member
Hi,

Thanks for ur help...

Is there any way to get the row counts in the file using UTL_FILE package.

Regards
Pulkit
Re: UTL_FILE usage [message #209266 is a reply to message #209262] Thu, 14 December 2006 00:34 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Welcome to Tahiti!
Previous Topic: Please kindly help in this SQL
Next Topic: Transaction Identification
Goto Forum:
  


Current Time: Fri Dec 09 02:15:37 CST 2016

Total time taken to generate the page: 0.12640 seconds