on 10-12-2023 8:48 AM
Hello All,
How can we effectively manage record locking in SAP CAP when multiple users are selecting the same rows for operations, ensuring that only one user can update the rows while others receive an error?
On a DB level we support shared locks: https://cap.cloud.sap/docs/node.js/cds-ql#forsharelock
On a logical/UI level, users normally work with draft-flows when data is edited. Here, you can rely on draft-locks: https://cap.cloud.sap/docs/node.js/fiori#draft-locks
I hope this answers your question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No running sample but you can see how it's used in our release notes: https://cap.cloud.sap/docs/releases/archive/2022/jun22#shared-locks
So, if you have a CQL statement in a custom handler (e.g. a On handler) you can just append forShareLock() to the statement and you're good to go. 🙂
In case you're running locally on SQLite this statement might either produce an error or does not have an effect at all. I just checked: SQLite does not support "SELECT FOR UPDATE" https://www.sqlite.org/lang_select.html. So, this would only work on SAP HANA or PostgreSQL.
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.