Just a quick gotcha that often catches me out on LiveSQL, so posting it here to make sure you also don’t get caught out.

(Quick Segue: If you’ve only used LiveSQL in the past, be sure to check it out again – it has been totally re-jigged give a much more modern experience.)

LiveSQL allows you to model how real world applications work nowadays, namely, 99.9% of the worlds applications work via a browser to a middle tier in a stateless fashion.

Each interaction with the database is essentially

  • Connect to the database (in reality, you are given a pre-existing connection from a pool, but from the application’s perspective, it is like a brand new connection)
  • You do some work
  • You give back the connection

This means that any transaction you initiated will end once you give back that connection. (I’m skipping over a super cool new 23ai feature called session-less transactions, but I’ll save that for a future post).

Bringing this back to LiveSQL, this mean that running a script with (say) 4 statements, is different to running each of the statements in sequence, because a script is a single interaction with the database, whereas running 4 statements will be four separate interactions with the database.

This has implications when it comes to transactions, because transactions end with each interaction. For example, here are 5 statements that I ran as a script.

Screenshot 2025-07-31 135155

This is a single interaction with the database, so the “rollback” command is within the same transaction/context of the session that did the INSERT statement.  Hence, my table is empty at the end of the interaction.

Here’s the same statements run sequentially using the “Run Statement” button.

livesql_next

Notice the difference. When I ran the INSERT statement and returned back to LiveSQL, that transaction is completed and hence the row is committed.

The “rollback” statement is executed in a new session, and thus has no impact on the previously inserted (and committed) row.

It’s nice to have both “modes” available to you, but if you’re debugging an issue with a script, be aware that you’ll need to probably debug it in the context of script execution, not with the individual statements.

One response to “Transactions on LiveSQL”

  1. iudithd5bf8e4d8d Avatar
    iudithd5bf8e4d8d

    Hi Connor,

    Just because your examples show the V2 version of LiveSQL, I would just like to ask whether do you know
    whether reported bugs/issues in V2 are currently attended by anybody.

    I ask because I tried to use feedback to report a really trivial bug that I discovered (in V2 only !), and I was directed to a Forum page,
    instead of the usual APEX Feedback page that I used many times with the old LiveSQL version.

    I posted the problem there about a month ago, but now I see that the problem still exists.

    I should mention once again that, while using the old LiveSQL version, all the many feedbacks that I sent along the years
    were always attended promptly, excellently and followed after until a solution.
    It would be a pity if that good habit will be dropped for V2 😦 …

    So, if you do have any influence on the matter, I would be grateful for your help.

    Cheers & Best Regards,
    Iudith Mentzel

Got some thoughts? Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trending