ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

keys for chain and read

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

  • keys for chain and read

    Can someone tell me if there is a difference between:

    Code:
                chain keyfld filename;
    and

    Code:
                chain (keyfld) filename;
    when the key is only one field? If so, can you explain what that difference is?

    Thanks,
    Michael
    "Time passes, but sometimes it beats the <crap> out of you as it goes."

  • #2
    Re: keys for chain and read

    You use the parentheses to specify a keylist (such as an ad-hoc key list).


    Code:
    chain ( OrderNbr : Sequence ) OrderDtl;
    If you are only using a single field to chain with, then the parentheses arent needed.


    Code:
     
    chain OrderNbr OrderH;
    You can also use expressions to create the key field, in which you would need the parentheses as well.

    Code:
    chain ( %trimr( SubPart ) + 'A' ) Inventory;
    Michael Catalani
    IS Director, eCommerce & Web Development
    Acceptance Insurance Corporation
    www.AcceptanceInsurance.com
    www.ProvatoSys.com

    Comment


    • #3
      Re: keys for chain and read

      and if you're doing a chain by RRN parens are not allowed the compiler will barf since it would never be a key list on an RRN chain(i.e. subfile)
      I'm not anti-social, I just don't like people -Tommy Holden

      Comment


      • #4
        Re: keys for chain and read

        That's what I thought.

        Thanks.
        "Time passes, but sometimes it beats the <crap> out of you as it goes."

        Comment


        • #5
          Re: keys for chain and read

          it would be better for you to put the parentheses to identify the key. many people confuse, including the as400 which at certain condition, it shows error because of missing the parentheses.

          won't harm by just add 2 characters into the coding than having possible error, right? hehe
          "Nothing is impossible in coding. If the logic exist in this world, so as programming world. All we need it the bravery to ask others for help and a thanks for all the gifts received"

          Comment


          • #6
            Re: keys for chain and read

            Originally posted by Windy Chia View Post
            it would be better for you to put the parentheses to identify the key. many people confuse, including the as400 which at certain condition, it shows error because of missing the parentheses.

            won't harm by just add 2 characters into the coding than having possible error, right? hehe
            i use the parens if the chain,etc are not being processed by RRN that way when i see a single field on a chain i know immediately if it's RRN (SFL) or an actual key list value. if you try to compile on a RRN CHAIN the compiler will "barf" if you have parens around the key field. with keyed chains the compiler doesn't care if it's in parens or not.
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment

            Working...
            X