Skip to main content

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
------------------------------

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
------------------------------

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
------------------------------
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
------------------------------

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
------------------------------


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
------------------------------

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
------------------------------

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
------------------------------

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
------------------------------

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
------------------------------

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
------------------------------