IBM InfoSphere DataStage, Version 11.3.1
TRANSACTION ABORT statement
Syntax
TRANSACTION ABORT
Description
Use the TRANSACTION ABORT statement to cancel all file I/O changes made during a transaction.
You can use the TRANSACTION ABORT statement in a transaction without a TRANSACTION COMMIT statement to review the results of a possible change. Doing so does not affect the parent transaction or the database.
After the transaction ends, execution continues with the statement following the TRANSACTION ABORT statement.
Example
The following example shows the use of the TRANSACTION ABORT statement to terminate a transaction if both the ACCOUNTS RECEIVABLE file and the INVENTORY file cannot be successfully updated:
PROMPT ''
OPEN 'ACC.RECV' TO ACC.RECV ELSE STOP 'NO OPEN
ACC.RECV'
OPEN 'INVENTORY' TO INVENTORY ELSE STOP 'NO OPEN
INVENTORY'
PRINT 'Customer Id : ':
INPUT CUST.ID
PRINT 'Item No. : ':
INPUT ITEM
PRINT 'Amount : ':
INPUT AMOUNT
* Start a transaction to ensure both or neither
records
* updated
TRANSACTION START ELSE STOP 'Transaction start
failed.'
* Read customer record from accounts receivable
READU ACT.REC FROM ACC.RECV, CUST.ID
ON ERROR
STOP 'Error reading ':CUST.ID:' from ACC.RECV
file.'
END LOCKED
* Could not lock record so ABORT transaction
TRANSACTION ABORT
STOP 'Record ':CUST.ID:' on file ACC.RECV locked
by user ':STATUS()
END THEN
* Build new record
ACT.REC<1,-1> = ITEM:@SM:AMOUNT
ACT.REC<2> = ACT.REC<2> + AMOUNT
END ELSE
* Create new record
ACT.REC = ITEM:@SM:AMOUNT:@FM:AMOUNT
END
* Read item record from inventory
READU INV.REC FROM INVENTORY, ITEM
ON ERROR
STOP 'Error reading ':ITEM:' from INVENTORY file.'
END LOCKED
* Could not lock record so ABORT transaction
TRANSACTION ABORT
STOP 'Record ':ITEM:' on file INVENTORY locked by
user ':STATUS()
END THEN
* Build new record
INV.REC<1> = INV.REC<1> - 1
INV.REC<2> = INV.REC<2> - AMOUNT
END ELSE
STOP 'Record ':ITEM:' is not on file INVENTORY.'
END
* Write updated records to accounts receivable and
inventory
WRITEU ACT.REC TO ACC.RECV, CUST.ID
WRITEU INV.REC TO INVENTORY, ITEM
TRANSACTION COMMIT ELSE STOP 'Transaction commit
failed.'
END
Last updated: 2015-03-09
PDF version of this information: