Rocket U2 | UniVerse & UniData

 View Only

 Status values in uopy

  •   UOPY
Héctor Cortiguera's profile image
PARTNER Héctor Cortiguera posted 10-29-2021 12:49
Hi all

I'm doing a simple test using uopy to write some data to the 'UP' file.

    with uopy.connect(host=...', user='...', password='...', account='...', encoding='cp1252',
                      service=uopy.UV_SERVICE, port=31438) as session:
        codigo_subrutina = [
            "SUBROUTINE PRUEBA.ENV(XINPUT,XOUTPUT)",
            "*",
            "* Programa Universe de prueba. Test tildes: á, é, í, ó, ú.",
            "*",
            "   XOUTPUT=\"Salida del programa\"",
            "RETURN"]
        nombre_subrutina = 'PRUEBA.ENV'
        with uopy.File('UP') as up_file:
            up_file.write('PRUEBA.ENV', DynArray(codigo_subrutina))
            print(up_file.status)​

I'm getting the value -2 in up_file.status.

What does this mean? Is there some documentation about this status values?
Mike Rajkowski's profile image
ROCKETEER Mike Rajkowski
The Status on the uopy.File object is from the last function/method called on the object.  In your example, the -2 is for "The record was unlocked before the operation."   

Note that these statuses are returned from the server, and are the same as their BASIC equivalent: 

After a MATWRITE, WRITE, WRITEU, WRITEV, or WRITEVU statement:
Value       Description
  0               The record was locked before the operation.
  3                In NLS mode, the unmappable character is in the record ID.
  4                In NLS mode, the unmappable character is in the record’s data.
-2                The record was unlocked before the operation.
-3                The record failed an SQL integrity check.
-4                The record failed a trigger program.
-6                Failed to write to a published file while the subsystem was shut down.

So, for your example, you can change the status by reading and locking the item first: