C
cverbiest
Guest
We had a situation where a client-server user has been working for a couple of hours with an open transaction. After he finished he closed the application and everything was undone. I would like to create a bad behaving procedure that leaves a transaction open while returning control to the caller. This proves to be harder than I imagined, I now have a persistent procedure that creates a record in the main block on a globally scoped buffer but this does not leave a transaction open. I tried creating the record in internal procedures, doing excluive-find in an internal procedure None of these actions leave the transaction op after the call finishes Below is the code I have so far. I would have hoped this was sufficently bad but transaction is false run devtools/transactiontrouble-l.p persistent. run trouble_exclusivefind. message "transaction" transaction. block-level on error undo, throw. define buffer global_CCECONV for CCECONV. run cleanup_previous. session:add-super-procedure(this-procedure). /* self-register as super procedure */ /* find first global_CCECONV /* ensure scope is procedure-wide */ where global_CCECONV.AP-NR = 0 and global_CCECONV.CONV-CODE = this-procedure:file-name share-lock.*/ create global_CCECONV. run trouble_starttransaction. procedure cleanup_previous: define variable lHandle as handle no-undo. define variable lCount as integer no-undo. do lCount = 1 to num-entries(session:super-procedures): lHandle = widget-handle(entry(lCount, session:super-procedures)). if lhandle:filename = this-procedure:filename then do: apply "close" to lHandle. delete procedure lHandle. end. end. end procedure. procedure trouble_exclusivefind: find first global_CCECONV where global_CCECONV.AP-NR = 0 and global_CCECONV.CONV-CODE = this-procedure:file-name exclusive-lock. end procedure. /** * Purpose: Start a transaction and leave it open * Notes: * */ procedure trouble_starttransaction: on write of cceconv old OLD-cceconv override do: end. assign global_CCECONV.AP-NR = 0 global_CCECONV.CMP-ID = next-value(CCECONV-ID) global_CCECONV.CRE-WHO = userid("LISA") global_CCECONV.CRE-DAT = today global_CCECONV.CONV-CODE = this-procedure:file-name global_CCECONV.CONV-CCE-V = ? global_CCECONV.CRE-TIME = time global_CCECONV.CONV-TYPE = "trouble" . end procedure. /** * Purpose: Undo the transaction * Notes: * @param parameter1 Description * @return */ procedure trouble_undotransaction: end procedure. Has somebody created such a procedure that he/she can share ? Any hints on how to cause an open transaction ?
Continue reading...
Continue reading...