Hi,
I just started learning Progress this week, and I've been stuck on an efficient way to do a FIND LAST with a WHERE clause that will look at 2 tables.
My goal, is to find the last entry in a table for a particular day, with conditions.
I was able to find the value using a FOR EACH, however I was shocked at just how long this was taking, so I need a faster way. I had also tried to do a BREAK BY on the date, but I didn't seem to be getting what I was expecting.
Scan Table:
scanID (int, pk)
empl-no (char)
scannedOn (datetime)
ScanCode Table
scanID (int, pk, fk)
oneWay (logical)
My Code:
DEF VAR lastEntryTime AS DATETIME INIT '01/01/1970'.
DEF VAR lastEntryId AS ROWID.
DEF BUFFER scan2 FOR scan.
FOR EACH scan2, EACH scanCode WHERE scan2.scanID = scanCode.scanID
AND DATE(scan2.scannedOn) = DATE(tempReportTable.scannedOn)
AND scan2.empl-no = tempReportTable.scannedOn
AND scanCode.oneWay = FALSE:
IF (scan2.scannedOn > lastEntryTime) THEN
DO:
lastEntryTime = scan3.scannedOn.
lastEntryId = ROWID(scan3).
END.
END.
I had tried to set this up as a "FIND LAST scan2, EACH scanCode" which doesnt compile, and I tried "FIND LAST scan2 OF scanCode" which compiles, but always fails.
Anyone have any suggestions?
I just started learning Progress this week, and I've been stuck on an efficient way to do a FIND LAST with a WHERE clause that will look at 2 tables.
My goal, is to find the last entry in a table for a particular day, with conditions.
I was able to find the value using a FOR EACH, however I was shocked at just how long this was taking, so I need a faster way. I had also tried to do a BREAK BY on the date, but I didn't seem to be getting what I was expecting.
Scan Table:
scanID (int, pk)
empl-no (char)
scannedOn (datetime)
ScanCode Table
scanID (int, pk, fk)
oneWay (logical)
My Code:
DEF VAR lastEntryTime AS DATETIME INIT '01/01/1970'.
DEF VAR lastEntryId AS ROWID.
DEF BUFFER scan2 FOR scan.
FOR EACH scan2, EACH scanCode WHERE scan2.scanID = scanCode.scanID
AND DATE(scan2.scannedOn) = DATE(tempReportTable.scannedOn)
AND scan2.empl-no = tempReportTable.scannedOn
AND scanCode.oneWay = FALSE:
IF (scan2.scannedOn > lastEntryTime) THEN
DO:
lastEntryTime = scan3.scannedOn.
lastEntryId = ROWID(scan3).
END.
END.
I had tried to set this up as a "FIND LAST scan2, EACH scanCode" which doesnt compile, and I tried "FIND LAST scan2 OF scanCode" which compiles, but always fails.
Anyone have any suggestions?