ee05220
23rd December 2022, 12:05
Hi,
I am try to create a session with a new table. I would like to create an application lock, but it seems it's just work for standard tables.
If I use a standard table the lock is shown on session "ttadv9598m000" but when use a new table (created table) I don't have any lock.
Anyone could confirm this?
Regards.
RieseUSA
24th December 2022, 04:44
Hi ee05220,
I am wondering if there is a misunderstanding about how application locks work and what they are used for.
Application locks require programming logic to be set and removed. They get removed when the process ends normally, but a good programmer handles the removal.
An application lock can be used to identify access restrictions to a table, but you can create an application lock with identifier 'ee05220', check if it is set, and control anything with it.
Application locks are not database table locks. They are used to control that processes do not interfere, e.g., there should only be one process updating a specific sales order at a time.
Based on this, your newly created session could set and check an application lock for any identifier, a standard table code, a custom table code, the custom session code, or something else, but you need the programming code for it.
Yours,
Stephan
bdittmar
24th December 2022, 11:30
Hello,
as Stephan says,
Application locks: overview
Use these functions to handle application locks for 4GL processes.
You use application locks to prevent other applications and users from reading and/or
modifying an application's data during critical operations. For example, to prevent
access to data when it is being updated.
You can set an application lock only for the current 4GL process. You can test for or delete an application lock only within the application to which it applies.
Application lock features
Each application lock has an owner, which is automatically assigned. The owner consists of a combination of the login ID of the application user, and the process ID of the application.
Each application lock has a unique name, which you define when you create the lock.
An application lock is automatically removed when the application ends. You can also remove it with the appl.delete() function.
An application lock applies only to an application and that application's data. It is not part of the RDBMS and is not linked to a table or a particular database transaction. To set table locks, use db.lock.table().
Application lock types
There are three main types of application locks:
Read locks When you set a read lock, the owner of that lock has only read access to the application's data. Other applications can read and modify the data. Other users of the application can set read and write locks on it. But they cannot set an exclusive application lock.Each application can have several read-type application locks.
Write locks When you set a write lock, the owner of that lock has both read and write access to the application's data. Other applications can read the data but not modify it. Other users of the application can set read locks on it, but not a write lock or an exclusive lock.Each application can have only one write-type application lock. So you cannot set this type of lock when there is a write-type or exclusive-type lock already present.
Exclusive locks When you set an exclusive lock, the owner of that lock has exclusive access to the application's data. Other applications and users can neither read nor modify the data, nor can they set any application locks on it.You can set an exclusive lock only when there are no other locks (of any type) already present.
There is one additional lock type, which you can combine with any of the other types:
Application-wide locks Normally, an application lock is set for the current company only. By using this additional lock mode, you can apply the lock globally to all companies. This means that the application lock is valid in all companies.
Application locks
An Application locks: overview prevents other applications and users from reading and/or modifying an application's data during critical operations. It is not part of a transaction and so is not automatically removed when a transaction is committed. Instead, an application lock is removed when the application ends or when appl.delete() is called.
appl.xxxxx() functionality must be used.
e.g.
appl.set()
Syntax:
function long appl.set (const string name, long mode)
Description
This creates an application lock for the current application.
Arguments
const string name The name of the application lock. This must be unique.
long mode The type of application lock to set:
APPL.READ
APPL.WRITE
APPL.EXCL
APPL.WIDE
You can combine APPL.WIDE with any one of the other lock types.
Return values
0 success
-1 application-wide lock present
-3 internal error
>0 application lock already present; mode is returned
Context
This function is implemented in the 4GL Engine and can be used in all script types.
Examples
This example sets a write-type application lock for all companies. Only the owner can modify the application's data in all companies.
appl.set("00112334455", APPL.WRITE + APPL.WIDE)
This example sets an exclusive-type application lock on a production order and subsequently deletes it.
if appl.set( "tisfc001" & tisfc001.pdno, APPL.EXCL ) > 0 then
| Lock is already present, give message
return
endif
...
appl.delete( "tisfc001" & tisfc001.pdno )
Regards
ee05220
26th December 2022, 11:01
Hi,
thanks for your all answers. What I am try to say, some appplications locks are shown is session ttadv9598m000 and others don't.
As I said if I create an application lock with "ee05220" it doesn't shows on table ttadv998, but when I use a string "tisfc001" or some string started with "t..." we can see on table ttadv998.
It is very strange.
Regards.