:: krowemoh

Thursday | 26 DEC 2024
Posts Links Other About Now

previous
next

Errors in Using UniVerse Transactions

2023-05-03
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
*