ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Transactions? COMMIT/ROLLBACK?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transactions? COMMIT/ROLLBACK?

    Hi guys,

    I have a journaled file that I am working with.

    I want to learn/test out how to use SQL Transactions.

    I delete a single row from a table and then issue the ROLLBACK command on ACS Run SQL Scripts.

    I would expect that after I issue the ROLLBACK command the previous delete statement would be undone.. but to my surprise the record is still gone!

    What am I doing wrong, what should I better understand?

    Thank you.

  • #2
    My guess is that you have the isolation level of the JDBC connection set to "No commit". Try "Cursor stability".

    Comment


    • #3
      You're right

      This thread had some information on it from a Mr. Elvis Budimlic

      RE: Rollback Delete Query in STRSQL ? -- Probably the easiest thing to do for interactive SQL is: 1) start journaling all the files you care about, i.e. STRJRNPF FILE(myLib/myFile) JRN(myLib/myJournal) IMAGES(*BOTH) 2) change your interactive session attributes to always run under commitment cont...



      1) start journaling all the files you care about, i.e. STRJRNPF FILE(myLib/myFile) JRN(myLib/myJournal) IMAGES(*BOTH) 2) change your interactive session attributes to always run under commitment control STRSQL F13 1 change Commitment Control to *ALL >From this point on, you'll always be able to simply type ROLLBACK on your interactive session to rollback all the changes you've made in that session. Or if you want to keep changes without rolling them back (i.e. they're 'good' changes), you can and should type COMMIT instead. Note that you can't rollback commited changes. If you use neither COMMIT or ROLLBACK and end your job, rollback will take place implicitly. So make sure you use COMMIT if you want to keep any updates, inserts or deletes! You can start commitment control in other ways. There is a CL command, i.e.: STRCMTCTL LCKLVL(*ALL) CMTSCOPE(*JOB) And you could use SQL command in the interactive session itself, i.e.: SET TRANSACTION ISOLATION LEVEL ALL Key is that you're already journaling before and after images, so commitment control is able to function properly.

      Comment

      Working...
      X