Bug #5954
FOR EACH in FWD behaves differently than in 4GL when UDF raises an error
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
01/07/2022
Due date:
% Done:
0%
billable:
No
vendor_id:
GCD
case_num:
History
#2 Updated by Igor Skornyakov over 2 years ago
- File foreach-tmp.p added
Consider the following test program (attached):
define temp-table udftest field id as integer field fdate as date field fmt as character field fstr-result as character index pk as primary id . create udftest. id = 1. fdate = date(07, 19, 2021). fmt = '999999'. fstr-result = "071921". create udftest. id = 2. fdate = date(07, 19, 2021). fmt = '99999999'. fstr-result = "07192021". create udftest. id = 3. fdate = date(07, 05, 2021). fmt = '9.9.99'. fstr-result = "7.5.21". create udftest. id = 4. fdate = date(07, 05, 2021). fmt = '99999'. fstr-result = ?. create udftest. id = 5. fdate = date(07, 15, 2021). fmt = '99.999.9999'. fstr-result = "10.015.2021". create udftest. id = 6. fdate = date(07, 15, 2021). fmt = '99.9999.9999'. fstr-result = "10.0015.2021". OUTPUT TO foreach-tmp.txt. def var err-flag as logical no-undo. outer: do on stop undo, leave outer: FOR EACH udftest NO-LOCK WHERE string(fdate, fmt) = fstr-result : message 'inside loop'. err-flag = false. message udftest.id ERROR-STATUS:ERROR ERROR-STATUS:NUM-MESSAGES AVAILABLE udftest. END. end. message 'done' err-flag. OUTPUT CLOSE.
For the record with id
== 4 string(fdate, fmt)
raises an error.
With 4GL the output is:
inside loop 1 no 0 yes inside loop 2 no 0 yes inside loop 3 no 0 yes ** Date format 99999 is incomplete. (154) done no
As we can see the first 3 records are retrieved.
With FWD the output is:
inside loop 1 no 0 yes ** Date format 99999 is incomplete. (154) done no
The same test with a permanent table with FWD fails immediately (no records are processed).