Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a new order on two PCs
Message
 
 
À
13/07/2016 15:03:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01638327
Message ID:
01638345
Vues:
58
>>>>Hi,
>>>>
>>>>I have a situation where one customer is experiencing the following: two users (on different PCs) create a new order and if they do it pretty much at the same time, the second one overwrites the first. The DB is SQL Server. The method of updating the DB is CursorAdapter.
>>>>
>>>>Here is the segment of the code dealing with creating new order:
>>>>
>>>>
>>>>INSERT INTO V_ORDERS ( STATUS, DATE_OPEN,  OPEN_TIME, USER_NAME, USER_ID, INSP_PASS, SITE_NO ) VALUES ;
>>>>				('O', DATE(), time(), oPassword.UserName(), oPassword.User_Password_Id(), NULL, this.site_no )
>>>>
>>>>	IF !TABLEUPDATE(0,.T., "V_ORDERS" )
>>>>		AERROR(aErrorInfo)
>>>>		this.error_message_text = aErrorInfo[1,2]
>>>>		this.error_number = aErrorInfo[1,1]
>>>>		this.error_message_title = "Failed TABLEUPDATE() of V_ORDERS"	
>>>>		RETURN .F.
>>>>	ENDIF
>>>>
>>>>
>>>>The error (which is logged) does not seem to fire. But is it possible that the TABLEUPDATE() takes "time" (a second or two or more) to actually update the SQL Server. And therefore, the second user's TABLEUPDATE() overwrites the first one? If this is the case, how do I "force" the tableupdate to be faster? Or any other suggestions to deal with this situation?
>>>>
>>>
>>>Is there an Insert trigger on the SQL Server table? If so, what does it do?
>>>
>>>Tamar
>>
>>No, there is no insert trigger on this table. Why would it be necessary?
>
>from the code shown it is unclear how PK is defined/handled. Unless there is code in the CA single methods, 2 insert calls should hit the server. "Pure" inserts should never block/overwrite by definition. Any parent/child rule firing in your scenario ? How is conflict resolution set ? Why 2. parameter set to force ? (Might influence error handling when "forcing", never went into that detail...)

When Insert is executed via Cursor Adapter, the PK (being an Identity column) is created by SQL Server. No work is necessary on the VFP side. As I just mentioned to Naomi, no other customer ever reported this type of issue. So this is why I think that I need to do something about this tableupdate(). Force it to execute immediately (but how?). Basically in "logical" terms, I need to "lock" this table in the SQL server until Tableupdate() executes and a PK is created. Therefore, the other user will get a different PK. I am thinking about creating a semaphore file that will allow the first tableupdate() to do its job and then proceed to the next one.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform