Home » SQL & PL/SQL » SQL & PL/SQL » Determining end of file
Determining end of file [message #1664] Mon, 20 May 2002 11:44 Go to next message
Janet
Messages: 8
Registered: May 2002
Junior Member
In a simple FOR loop, how do I tell the loop to exit when I'm at the end of the file? I'm adding data to a table from an ASCII file and need to know 1) if the
ASCII file exists at all and 2) how do I exit the loop once all the lines in the ASCII file are added to the table as records.
Re: Determining end of file [message #1666 is a reply to message #1664] Mon, 20 May 2002 21:45 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
You can trap a NO_DATA_FOUND error in an inner PL/SQL block within your loop.

Excerpt from the manual:
---
GET_LINE Procedure
This procedure reads a line of text from the open file identified by the file handle and places the text in the output buffer parameter. Text is read up to but not including the line terminator, or up to the end of the file.

If the line does not fit in the buffer, then a VALUE_ERROR exception is raised. If no text was read due to "end of file," then the NO_DATA_FOUND exception is raised...
---

HTH,
MHE
Previous Topic: Re: SQL Count Statement
Next Topic: Long Datatype
Goto Forum:
  


Current Time: Thu Apr 25 16:57:07 CDT 2024