I need help.
which way is better when we save the data on advantage database server 10.1.0.028
- Code: Select all Expand view
// ads without nesting
function save()
use x new share .....
use y new share .....
use z new share .....
Try
AdsBeginTransaction()
select x
if rlock()
replace field1 with 'abc'
endif
replace_y()
select z
if rlock()
replace field with 'fff'
endif
AdsCommitTransaction()
catch
AdsRollback()
end
dbcommitall()
return nil
static function replace_y()
local colddbf :=select()
select y
if rlock()
replace field1 with '123'
endif
dbselectarea(colddbf)
return nil
second way
- Code: Select all Expand view
// second way using nesting
function save()
use x new share .....
use y new share .....
use z new share .....
Try
AdsBeginTransaction()
try
AdsBeginTransaction()
select x
if rlock()
replace field1 with 'abc'
endif
AdsCommitTransaction()
catch
AdsRollback()
end
try
AdsBeginTransaction()
replace_y()
AdsCommitTransaction()
catch
AdsRollback()
end
try
AdsBeginTransaction()
select z
if rlock()
replace field with 'fff'
endif
AdsCommitTransaction()
catch
AdsRollback()
end
AdsCommitTransaction()
catch
AdsRollback()
end
dbcommitall()
return nil
static function replace_y()
local colddbf :=select()
select y
if rlock()
replace field1 with '123'
endif
dbselectarea(colddbf)
return nil
third
- Code: Select all Expand view
// third way using nesting
function save()
use x new share .....
use y new share .....
use z new share .....
Try
AdsBeginTransaction()
try
AdsBeginTransaction()
select x
if rlock()
replace field1 with 'abc'
endif
AdsCommitTransaction()
catch
AdsRollback()
end
replace_y()
try
AdsBeginTransaction()
select z
if rlock()
replace field with 'fff'
endif
AdsCommitTransaction()
catch
AdsRollback()
end
AdsCommitTransaction()
catch
AdsRollback()
end
dbcommitall()
return nil
static function replace_y()
local colddbf :=select()
try
AdsBeginTransaction()
select y
if rlock()
replace field1 with '123'
endif
AdsCommitTransaction()
catch
AdsRollback()
end
dbselectarea(colddbf)
return nil
thanks
kok