In a single CL Program, can we read a database file more than once?

25 pts.
Tags:
AS/400 database
CL Program
CLLE
Database Files
In a single CL Program, can we read a database file more than once

Software/Hardware used:
AS400

Answer Wiki

Thanks. We'll let you know when a new response is added.

you can use POSDBF to reposition the file to *START to re-read it

Discuss This Question: 9  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    You don't tell us what version your system is at, so it's hard to know the right answer. If you're at v6.1 or later, review Reading a file twice in CL before anything else. If you're at V5R4 or earlier, then a single CL program cannot read the same file again after reaching end-of-file. That's simply the way it works. CL is a control language not a database processing language. You can work around it it two general ways. You can split your program into two programs -- one for an outer control structure and the other for the file-processing portion. The outer control code would call the inner program twice (or as many times as needed.) Or you can use RTVMBRD or a similar function to retrieve the number of records in the file before you start to read it. As you read records, keep count of them and compare your count to the number of records in the file's member. Stop reading after you have counted as many are in the file. If you try to read one more than that, end-of-file will be reached and you can't go beyond that. But if you stop just before end-of-file is signaled, you can reposition back to *START and read again. Tom
    125,585 pointsBadges:
    report
  • dinuas400
    Yes using OVRDBF we can read a file again from the starting...
    510 pointsBadges:
    report
  • TomLiotta

    Yes using OVRDBF we can read a file again from the starting…

    No, you can't.

    There are ways of doing it, but OVRDBF isn't one of them.

    Tom

    125,585 pointsBadges:
    report
  • RamvishakRamesh
    If the file has reached EOF,then OVRDBF will not help, however if version is V6R1, we can close the file and next RCVF will read the file from the begining.
    2,505 pointsBadges:
    report
  • ejb12097

    We are at 7.1 and POSDBF doesn't work - because the error I get is No file open with OPENID(&4) I used the file name - should I have used the format name? And also, the file is created during a DSPOBJD command - but it doesn't get deleted.


    20 pointsBadges:
    report
  • philpl1jb

    As soon as your cl starts it will normally lock the DCLF file.

    52,525 pointsBadges:
    report
  • TheRealRaven
    @ejb12097, What open ID did you assign on the DCLF? Does it match with the POSDBF open ID? Also, if the file has signalled that EOF was reached, POSDBF won't help unless the file is closed and reopened.
    3,535 pointsBadges:
    report
  • ToddN2000
    You can try to close and reopen the file. IT may not be the cleanest way to handle the task. Why not just create another CL  and call it from the original program.  It makes debugging a lot easier if you are not opening and closing file repeatedly in a program.
    22,685 pointsBadges:
    report
  • philpl1jb

    I'm with Todd on this one .. and all the others.

    The parent creates the file

    The child uses the file to do .. whatever. Only the child has a DCLF in it.

    Need to do two things with the file .. have two children or call the child twice with different parameters.


    52,525 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following