Noor Jahan
1st March 2016, 13:03
Hi,

What is the difference in appl.set() application lock on table explicilty and for update on select stmnt.

i need to apply th eapplication lock on table then have to delte the recordes from it.

shall i use appl.set and "for update" together or have to use one only at a time

appl.set("tab_name")
select
selectdo..........
dal.destroy()
endselect
appl.delete("tab_name")

Ajesh
1st March 2016, 13:26
You can just use "for update" and not with appl.set().No need to use appl.set() with "for update".Something like



long ret.val
string messg,e.flag

db.retry.pt()


select tdsls870.*
from tdsls870 for update
where tdsls870._index1 = {:hold.orno}
selectdo
dal.destroy("tdsls870",ttdsls870,ret.val,db.retry,TRUE,e.flag)
endselect
if ret.val = 0 then
commit.transaction()
else
dal.get.error.message(messg)
endif



And as far as i know,appl.set() doesnt work like that. And to lock the table and delete the records, i havent encountered something like that. Maybe it could be possible.

bdittmar
1st March 2016, 15:57
Hello,

appl.set should/can be used, if it is necessary to prevent a session running twice.

appl.set()
Syntax:

function long appl.set (string name(.), long mode)

Description
This creates an application lock for the current application.

Arguments
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 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