Adxlog
adxlog
is a variable that states if a database transaction has already been started (by Trbegin).
adxlog
`adxlog` can have two values:This is especially useful when a function performs several updates that have to be executed either autonomously as a consistent transaction, and can be executed in a bigger transaction.
# A stock movement increases the quantity from a location A and decreases the same quantity from a location B# This function can be called within a transaction or autonomouslyFunprog STOCK_MOVE(LOC_A, LOC_B, PRODUCT, QUANTITY)Value Char LOC_A(), LOC_B(), PRODUCT()Value Decimal QUANTITYLocal Shortint IFTRANSACIFTRANSAC=adxlogIf IFTRANSAC=0 : Trbegin [STO] : EndifUpdate [STO] where LOC=LOC_A With QTY=QTY+QUANTITYIf fstat=0Update [STO] where LOC=LOC_B With QTY=QTY-QUANTITYEndifIf fstatIf IFTRANSAC=0 : Rollback : EndifEnd [V]CST_AERROREndifIf IFTRANSAC=0 : Commit : EndifEnd [V]CST_AOK