>>AFAIK Insert command locks the table header, thus the Error you're getting.
>
>I thought something along this line.... when I read from the INSERT - SQL help info...
>"If the table you specify isn't open, it is opened exclusively in a new work area and the new record is appended to the table. The new work area isn't selected; the current work area remains selected.
>
>If the table you specify is open, INSERT appends the new record to the table. If the table is open in a work area other than the current work area, it isn't selected after the record is appended; the current work area remains selected."
>
>Does the "append" do a momentary lock on the table for the append? If so, then the simultaneous attempts by the 2 batch files would cause the problem....sigh....
>
>>>You may surround your insert with explicit flock() or try to use this table in buffering mode and then tableupdate. I think, the first method would be better.
>
>Yeah, I think so too...
>
>So I need to add to the AUDITBAT code the following?....
>
>SET REPROCESS TO 10 SECONDS (set locking attemt to 10 seconds)
>
>Then
>
>IF FLOCK('auditbat')
>
>>
>>>The Error : "File is in Use by Another User"
>>>
You could do that, but if you do, I would put a timer in it manually. Such as:
SELECT auditbat
WAIT WINDOW "Updating..." NOWAIT
LOCAL mtimes
mtimes=0
DO WHILE !FLOCK().and.mtimes<1000000
?FLOCK()
mtimes=mtimes+1
enddo
IF UPPER(ALLTRIM(psStatus)) = 'START'
INSERT INTO auditbat (progname, startdate, starttime) ;
VALUES (psProgName, pdStartDate, psStartTime)
ELSE
IF UPPER(ALLTRIM(psStatus)) = 'END'
UPDATE auditbat SET EndDate = DATE(), EndTime = TIME() ;
WHERE Progname = psProgName AND StartDate = pdStartDate AND StartTime = psStartTime
ENDIF
ENDIF
UNLOCK IN auditbat
WAIT CLEAR
How long does it typically take to run that process? Have you tested update times?
Or you could do conditional searches for your records that match your condition and update each record accordingly. That's the approach I usually take and I lock the record before I update it and unlock it again. These are the solutions I've used ONLY when I cannot use buffering for whatever reason.
Tracy
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"