Rocket OpenQM

 View Only
  • 1.  Working with indexes and SELECTINDEXV

    Posted 06-13-2023 07:10

    I am learning how index work in OpenQM.  But, my program is aborting when I try to address the "list.var"

    SELECTINDEXV index.name {, valueFROM file.var TO list.var

    Here is my test program:

    PROGRAM TEST.SELECTINDEXV
      OPEN "MEMBERS" TO MF ELSE CRT "CANNOT OPEN MEMBERS"; STOP
      SELECTINDEXV 6,"999-999-9999" FROM MF TO MEMBER.ID
      CRT MEMBER.ID
      IF MEMBER.ID="" THEN
        CRT "NO VALUE"
      END
    END

    Here my results with the abort.  MEMBER.ID is the correct ID.

    :RUN BP TEST-INDEX2
    00500
    00000121: Value not found where required at line 5 of /usr/qmsys/TEST/BP.OUT/TEST-INDEX2
    :



    ------------------------------
    Tedmund Hurlbut
    Self Registered
    Simpsonville SC US
    ------------------------------



  • 2.  RE: Working with indexes and SELECTINDEXV

    Posted 06-13-2023 08:10
    MEMBER.ID is an array of members. 
    Your program must be this way:
    PROGRAM TEST.SELECTINDEXV
      OPEN "MEMBERS" TO MF ELSE CRT "CANNOT OPEN MEMBERS"; STOP
      SELECTINDEXV 6,"999-999-9999" FROM MF TO MEMBER.ID
      LOOP
       READNEXT ID FROM MEMBER.ID THEN
         ...do something
    CRT ID
       END ELSE
        EXIT
       END
      REPEAT
    STOP
    END
    or this way:
    PROGRAM TEST.SELECTINDEXV
      OPEN "MEMBERS" TO MF ELSE CRT "CANNOT OPEN MEMBERS"; STOP
      SELECTINDEXV 6,"999-999-9999" FROM MF TO MEMBER.ID
      READLIST MYLIST FROM MEMBER.ID
      CCO=DCOUNT(MYLIST,@AM)
      FOR I=1 TO CCO
         ...do something
    CRT MYLIST<I>
      NEXT I  
    STOP
    END
    HTH


    ------------------------------
    Angel Rivas
    Kosday
    ------------------------------



  • 3.  RE: Working with indexes and SELECTINDEXV

    Posted 06-13-2023 09:42

    Angel,

    Thanks. This sure helped.  I did it without the loop since if I had a hit, all I wanted was the MEMBERS ID.  No abort!

    PROGRAM TEST.SELECTINDEXV
      OPEN "MEMBERS" TO MF ELSE CRT "CANNOT OPEN MEMBERS"; STOP
      SELECTINDEXV 6,"999-999-9999" FROM MF TO MEMBER.ID
      CRT MEMBER.ID
      READLIST MYLIST FROM MEMBER.ID
      CRT "MYLIST '":MYLIST:"'"
      IF MYLIST="" THEN
        CRT "NO VALUE"
      END
    END

    :RUN BP TEST-INDEX2
    00500
    MYLIST '00500'
    :



    ------------------------------
    Tedmund Hurlbut
    Self Registered
    Simpsonville SC US
    ------------------------------



  • 4.  RE: Working with indexes and SELECTINDEXV

    Posted 06-14-2023 15:50

    Hi Ted,

    There is a sample class routine for walking indexes in the QMSYS BP file named 'index.cls'.  Of course, you have to use object syntax to use that class which takes a while to get used to. But even if you don't use this class, then reading the code will help you understand how to use the indices in OpenQM.

    Cheers,

    Brian



    ------------------------------
    Brian Speirs
    Senior Analyst - Information Systems
    Self Registered
    Wellington NZ
    ------------------------------



  • 5.  RE: Working with indexes and SELECTINDEXV

    Posted 06-15-2023 09:32

    Brian,

    Thank you for the example.  They really help. 

    Have you used the code in the example for "Alternate Key Indices" dealing with Partial Key Look-up?

    "Partial Key Look-up

    Sometimes it is useful to allow a user to type in a text item and, as each character is entered, display a list of items that start with as much as has been typed. The following code shows the principles behind a subroutine that provides this functionality."

    https://docs.rocketsoftware.com/bundle/openqm_ref_4/page/tru1652705885705.html

    This might be something I will try in the future.  This has been missing from our old code that users are looking for.

    Ted



    ------------------------------
    Tedmund Hurlbut
    Self Registered
    Simpsonville SC US
    ------------------------------



  • 6.  RE: Working with indexes and SELECTINDEXV

    Posted 06-15-2023 17:31

    Hi Ted,

    Our indices are mostly time-based (e.g. date; year and week number; or year and month number), so the values of the keys are known and logical. We don't have any need for partial selection.

    I know the example is in the documentation, but haven't had any call to use it.

    Cheers,

    Brian



    ------------------------------
    Brian Speirs
    Senior Analyst - Information Systems
    Self Registered
    Wellington NZ
    ------------------------------