Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
errStatus = ''
* Begin the transaction
* volname is the name you used in the connection / attach
* call attach_Table(“MVBFS_TEST”, ‘’, ‘’)
stat = rti_transaction(volname, 'BEGIN', errStatus)
* Read a record in a reversable manner
If stat then
stat = RTI_READU( f_customers, cust_id, cust_rec)
End
* Change it, write it back
If stat Then
cust_rec<1> = ' changed ' : timedate()
stat = RTI_WRITEU( f_customers, cust_id, cust_rec)
End
stat = RTI_READU( f_orders, order_id, orders_rec)
If stat Then
orders_Rec<1> = ' changed ' : timedate()
stat = RTI_WRITEU( f_orders, order_id, orders_rec)
End
* Success? else roll back
If stat then
stat = rti_transaction(volname, 'COMMIT', errStatus)
End Else
stat = rti_transaction(volname, 'ROLLBACK', errStatus)
End

 

 

SQL

Code Block
* Begin the transaction
stat = rti_transaction(volname, 'BEGIN', errStatus)
If stat then
Read cust_rec from f_customers, cust_id Else
stat = false$
end
End
* Change it, write it back
If stat Then
cust_rec<1> = ' changed ' : timedate()
Write cust_rec On f_customers, cust_id Else
stat = false$
end
End
If stat then
Read orders_rec  from f_orders, order_id Else
stat = false$
end
End
* Change it, write it back
If stat Then
orders_rec<1> = ' changed ' : timedate()
Write orders_rec  On f_orders, order_id Else
stat = false$
end
End
* Success? else roll back
If stat then
stat = rti_transaction(volname, 'COMMIT', errStatus)
End Else
stat = rti_transaction(volname, 'ROLLBACK', errStatus)
End
Linear hash
errStatus = ''
* VOLNAME not required for linear hash use – pass “” instead
* Begin the transaction
stat = rti_transaction('', 'BEGIN', errStatus)
* Read a record in a reversable manner
If stat then
Lock f_customers, cust_id then
Read cust_rec from f_customers, cust_id Else
stat = false$
end
* Change it, write it back
If stat Then
cust_rec<1> = ' changed ' : timedate()
Write cust_rec On f_customers, cust_id Else
stat = false$
end
End
UnLock f_customers, cust_id Else null
End Else
stat = false$
End
end
If stat Then
Lock f_customers, cust_id then
Read orders_rec from f_orders, order_id Else
stat = false$
end
* Change it, write it back
If stat Then
orders_rec<1> = ' changed ' : timedate()
Write orders_rec On f_orders, order_id Else
stat = false$
end
End
UnLock f_orders, order_id Else null
End Else
stat = false$
End
end
* Success? else roll back
If stat then
stat = rti_transaction('', 'COMMIT', errStatus)
End Else
stat = rti_transaction('', 'ROLLBACK', errStatus)
End