Symptom

Using PowerBuilder and the datastore.find() is returning the incorrect row number.

From the PowerBuilder online help:
Find - finds the next row in a DataWindow or Datastore in which data meets a specified condition

Syntax:
long datastore.Find ( stringexpression, longstart, longend )

Environment

  • PowerBuilder

Reproducing the Issue

The following code was used to reproduce the issue:

ds_mast = ids_route_master

ll_rows = ads_stops.rowcount()

forll_count = 1 to ll_rows
   ls_route_num = adw_stops.getitemstring(ll_count,'route_num')
   ll_stop_id = adw_stops.getitemnumber(ll_count,'stop_id')
   ll_find = ds_mast.find("route_num = '" + ls_route_num + "' and stop_id = " + string(ll_stop_id),ll_find,ds_mast_rowcount()+1)

loop

Cause

Datastore.find() was returning the incorrect row because of this line of code:
ds_mast = ids_route_master

The datastore was being copied to another datastore but the 'internal' pointer stored in
ids_route_master is copied to ds_mast.

Resolution

Used the Rowscopy to copy the data from the ids_route_masterdatastore to the ds_mastdatastore.

ids_route_master.RowsCopy(ids_route_master.GetRow(), ids_route_master.RowCount(), Primary!, ds_mast, 1, Primary!)

0
0