You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

How to Skip the last line while reading the flat file in SQR

1 reply [Last post]
Guest's picture
Guest

Hi All,
Kindly suggest me how to write the code in SQR to skip the last line while reading the flat file.

Example file:

1 ABC
2 xyz
000000000000

Lepa's picture
User offline. Last seen 1 year 18 weeks ago. Offline
Joined: 06/23/2008
Posts: 591
Re: How to Skip the last line while reading the flat file in SQR

If there are no more records to read, the #end-file reserved variable is set to 1; otherwise, it is set to 0 (zero). So before reading in your line check for the value inside your read loop like the following:

if not #end-file  !any more records to read?
    Do process-record
else
    !This is the last record, do nothing
end-if

It has been a while since i've coded in SQR, not sure if the above will do what you are looking for.

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog