M
Mike Fechner
Guest
Take this program: DEFINE TEMP-TABLE ttTest NO-UNDO FIELD MyField AS CHARACTER INDEX MyField IS UNIQUE MyField . DEFINE VARIABLE i AS INTEGER NO-UNDO. DO i = 1 TO 2: RUN test. END. MESSAGE "after" VIEW-AS ALERT-BOX . FOR EACH ttTest: DISPL ttTest. END. PROCEDURE test: MESSAGE i VIEW-AS ALERT-BOX . DO TRANSACTION: CREATE ttTest . ASSIGN ttTest.MyField = "42" . END. END. The second iteration will violate uniqueness. So within the second invocation of the test procedure you get: ** ttTest already exists with "42". (132) Then the message “after”. And three times ** ttTest already exists with "42". (132) as we reach the FOR EACH – which is where the buffer scope ends. Remove the DO TRANSACTION Block and the flow is 100% the same. The CREATE is never undone (because the TT is NO-UNDO). But I bet most programmers – at first sight – would expect the CREATE to get undone. You can resolve this for instance by adding this inside the DO TRANSCATION block: CATCH err AS Progress.Lang.Error: IF AVAILABLE ttTest THEN DELETE ttTest . END CATCH .
Continue reading...
Continue reading...