Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multiuser file access
Message
De
06/12/2013 11:14:27
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
06/12/2013 10:09:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Web
Divers
Thread ID:
01589362
Message ID:
01589460
Vues:
49
>>>Hi All:
>>>
>>>Every time I run a transaction, my program either APPENDs BLANK to a log table, or updates an existing record in the log table.
>>>
>>>What is the best resource to consult with regard to doing this in a multiuser environment?
>>>
>>>Thanks,
>>>
>>>Yossi
>>
>>Don't use Append Blank, use Insert Into instead, this is especially important in a multiuser environment. And in general you should never update a record in a log table, you should only add new records.
>
>Are you saying that with INSERT INTO, I don't need flock()?
>I guess that 'Log file' is inaccurate. It's a list of emails that have a lSent field. If the previous attempt was unsuccessful and it is successful now, I want to update the lSent to .t.
>
>
>PROCEDURE UpdateEmailLog(tcText, tcCustno, tcDisposition)
>

Hi Yossi

Your code does not do anything with updating the lSent field. If the log is being updated to change the lSent, you need some means of locating the correct log record to update it.

The equivalent code to what you posted done without append blank + replace follows. Those two commands update the indexes as well as the dbf twice (once per command). A single insert into command updates the indexes and the dbf once only and does it without your having to remember and reset the workarea etc. I use TRY/CATCH error handling in such cases. 

<pre>
UpdateEmailLog.PRG
LPARAMETERS (tcText, tcCustno, tcDisposition)

LOCAL llUpdated
llUpdated = .F.

DO WHILE !m.llUpdated
	TRY
		INSERT INTO emails (em_body,em_datetim,em_custno,em_disptn) ;
			VALUES (m.tcText,DATETIME(),m.tcCustno,m.tcDisposition)
		llUpdated = .t.
	CATCH TO loErr
		SET STEP ON
	ENDTRY
ENDDO
RETURN m.llUpdated
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform