ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Record rrn inside rpg program

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

  • Record rrn inside rpg program

    Hello guys, i have this file that allows duplicate records and need to update it. In order to update it properly , i need to find the rrn of the record so i can do a chain to that specific record.

    Supposedly i can use the INFDS from binary position 397 to 400, but i am getting the same (and a wrong) rrn from 2 records.
    I have read that i must do a OVRDBF with SEQONLY *YES 1 in order for it to work, but i have tried and still doesn't work.

    I get 1077952576 as the rrn instead of 7186105 that select rrn(file) returns.

    What should i do?

  • #2
    Re: Record rrn inside rpg program

    Please, show us how you have exactly defined the RRN of the INFDS.

    Note. Actually the value 1077952576 that you get is x'40404040' ie blanks.
    Philippe

    Comment


    • #3
      Re: Record rrn inside rpg program

      I have just found RECNO, but i am reading the file using a logical file with a key, then doing a chain to the physical file itself (without the key) and i need to compare the rrn from both, but i can't use RECNO with the keyed file.
      I can't just do a READ to the physical file instead of using the logical file, it is way too big and the program would be extremely slow.

      Comment


      • #4
        Re: Record rrn inside rpg program

        Hi Fjleon:

        Just a curiosity....
        If you already have the record (from the logical file) can't you just update that? Why do you need the physical?

        GLS
        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

        Comment


        • #5
          Re: Record rrn inside rpg program

          The RECNO can NOT be different since the LF gets its RRN (RECNO) from the underlying PF it points to.
          If you want to update the most current record you could consider using the LIFO keyword in DDS instead of the default FIFO.
          Philippe

          Comment


          • #6
            Re: Record rrn inside rpg program

            If you have a good recno and you can use embedded SQL:

            Code:
            exec sql update myPhyFile set myField = someValue where rrn(myPhyFile) = recno;
            might be a bit slow with a large file, though

            Comment


            • #7
              Re: Record rrn inside rpg program

              Thanks, your post mentioning that 1077952576 is actually blanks let me find out that i was putting the INFDS inside the physical file instead of the logical i am using to read the values. Now it works!

              Comment


              • #8
                Re: Record rrn inside rpg program

                Originally posted by GLS400 View Post
                Hi Fjleon:

                Just a curiosity....
                If you already have the record (from the logical file) can't you just update that? Why do you need the physical?

                GLS
                Because i needed to show the record in a subfile for the user to be able to change it, then with those values i do a chain to avoid locking the record for too long.

                Comment


                • #9
                  Re: Record rrn inside rpg program

                  Here an example how the RRN can be retrieved:

                  Code:
                  FDWWEBAPP  IF   E           K DISK    UsrOpn  InfDs(InfDSKey)             
                  F                                     Rename(WEBAPPF: DWWEBAPPF) 
                  
                  D InfDSKey        DS                  Qualified             
                  D   RRN                 397    400U 0                       
                   /Free
                       Chain (MyKeyFld1: MyKeyFld2) DWWEBAPPF;
                       If %Found;
                          Dsply INFDSKey.RRN;
                       EndIf;
                   /End-Free
                  might be a bit slow with a large file, though
                  It will become VERY slow with large files, because a table scan (or at least a table probe) must be performed, that means all records are read. It will not even stop reading if the right record is found.

                  Birgitta
                  Last edited by B.Hauser; June 16, 2010, 11:38 PM.

                  Comment


                  • #10
                    Re: Record rrn inside rpg program

                    Originally posted by b.hauser View Post
                    it will become very slow with large files, because a table scan (or at least a table probe), that means all records are read. It will not even stop reading if the right record is found.

                    Birgitta
                    so saith the queen of sql!!!
                    I'm not anti-social, I just don't like people -Tommy Holden

                    Comment

                    Working...
                    X