Dataset Batching & Index Question

Posted by Paul Mowat on 02-Jun-2016 09:57

Hi All,

I'm making some changes to implement batching in a ultragrid. I have got it working mostly.

I have the following code.

** Loop round the payrolls populating the temp-table as required.


cQueryString = "PRESELECT EACH employee NO-LOCK WHERE employee.payno = " + STRING(iPayNo) + 
(IF pcQueryString <> "" THEN " AND " + pcQueryString ELSE "") + 
(IF iUserNo <> 0 THEN " AND SUBSTRING(employee.secstring," + STRING(iUserNo) + ",1) <> ~"N~"" ELSE "") +
(IF pcSortPhrase <> "" THEN " " + pcSortPhrase ELSE "").

QUERY qEmployee:QUERY-PREPARE (cQueryString).

If I just specify one payroll it works perfectly fine. However If i specify a list i get issues with the next-rowid and setting the restart-rowid for the next batch, I believe this is because the query has changed and it doesn't know the rowid anymore. I get a message "Cannot reposition query to specified rowid (7331)"

When I first developed this I initially used a list so I can ensure that I still use the required index on the table and don't break it by using a lookup function within the query.

I'm a bit stumped on how I can ensure i process all the required payrolls but ensuring that batching will work and the index will remain in tact. 

Anyone have any ideas? Only one left I have is to try and maintain the context of where i am in the DO loop between fetches of data.



All Replies

Posted by Paul Mowat on 02-Jun-2016 10:13

Just had a thought that I could also parse the payroll list into a string of " payno = 1 or payno = 2 or payno = 3" etc but its not really nice. Is there a better way?

This thread is closed