Reading File In Part( paging)
Vikas Sharma, April 01, 2003 - 5:16 pm UTC
Hi Tom,
I have a problem. I am running a procedure which execute the sql commands and add log into a file using utl_file. The procedure run for very long and create a text file of about 400 to 500 mb. I want to read this file in part somthing like paging method. For example i will first read 100 line then next 100 then next 100 and so on.
Kindly tell me the best way to achive. I display the the lines on browser. every thing work fine for small file size about 1 mb and more.
What i would like to achive is paging when reading file. I have alredy adopted your paging method when reading from tables. Kindly suggest.
Thanks,
Regards
Vikas Sharma
April 01, 2003 - 7:40 pm UTC
load the file into a table with a sequence per line and forget the file exists?
that would be easiest.
But you could use a BFILE instead in 8i as it supports "seeking", you would have to use dbms_lob.instr and dbms_lob.substr and utl_raw.cast_to_varchar2 -- but it would be doable. Your web page would have to remember the offset to start reading at again when it picked up. see
</code>
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:1352202934074 <code>
for an example of what I mean.
In 9i, utl_file supports utl_file.fseek - so you could use that as well. Just remember where you were (fgetpos) and fseek there to resume paging.
Thanks
Vikas Sharma, April 03, 2003 - 1:00 pm UTC
Hi Tom,
Thanks.
Regards,
Vikas Sharma
going back to previous rec wile reading a file
srinivasa rao bachina, May 31, 2003 - 7:41 am UTC
Hi tom ,
i am having file with a set of recs like
aa,fdds.................
bb,.................
bb,.................
bb,.................
aa,.............
bb,...........
bb,...........
where aa is the indication for master rec and bb for dtl rec
each master rec and recs followig after that but before another master belonfs to one group.while processing the recs if any validation goes wrong i have to put that group of recs(master rec+ detl recs) in a separate file,that is i have to go back and read again the contents and again write to some other file,in utl_file package there is no procedure/function to go back in file,how can we solve this situation.
i am using oracle 8i releae 8.1.7.4.0
Please give your solution
Thanks
C nu
May 31, 2003 - 11:53 am UTC
you will be writing a program to procedurally process this file in whatever language you like.
Limit of opened files using utl_file
Reader, May 31, 2003 - 3:06 pm UTC
Tom,
Is there any limit on number of files can be opened for a given session?
May 31, 2003 - 4:33 pm UTC
yes, as determined by the operating system (and given that oracle itself has files opened)
How may files can be read at a given session.
Vinod, March 15, 2005 - 4:21 am UTC
Secanrio : WinNT, DB 8.1.6
We are reading files thru the UTL file reader sequentially. But at some point of time ( say after 15 - 16 occurances) the UTL reader is unable to process further files but it pretends in doing so (as this process is mapped to a table with a status column which returns the success flag). There could be more than 25 files to read sequentially at some time. What can be done to over come this sort of error.
Is there any wait/time delay statement that can be put into PL/Sql
Please advice.
Vinod
March 15, 2005 - 8:16 am UTC
sorry -- totally insufficient data here.
code doesn't "pretend".
sounds like maybe you are forgetting to close files -- you cannot open any new files -- but your code is perhaps ignoring errors (do you have any exception blocks? comment them all out and see what you see then)