Since the database is being accesses from both the web and desktop I assume I'll have to add this setting in both apps (I'm doing it in my code rather than in the dict).
If you use FM3 then there is a spot to stick the driver string in there as the driver string needs to be set on the first table the DB opens. I don't think it needs to be in the desktop app but as I have it set in FM3 I just leave it there.
Just Google Lock_Timeout but basically all it does is release a table if it can't get access within a certain time rather than hanging forever.
So I have something like the following:
DUMMY{Prop:SQL} = 'Set Lock_Timeout 10000' !wait 10 seconds
If Errorcode()
Message('PO Form Set Lock_Timeout 10000 = ' & DUMMY{Prop:SQL})
End
DUMMY{Prop:SQL} = 'Select Count(*) as DUM_Field01 From NOTIFY Where NOTI_UserName = <39>' & Clip(POT:CurrentApproval) & '<39>'
Next(DUMMY)
If Errorcode() = 90 !File is in use so just ignore
Message('PO Browse=' & Clip(POT:CurrentApproval) & clip(errorcode() & ' ' & error()) & ' :: ' & fileerrorcode() & ' ' & clip(fileerror()))
!
Elsif DUM:Field01 = 0 or Errorcode()
! If Errorcode() ~= 10
Message('PO Browse add Notify=' & Clip(POT:CurrentApproval) & clip(errorcode() & ' ' & error()) & ' :: ' & fileerrorcode() & ' ' & clip(fileerror()))
NOTIFY{Prop:Sql} = 'Insert Into Notify ' &|
'(NOTI_UserName,NOTI_Orders,NOTI_UnapprovedOrders,NOTI_Time,NOTI_Date) '&|
'Values (<39>' & Clip(POT:CurrentApproval) & '<39>,1,0,'&|
'<123>ts <39>1900-01-01 ' & Format(Clock(),@T04) & '<39><125>,' &|
'<123>ts <39>' & Format(Today(),@D010-) & ' 00:00:00<39><125>)'
If Errorcode()
! SetClipboard(NOTIFY{Prop:Sql})
Message('a PO Browse add Notify=' & Clip(POT:CurrentApproval) & clip(errorcode() & ' ' & error()) & ' :: ' & fileerrorcode() & ' ' & clip(fileerror()))
End
! End
Else
NOTIFY{Prop:Sql} = 'Update Notify Set ' &|
'NOTI_Orders = NOTI_Orders + 1 ' &|
'Where NOTI_UserName = <39>' & Clip(POT:CurrentApproval) & '<39>'
If Errorcode()
! SetClipboard(NOTIFY{Prop:Sql})
Message('PO Browse update Notify=' & Clip(POT:CurrentApproval) & clip(errorcode() & ' ' & error()) & ' :: ' & fileerrorcode() & ' ' & clip(fileerror()))
End
End
DUMMY{Prop:SQL} = 'Set Lock_Timeout -1' !wait 10 seconds
If Errorcode()
Message('PO Browse Set Lock_Timeout -1 = ' & DUMMY{Prop:SQL})
End
I use CSMessage to log the messages straight to disk.
As for strategic places, I use SQL Enterprise manager to monitor the locks. If you use Prop:SQL then you will see your statement that is hanging. So I modified my code to to do a select count(*) to detect if the table was in use before proceeding (as above). It just then became a process of elimination until I was rid of them all. If you don't use Prop:SQL then it will just show Cursor. I also used debug view to pinpoint some problems.
HTH's
Kevin