ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to determine number of records in a file...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to determine number of records in a file...

    I have written a series of pgms that clean-up or delete records. Each pgm deletes records from quite a few files.

    I would like to create a log as the programs are running that tracks the starting number of records, ending number of records, and the number of records deleted for each file. I would like to do this with a few lines of code.

    Questions:

    Other than RTVMBRD command - is there a way in RPG to determine the number of records in a file?

    Is there a DS (INFDS, etc.) that contains the record format name of the file currentl (or last) opened/updated? Given the number of files involved, it would be helpful to have the filename/format name in a variable w/out having to "eval" it myself.

    Thx

  • #2
    Re: How to determine number of records in a file...

    Use SQL --

    Select Count(*) into :RecCount From Lib/File;

    Use this to find the File Name, etc ... utilizing the INFDS.

    Comment


    • #3
      Re: How to determine number of records in a file...

      While I have never done it, I am just thinking of ways to do this. There is a INFDS field that has the relative record number in it. If you were to position the file cursor at the end of the file and then do a READP, this INFDS field "should" give you the record number.

      Comment


      • #4
        Re: How to determine number of records in a file...

        you can use the infds

        PHP Code:

        fbrc02hsta uf   e           k disk    infds
        (infhst)
        dinfhst           ds                     
        d fileRRN               397    400I 0    
        D NUM_RCDS         156    159I 0 
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: How to determine number of records in a file...

          So i really just need to define the fields in the INFDS so I can check them? BTW - what happened to the link on this site that described the fields in INFDS and PSDS and the like?

          Comment


          • #6
            Re: How to determine number of records in a file...

            Its still there
            http://www.code400.com/codepage.php?id=11

            j
            amie
            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment


            • #7
              Re: How to determine number of records in a file...

              That's what the link I provided up top does for you... gives you the INFDS and the definitions...

              I know .. you just like Jamie best. He ALWAYS gets the attention around here.... Jaime, Jaime Jaime!!

              Comment


              • #8
                Re: How to determine number of records in a file...

                Originally posted by FaStOnE View Post
                That's what the link I provided up top does for you... gives you the INFDS and the definitions...

                I know .. you just like Jamie best. He ALWAYS gets the attention around here.... Jaime, Jaime Jaime!!
                WHy do I suddenly have the urge to break into a 1970's dance routine???
                Michael Catalani
                IS Director, eCommerce & Web Development
                Acceptance Insurance Corporation
                www.AcceptanceInsurance.com
                www.ProvatoSys.com

                Comment


                • #9
                  Re: How to determine number of records in a file...

                  Originally posted by MichaelCatalani View Post
                  WHy do I suddenly have the urge to break into a 1970's dance routine???
                  coz you're old???
                  I'm not anti-social, I just don't like people -Tommy Holden

                  Comment


                  • #10
                    Re: How to determine number of records in a file...

                    Rather than do the count yourself the count is stored in the system tables
                    Code:
                    select TABLE_NAME ,  NUMBER_ROWS
                    from QSYS2/SYSTABLESTAT
                    where TABLE_SCHEMA = ''
                    and TABLE_NAME= ''

                    Comment

                    Working...
                    X