Issue 31670  —   Grid: Read trigger fired many times after scrolling and using $hits

Status:   Planned for resolution in 10.3.01

Solution available in patch(es):      10.3.01.007    9.7.05.007

Description:

 Summary:
 Uniface:
 A first retrieve and some scrolling through records is done in a grid.
 Next a clear,  second retrieve and checking $hits takes place.
 Now the read trigger fires many times: Matching the number
 of times the read trigger fired after the first retrieve and the scrolling.

 Environment:
 Uniface:
 Uniface Nine and Ten

 Operating System:
 OS independent

 Database:
 DBMS independent

 Symptoms
 A first retrieve and some scrolling through records is done in a grid.
 Next a clear,  second retrieve and checking $hits takes place.
 Now the READ trigger fires many times: Matching the number
 of times the READ trigger fired after the first retrieve and the scrolling.

 Example using the ugrid_person entity:
 step size set to 2. 4 rows visible in the grid.
 In the database there are 14 records with content field ABBREVIATION starting
 with X.
 In the database there are 14 records with content field ABBREVIATION starting
 with Y.
 In EXEC trigger
 ABBREVIATION.UGRID_PERSON/INIT = "X<GOLD>*"
 retrieve
 I/O function: S, mode: 0, on file/table: UGRID_PERSON index: 1 >=
  Where ((ABBREVIATION Like 'X*'))
 -> Hits selected: 2 .
 edit
 Scrolling takes places until ninth row is visible at the bottom of the grid.
 The READ trigger fires 10 times.

 Now clear and a second retrieve is done retrieving the records starting with Y:
 clear
 retrieve/e "UGRID_PERSON"
 I/O function: S, mode: 0, on file/table: UGRID_PERSON index: 1 >=
  Where ((ABBREVIATION Like 'Y*'))
 TOT_HITS.DSP = $hits(UGRID_PERSON.UGRID)
 I/O function: S, mode: 3, on file/table: UGRID_PERSON index: 1 >=
  Where ((ABBREVIATION Like 'Y*'))
  -> hits 14 .

 The READ trigger now fires 10 times.
 Doing the same test without using $hits the READ trigger fires 6 times after
 the second retrieve.
 Doing the same test without scrolling after the first retrieve the READ trigger
 fires 6 times after the second retrieve.

Workaround:

 Do not use $hits (lookup , selectdb , 4gl sql, ...)
 For example
 lookup
 TOT_HITS.DSP = $status
   retrieve
   if ($status < 0)
     message $text(1762) ;error
   endif
 
   Realize that lookup will only look at primary key fields.
 
 or
 
 After checking $hits repeat the second retrieve:
 variables
 string searchprofile
 endvariables
 putlistitems/occ searchprofile,"<theent>"
 retrieve/e "<theent>"
 if ($status < 0)
    message $text(1762) ;error
 endif
 TOT_HITS.DSP = $hits(UGRID_PERSON.UGRID)
 clear/e "<theent>"
 getlistitems/occ/init searchprofile,"<theent>"
 retrieve/e "<theent>"
 if ($status < 0)
   message $text(1762) ;error
 endif
 
 Realize that means two times a database access is done.

Notes: