I have started using the merge statement more and have been reading on the locks it creates. My program is set to no commit control yet locks remain long after the user is done with the record and inevitably someone gets a record in use error and then a 21506 error on the merge statement. Below is the code. I am able to at least ignore the locks using "With Cs Skip Locked Data" but I don't know why the locks remain in the first place.
Code:
Exec Sql
Set Option Commit = *None;
Exec Sql
Merge Into Ordduef01 Target Using(Values(:Company,
:Order#, :Shipto#))
As Source (Odcomp,Odorder#,Odshipto#) On (Source.Odcomp =
Target.Odcomp And Source.Odorder# = Target.Odorder# And
Source.Odshipto# = Target.Odshipto#) When Matched Then
Update
Set Oddue = :Duedatetime,
Odlob = :Orderinfo.Lineofbusiness,
Odshipvia = :Orderinfo.Shipvia,
Odpriority = :Orderinfo.Priority
When Not Matched Then Insert(Odcomp, Odorder#, Odshipto#,
Oddue, Odlob, Odshipvia, Odpriority) Values(:Company,
:Order#,
:Shipto#,
:Duedatetime,
:Orderinfo.Lineofbusiness,
:Orderinfo.Shipvia,
:Orderinfo.Priority)
With Cs Skip Locked Data;

