ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Join

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

  • Join

    i have two files trying to join, In SFAM file there is a field RGLPK that joins to SFLPI. It joins fine but here is the problem we stopped using RGLPK so now the new data
    is being entered into field SRLPK. So i want to join on both fields? Is this possible so i can get the old data and the new data in one file. Below I tried to put the

    A R SFFMT JFILE(SFAM SFLPI)
    A J JOIN(SFAM SFLPI)
    A JFLD(RGLPK LLIK)
    A* J JOIN(SFAM SFLPI)
    A* JFLD(SRLPK LLIK)
    A LLPGM
    A SSS#
    A LSAMS#
    A RSRVYR
    A RSRVMO
    A RSRVDA

  • #2
    Re: Join

    sorry about that i didnt get it all in

    Join
    i have two files trying to join, In SFAM file there is a field RGLPK that joins to SFLPI. It joins fine but here is the problem we stopped using RGLPK so now the new data
    is being entered into field SRLPK. So i want to join on both fields? Is this possible so i can get the old data and the new data in one file. Below I tried to put the join in again like
    an or? Is this possible?

    A R SFFMT JFILE(SFAM SFLPI)
    A J JOIN(SFAM SFLPI)
    A JFLD(RGLPK LLIK)
    A* J JOIN(SFAM SFLPI)
    A* JFLD(SRLPK LLIK)
    A LLPGM
    A SSS#
    A LSAMS#
    A RSRVYR
    A RSRVMO
    A RSRVDA

    Comment


    • #3
      Re: Join

      Why make a joined logical. So old school. Sql is so much better
      Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

      Comment


      • #4
        Re: Join

        Originally posted by Danba View Post
        sorry about that i didnt get it all in

        Join
        i have two files trying to join, In SFAM file there is a field RGLPK that joins to SFLPI. It joins fine but here is the problem we stopped using RGLPK so now the new data
        is being entered into field SRLPK. So i want to join on both fields? Is this possible so i can get the old data and the new data in one file. Below I tried to put the join in again like
        an or? Is this possible?

        A R SFFMT JFILE(SFAM SFLPI)
        A J JOIN(SFAM SFLPI)
        A JFLD(RGLPK LLIK)
        A* J JOIN(SFAM SFLPI)
        A* JFLD(SRLPK LLIK)
        A LLPGM
        A SSS#
        A LSAMS#
        A RSRVYR
        A RSRVMO
        A RSRVDA
        If I hear what you're asking properly - can you get the join using EITHER the old key (RGLPK) or the new key (SRLPK). I don't know of a way to do it in DDS - but you can using DDL (SQL).
        Code:
        CREATE VIEW lib.vwname AS
        SELECT LLPGM,SSS#,LSAMS#,RSRVYR,RSRVMO,RSRVDA FROM SFAM A JOIN SFLPI B ON ((RGLPK=LLIK) OR (SRLPK=LLIK))
        RCDFMT rcdfmtname
        You can use this file in your RPG program just as you would any join file EXCEPT a join can have keys - a view cannot.

        Comment


        • #5
          Re: Join

          I dont know sql very well, where is a good place to learn it?

          Comment


          • #6
            Re: Join

            I picked mine up primarily through the RPG & DB2 Summit (http://systemideveloper.com/summit/conferences.html) and COMMON - last spring I took the extra session on SQL that Birgitta taught and it was awesome.

            Comment


            • #7
              Re: Join

              Originally posted by Danba View Post
              ...here is the problem we stopped using RGLPK so now the new data
              is being entered into field SRLPK.
              Does that mean that field RGLPK is null (or blank/zero or some other guaranteed value) when the new field is used?
              Tom

              There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

              Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

              Comment

              Working...
              X