Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transactions and Remote Views questions
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00662113
Message ID:
00662212
Vues:
21
Hi Andreas,

Setting Manual transactions on the connection and sending SQLCOMMIT() or SQLROLLBACK() did the trick when using VFP or SQLServer backend. I will have to set up an Oracle database to test that one.

My test program:
*!* memvars should be defined to create records in both remote views
*!* both remote views share the same connection
m.fldmon2id = 0
*!* uncomment release to cause invalid primary key error on update of second RV
*!* to test rollback or run twice.  First should commit, Second should rollback
**release m.fldmon2id  
close tables
use v_fldmon1
=cursorsetprop("buffering",5,"v_fldmon1")
select 0
use v_fldmon2
=cursorsetprop("buffering",5,"v_fldmon2")
select v_fldmon1
append blank
gather memvar
select v_fldmon2
append blank
gather memvar
*!* set connection for manual transactions
=SQLSETPROP(CURSORGETPROP("ConnectHandle","V_FLDMON1"),"Transactions",2)
BEGIN TRANSACTION
if  tableupdate(1,.t.,"v_fldmon1") .and. tableupdate(1,.t.,"v_fldmon2")
   =SQLCOMMIT(CURSORGETPROP("ConnectHandle","V_FLDMON1"))
   END TRANSACTION
   =messagebox("committed")
else
   =SQLROLLBACK(CURSORGETPROP("ConnectHandle","V_FLDMON1")) 
   ROLLBACK
   =messagebox("rolled back")
   =tablerevert(.t.,"v_fldmon1")
   =tablerevert(.t.,"v_fldmon2")  
endif 
*!* remote views properly committed or rolled back
select v_fldmon1
browse 
select v_fldmon2
browse 
*!* reset to automatic transactions
=SQLSETPROP(CURSORGETPROP("ConnectHandle","V_FLDMON1"),"Transactions",1)
=requery("v_fldmon1")
=requery("v_fldmon2")
*!* Underlying tables properly committed or rolled back
select v_fldmon1
browse 
select v_fldmon2
browse
This code appears to do what I want but I'm not sure exactly why. Does it look right?

Thanks for your help.

Elmer
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform