--- Title: Errors in Using UniVerse Transactions Date: 2023-05-03 Sequence: 1 Tags: ["multivalue","database","universe"] ---
I was playing around with UniVerse transaction blocks and kept running into a strange error. I originally thought I had screwed something up in the way I set up universe as the message is quite cryptic.
Program "TEST.NIV": Line 8, FATAL: The locks necessary for database operations at the current isolation level (0) are not held by this process. Rolling back uncommitted transactions begun within this execution environmen
The error seems to be saying the process doesn't have the permissions to do the locking required to rollback. I tried running it as root as well but that also didn't pan out.
Ultimately the error was that I didn't have a READU, it looks like I need to acquire a lock on reading and that even using a WRITEU isn't enough inside a transaction block.
The below code should work now:
* OPEN '','CONTROL-FILE' TO CONTROL.FILE ELSE PRINT 'Unable to open file: CONTROL-FILE - Press RETURN': INPUT ANYTHING STOP END * BEGIN TRANSACTION READU TEST FROM CONTROL.FILE,'TEST' ELSE TEST = '' WRITEU 'Hello' ON CONTROL.FILE,'TEST' ROLLBACK END TRANSACTION *