ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

chain condition and field value

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

  • chain condition and field value

    Hi,

    suppose if i have 3 consecutive chain conditions inside a rpgle program and which have corresponding 3 different indicators associated with them let's say 10,30 and 20.

    and conditions are like below :-
    Code:
    keya  chain   file1      10
    keyb  chain  file2       30
    keyc   chain  file3       20
                 if    *in10 = '0' 
                          and  *in30 = '0'
                 if     *in20  = '0'
                 exsr  xyz
    then inside xyz subroutine some values are assigned based on fil1,file2,,file3 and associated files of keya,keyb and keyc .

    then why some specific field value from file3 is not getting updated in eval statement into some output file based on above chain conditions ?

    though records are there in file3 for keyc chain condition.


    Thanks...





  • #2
    WItrh that code, for subroutine xyz to execute, there would have to be records in all three files

    Comment


    • #3
      Records are there in all these 3 files and chain conditions seem also to be true that is why in debug mode program is going inside this Exsr but the problem is that inside this Exsr when other field values are being moved to some fil declared in output mode inside this program then why that particular field is having blank values inside that file declared in output mode whereas other fields get values written in it?

      is there anyway i mean using any SQL query to join these 3 files together to verify that, how ever one by one i joined these 3 files but was able to fine records based on chain conditions (with respect to keys) used on these files.


      Thanks..

      Comment


      • John192
        John192 commented
        Editing a comment
        here keya is built of composite key means it has multiple fields declared as key fields in it and which are part of another file let's say it's file4 and keyc also has multiple fields declared as key fields inside it but all the key fields inside this keyc field are present in file3.

        so in a single SQL statement how can I test whether all these chain conditions are true and what is the cause of a particular field value from file3 which is being moved as blank value inside a file in this program which is declared in output mode.


        Thanks..

    • #4
      Have you tried running the code in debug? Maybe one of your key fields in the program doesn't have the value you think it does and causing the chain to find a different record than you think it does. Running in debug can help shed light on exactly what is happening.

      Comment


      • #5
        yes, i tried it in debug mode and in debug mode program does go inside exsr and i see different values are assigned based on fil1,file2,,file3 and associated files of keya,keyb and keyc inside the file declared in this program in output mode but specially that field has blank value inside it when i do strsql on that file once the program is executed.

        also same I found in debug mode that value is blank which is moved inside that specific field whereas records do exists based on keyc in file3.

        also since programs goes inside exsr that shows that all these three chain conditions are true then only it is going inside that exsr right?

        and once it goes inside that exsr i can see other values are moved in that output file based on field values ( in eval statements of this program) of file1,file2,,file3 and associated files of keya,keyb and keyc inside the fields of the file which is declared in this program in output mode only the specific field value always gets ( in eval statement ) blank value in it.


        Thanks..

        Comment


        • #6
          Are there multiple records that exist in file3 matching keyc? If so, the chain may not be picking up the one you think it is. After the chain look at other field values to see if it is the record you think it should be getting. It is hard trying to troubleshoot your program just from a description and not knowing what data exists in the tables. Obviously something is not as you assume it to be so check all assumptions as you step through the program, eventually you will find something that doesn't match what you expect.

          Comment


          • #7
            Is there any SQL query I can try building up considering these keys a,b,c and files involved in chain conditions to quickly identify that what is the cause of blank value for that specific field here?


            Thanks...

            Comment


            • #8
              Run 3 SELECT statement on each file
              SELECT * FROM FILE1 WHERE KeyField = value in KEYA
              SELECT * FROM FILE2 WHERE KeyField = value in KEYB
              SELECT * FROM FILE3 WHERE KeyField = value in KEYC

              And take a look at your results.

              Comment


              • #9
                In another post I saw you refer to STRSQL. I find that tool "clunky" and much prefer Access Client Solutions.
                I do all my SQL scripting there, adding comments, saving scripts to the network etc...
                Not limited to "green screen" window size.

                Comment


                • #10
                  But for following SQL queries :-

                  For example for first SQL query i have keyfield keya which is composite key and built of 3 key fields and these fields are of another file so how can i compare it secondly
                  if it shows thousands of such records in each of these SQL queries then how would i be able to conclude with so many values that because of this reason value is blank because when i debug this program i always find blank values in eval statement inside the program when it does like this eval fldX fldY ( here just for example i am explaining fldX is part of file3 and fldY is part of that file which is declared inside my program in output mode on which when I do STRSQL then for this specific field I always find blank values in that specific field let's say in fldY .) even though when i do SQL query like this :- select * from file3 where fldY <>'' and fldZ<>'' (here let's say KEYC is a composite key and built of two key fields fldY and fldZ) then I am able to see records inside this file3 for these fields fldY and fldZ which are part of this composite key KEYC.


                  So in debug mode evenif i assign forecefully nonblank values of fldY in fldY then which as per eval statement in this program will further assign it to that fldX of that file which i s declared in output mode and always shows blank values inside this field then what is the use of this debug then when i have to forecefully assign the values despite the values are there with nonblank values too inside this file3 for Keyc (which further has two subfields defined as keyfields inside the program let's say for example there name are fldY and fldZ)

                  "Run 3 SELECT statement on each file
                  SELECT * FROM FILE1 WHERE KeyField = value in KEYA
                  SELECT * FROM FILE2 WHERE KeyField = value in KEYB
                  SELECT * FROM FILE3 WHERE KeyField = value in KEYC

                  And take a look at your results. "



                  Thanks..

                  Comment


                  • John192
                    John192 commented
                    Editing a comment
                    just for correction in my statement "hen it does like this eval fldX fldY ( here just for example i am explaining fldX is part of file3 and fldY is part of that file which is declared inside my program in output mode on which when I do STRSQL then for this specific field I always find blank values in that specific field let's say in fldY .)"


                    Here fldX is part of a file which is declared in output mode (and shows blanks values always) inside the program and fldY is a part of key fields (KEYC has two key fields :- fldY and fldZ) of KEYC for this statement inside the program:-

                    keyc chain file3 20


                    Thanks...

                • #11
                  When troubleshooting data, I often build a very inclusive query that returns too much data.
                  Then gradually narrow the results, by adding more conditions to the WHERE clause, or including another JOIN, or adding another condition to the JOIN.
                  Perhaps then, at some point, you will discover what is restricting the data that you are expecting, but not getting.
                  Last edited by MFisher; February 8, 2022, 08:33 AM.

                  Comment


                  • #12
                    But two things seem to be clear :- 1) program is going inside exsr that is the proof that all 3 chain conditions are true.
                    2) in this exsr that specific field is getting blank value despite this 3rd chain condition is true:-
                    keyc chain file3 20

                    also there are records with respect to key fields of keyc (KEYC has two key fields :- fldY and fldZ) in file3 that i checked by doing strsql.

                    so now what is the cause of this blank value which is assigned to a specific field (fldX) of the file declared in the output mode here from the field of file3 whereas all the records with respect to this field in file3 are not having blank values in it.



                    Thanks..

                    Comment


                    • #13
                      I have run into this before.

                      Is FLDX being used in the program? If the compiler listing shows RNF7031 beside FLDX, you're not using the field.

                      If you're not using the field, the compiler won't load it.

                      Comment


                      • #14
                        That fldX is the field of the file which is declared inside the program in output mode only and used to get it's fields values assigned from the different files file1,file2,file3 and from the files where these keys keya,keyb,keyc are referred from.

                        I don't see that *RNF7031 on left side of this fldX in compiler listing.



                        Thanks..

                        Comment


                        • #15
                          Originally posted by John192 View Post
                          But two things seem to be clear :- 1) program is going inside exsr that is the proof that all 3 chain conditions are true.
                          2) in this exsr that specific field is getting blank value despite this 3rd chain condition is true:-
                          keyc chain file3 20

                          also there are records with respect to key fields of keyc (KEYC has two key fields :- fldY and fldZ) in file3 that i checked by doing strsql.

                          so now what is the cause of this blank value which is assigned to a specific field (fldX) of the file declared in the output mode here from the field of file3 whereas all the records with respect to this field in file3 are not having blank values in it.


                          Thanks..
                          Perhaps the value in the file is blank, so the chain succeeds with a blank parm.

                          Comment

                          Working...
                          X