lock a DB access

lock a DB access

  

Is it possible to lock DB accesses whenever a new entity is being created?

I need this because I have a screen with a button that, when pressed, creates a new entity in the DB. However, it should only work while there isn't anything else being created in the DB.

Hi Ricardo,

You can create another Entity call it DbLock (for instance) and a dummy record ... just for locking purposes and everytime you create need to create a new record of your entity ... first you do a get of the DbLock dummy record. Got it?

That consumes 1 additional AO. Is there any other better way?

Well, locking the DB is something that happens at the database server level, not the OutSystems Platform Server lever, so maybe you can have a stored procedure that locks the DB that you can call before creating the entity.


Why is there GetEntityForUpdate then? 

Gadar S wrote:

Why is there GetEntityForUpdate then? 


That action locks one record for editing, not the entire DB, which, as I understand it, is what the OP wants.

Note the original post is over a year old, Gadar necroed it with his AO question. Let's leave this topic to rest, people.

Kilian Hekhuis wrote:

Note the original post is over a year old, Gadar necroed it with his AO question. Let's leave this topic to rest, people.

Whether or not I create a new thread or use existing post to continue a discussion does not really matter to me. I am trying to find the best way to see how unique records can be created in OutSystems. The other approach I can think of is using UniqueIndex and try to catch for exception. Is there any other approach?