Back to articles
SQL Assertions, ANSI join, and ORA-08697
How-ToSystems

SQL Assertions, ANSI join, and ORA-08697

via Dev.toFranck Pachot

In the previous post on consistency boundaries, we saw that an updatable join view can hide a write-skew anomaly when the developer assumes the consistency boundary is a single row, even though there are actually two underlying rows and only one is locked. I wanted to see how the new SQL Assertions introduced in "Oracle AI Database 26ai Release 23.26.1.0.0" handle this, since they use a different locking mechanism. TL;DR: they handle it correctly, but without ANSI joins. Without assertions, for an employee with a salary of 1000 and a commission of 100, two concurrent users could each add 42 to both values because they couldn’t see each other’s changes, and updating one column didn’t lock the other. I then added a SQL assertion that doesn’t allow the commission to exceed 1150, so that only one session can add 42. This assertion works as expected, waiting on the other transaction before checking the sum: CREATE ASSERTION salary_plus_commission_le_1150 CHECK ( NOT EXISTS ( SELECT 'violati

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles