ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

KLIST in variable

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

  • KLIST in variable

    Hi, I want to know whether it is possible to assign a klist to a variable. I have a program that opens a different file depending on the parameters that are passed in. The key list for these files are different, the first is:

    Keylist 1
    Char(4)
    Char(4)
    Char(10)
    Char(10)
    Int(3)

    And the second (a logical of the first) is similar:

    Keylist 2
    Char(10)
    Char(4)
    Char(4)
    Char(10)
    Int(3)

    I need to perform a chain, setll and reade on whichever file is open. Is it possible to have a line such as: chain Key File ?
    Where File is determined by the parameters passed in and Key is one of the key lists.
    If so how do I define the variable Key so that it can either be Keylist 1 or Keylist 2?

    I assume I can use extfile with usropn to determine which file to use.

    Thanks

  • #2
    Re: KLIST in variable

    you can't have a single chain with different keys accessing 2 different files having different key list! it's not possible (and i highly doubt you'll ever see this added).

    if the file to be used is determined by a parameter then you'll have to use IF (or SELECT) constructs to determine which file/key combo to use. also instead of using KLIST use inline keys instead.

    pseudocode:
    Code:
    if myparm = 'FILE1';
      chain (key1_char4: key2_char4:key1_char10:key2_char10:int1) file1;
    else;
      chain (key1_char10:key1_char4:key2_char4:key2_char10:int1) file2;
    endif;
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: KLIST in variable

      In this case I would probably go the route of using Dynamic SQL.

      Comment


      • #4
        Re: KLIST in variable

        Originally posted by soup_dog View Post
        In this case I would probably go the route of using Dynamic SQL.
        Why Dynamic ? A static statement would be enough amply
        Patrick

        Comment


        • #5
          Re: KLIST in variable

          Originally posted by K2r400 View Post
          Why Dynamic ? A static statement would be enough amply
          Thats true, it would.

          Comment

          Working...
          X