ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

OAR and joined LF's

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

  • #16
    Originally posted by Barbara Morris View Post
    You shouldn't try to allocate memory to anything except the stateInfo subfield of the parameter.

    If the inputNullMap pointer is null, it means that the RPG program didn't have ALWNULL(*USRCTL) as an H spec keyword or command parameter.

    Even if you could set the inputNullMap pointer when it's null, RPG wouldn't notice it after your handler returned since it would only be looking at the data in the null map if it expected it.
    that worked - i thought I would need it for the handler pgm, but that did not work... so i added the h-spec to the pgm that calls the handler and that worked...

    Comment


    • #17
      my latest struggle...

      as an attempt to get familiar with the OAR behavior, I have my rpg pgm doing this...

      chain ('01'
      :'1001-80641-1 '
      :'012'
      :0000000
      :'PI') srvbmst;
      if %found(srvbmst);
      dsply (%trim(zbmst2));
      endif;

      read srvbmst;
      if not %eof(srvbmst);
      dsply (%trim(zbmst2));
      endif;

      readp srvbmst;
      if not %eof(srvbmst);
      dsply (%trim(zbmst2));
      endif;

      *inlr = *on;


      the chain works fine... i then want to do the read and finally the readp... the read is getting a pointer error

      Pointer not set for location referenced.

      attached is the handler pgm code

      figured i'll be stuck on this one for a while so thought i'd go ahead and signal for help...
      You'll see where I'm trying to keep it as simple as possible and reuse the handleChain() procedure for CHAIN/READ/READP... by simply renaming it handleGetRecord() and passing it either "FIRST", "NEXT", or "PRIOR", as these relate to sql cursor fetch operations. If I can maintain this design, i'd really like to do so.

      Attached Files

      Comment


      • #18
        disregard - getting it all to work... this is too much fun

        Comment


        • #19
          so here's the recent issue...

          RLA

          chain (some key) fileA
          record found

          readp... reads record prior to chained record no problem...


          SQL

          my chain equivalent looks like...

          g_sqlStmt = 'select * ' +
          'from ' + %trim(l_table) + ' ' +
          'where bankno >= ? ' +
          'and bankac >= ? ' +
          'and inv# >= ? ' +
          'and pool# >= ? ' +
          'and type >= ? ' +
          'for fetch only';

          exec sql
          prepare s1 from :g_sqlStmt;


          exec sql
          declare c1 scroll cursor for s1;

          exec sql
          open c1 using :i_bankno
          ,:i_bankac
          ,:i_inv#
          ,:i_pool#
          ,:i_type;
          exec sql
          fetch first from c1 into _dsInpRcd
          _indArray;


          I'll admit, my chain equivalents in regular embedded rpg is usually a select into, but Dan encouraged using the cursor to leverage other opcodes such as read/readp

          however based on how my select statement was built, i hit an EOF on a READP prior to my key value because of the >=

          i do the readp by simply... utilizing the current cursor and...

          exec sql
          fetch prior from c1 into _dsInpRcd
          _indArray;

          so what is the best modification to allow a chain and then a readp (to access records, prior to the chain in the selected record set)?

          Comment


          • #20
            Just a guess ... but maybe you have to reopen the cursor using <= if you get a READP, and ignore the first record returned. You'd have to save the keys from the CHAIN in your state info.

            Comment


            • #21
              thats a good call - and i'm learning tons about how this works

              Comment

              Working...
              X