Menu

LOGOUT/COMMIT usage

Help
2011-12-19
2013-03-18
  • nenad cikic

    nenad cikic - 2011-12-19

    Since LOGOUT now works I have tried it. First excuse my limit knowledge on the matter since, unfortunately, I do not use it in our main application. Anyway I have found that LOGOUT/COMMIT essentially works. I wanted just to point to 2 or 3 things I have discovered:

    This is my code:
         LOGOUT(10,tecajna_lista,tecajevi)
         if errorcode()
            message('Greška pri pokretanju transakcije!')
            ROLLBACK
            return retVal
         end

         !dodaj domaću valutu
         clear(tecajevi)
         tec:valuta_brojcano=dom_valuta
         tec:kupovni_tecaj=1
         tec:prodajni_tecaj=1
         tec:valuta_slovcano=val:oznaka
         tec:tl_broj_tecajne_liste=tl:broj_tecajne_liste
         tec:tl_datum_tecajne_liste=tl:datum_tecajne_liste
         tec:vmt_vrsta_tecaja='RED'
         tec:paritet=val:paritet
         tec:blokada='N'
         add(tecajevi)
         if errorcode()
            message('Greška pri automatskom dodavanju domaće valute na tečajnu listu!')
            ROLLBACK
            return retVal
         end

         tl:indikator='2'
         put(tecajna_lista)
         if errorcode()
            message('Greška pri ažuriranju statusa tečajne liste!')
            ROLLBACK
            return retVal
         end

         COMMIT
         if not errorcode()
            retVal=true
         end

    1. This is just a question: Is it correct to use ROLLBACK if LOGOUT fails?
    2.If i comment the block if errorcode() after add(tecajevi), so no ROLLBACK is executed, I got error on put(tecajna_lista)
    This seems strange to me. I would expect to add(tecajevi) silently fail and put(tecajna_lista) and COMMIT succedd.
    3.How can I check if COMMIT succedded? It seems to me that if I put blindly
    ROLLBACK
    COMMIT

    the file tecajna_lista is correctly not updated but COMMIT stil returns true

    Thanks
    Nenad

     
  • Andrew Barnham

    Andrew Barnham - 2011-12-19

    1.  Calling rollback on failed logout is fine.  Doesn't really matter; not necessary. But it doesn't cause harm
    2. reason why PUT is failing is connected to how postgres works.  If in between a logout/commit, any error occurs, then no operation to the DB will succeed until you rollback.  There is a way to work around this behaviour if required, using save points.  use {prop:sql} to issue commands to postgres. See postgres documentation on savepoints.
    3.  rollback followed by commit means : rollback all changes. The commit then says commit all changes, but since the rollback there are no changes to commit so nothing happens.  Always issue COMMIT() and then check ERRORCODE() afterwards.

     
  • nenad cikic

    nenad cikic - 2011-12-19

    OK, then it is all OK.
    Super
    Nenad

     
  • nenad cikic

    nenad cikic - 2012-01-23

    I have noticed that LOGUT/COMMIt works OK even if I have not added all files to LOGOUT statement.
    Is tis OK or should I add all files anway to LOGOUT statement?
    Thanks

     
  • Andrew Barnham

    Andrew Barnham - 2012-01-23

    You don't need to add any files. LOGOUT applies universally.

    I would expect that original clarion works this way too; has to do with the way SQL does transaction frames.  You could in theory make it so logout does pay attention to list of tables (by maintaining multiple database links, one for operations on tables currently in logout list and one for all the others), but it is alot of work and result is code that less robust. 

    I cannot think of a legitimate use for wanting to provisionally include some tables in list but not others. If one does indeed exist can take another look at this.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.