Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the meaning of NO-UNDO on define variable in progress 4gl?

I am the beginner for progress 4GL language and I'd like to know about the difference between NO-UNDO and NO-ERROR in progress 4gl language.

like image 525
Thiru Avatar asked Aug 07 '18 06:08

Thiru


1 Answers

NO-ERROR

No error supresses errors in the runtime and hands the responsibility for those error and their handing to you, the developer.

/* 
In this example we do basically the same thing twice, once with no-error and once without. 
Without no-error the program will exit and the last message box will not be shown.
*/
DEFINE TEMP-TABLE tt NO-UNDO
    FIELD a AS INTEGER.

CREATE tt.
ASSIGN tt.a = INTEGER("HELLO") NO-ERROR.
IF ERROR-STATUS:ERROR THEN DO:
    MESSAGE "There was an error" VIEW-AS ALERT-BOX ERROR.
    /* You will be left with a tt-record with 0 as field value */
END.


MESSAGE "After no-error" VIEW-AS ALERT-BOX.

CREATE tt.
ASSIGN tt.a = INTEGER("GOODBYE").

MESSAGE "After error" VIEW-AS ALERT-BOX.

NO-UNDO

No-undo removes undo handling. This is usually the default preferred behavior unless you need temp-tables, variables etc to utilize undo-handling. A very basic example below.

Unless you really need undo handling it better be avoided. It might effect performance, local disk writes etc. It also limit the length of character variables etc.

Note: changed from "default" to "preferred behavior" as this is a better description

DEFINE VARIABLE cTxt1 AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTxt2 AS CHARACTER.

DO TRANSACTION:

    ASSIGN 
        cTxt1 = "HELLO"
        cTxt2 = "GOODBYE".

    MESSAGE "Do you want to undo?"
        VIEW-AS ALERT-BOX 
        BUTTONS YES-NO
        UPDATE lAnswer AS LOGICAL.

    IF lAnswer THEN 
        UNDO, RETRY.        

 END.

 DISPLAY cTxt1 cTxt2.
like image 112
Jensd Avatar answered Nov 02 '22 23:11

Jensd