ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Memory structure of data structure array vs occurrence data structure

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

  • Memory structure of data structure array vs occurrence data structure

    Hello.

    Correct me if I'm wrong when I say a data structure array and an occurrence data structure are represented exactly the same in memory, all things being equal (same subfields, same dimension/occurrences).

    The reason I ask is: suppose PGMA calls PGMB. PGMA passes a data structure array to PGMB. PGMB defines an occurrence ds (same subfields and dimension) named "dsRec" and uses it in a SQL "fetch c1 for 50 rows into :dsRec". When the SQL statement finished PGMA's data structure array is filled.

    It seems to work fine but I'm wondering if there's some nuance that I'm missing.

    Thanks in advance,
    Mike

  • #2
    The "nuance" is that you will confuse the hell out of the next poor bugger who has to maintain the program. Technically you are correct but MODS are really a deprecated capability and I can't think of any real reasons to go on using them. So why not simply change the definition in the called program?

    Comment


    • #3
      Because embedded SQL has that requirement.

      Comment


      • #4
        A DS array and a multiple-occurrence DS have exactly the same storage layout.

        According to this documentation, a DS array can be used for a fetch. This happens to be the 7.4 version, but even the 7.1 version says the same thing. https://www.ibm.com/docs/en/i/7.4?to...s-that-use-sql

        Comment


        • #5
          Originally posted by mlopez01 View Post
          Because embedded SQL has that requirement.
          Multiple Row Fechtes with embedded SQL into Array Data Structures work fine.
          No need to generate/use MODs anymore

          Comment


          • #6
            I hate it when this happens. I went back into the source and changed OCCURS to DIM (and QUALIFIED) and recompiled so that I could show you the compile error stating something to the effect that the data structure is a dimensional array - but it compiled.

            Lol. I must have had something coded differently at the time.

            Thanks. I'm back to knowing I have moved on from OCCURS.

            Mike

            Comment


            • #7
              Originally posted by Barbara Morris View Post
              A DS array and a multiple-occurrence DS have exactly the same storage layout.

              According to this documentation, a DS array can be used for a fetch. This happens to be the 7.4 version, but even the 7.1 version says the same thing. https://www.ibm.com/docs/en/i/7.4?to...s-that-use-sql
              Thanks, Barbara.

              Comment

              Working...
              X