Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can SQL and VFP transactions co-exist?
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Can SQL and VFP transactions co-exist?
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01618504
Message ID:
01618504
Vues:
55
When I have 2 or more cursors (CursorAdapter) that need to be updated, and the database can be either VFP or SQL, can the
Transactions co-exist. Mainly I want to be sure that the BEGIN TRANSACTION and END TRANSACTION will not have an adverse affect
when using SQL Server. Here is a simplified case:

The variable lSqlServer is set to .T. for SQL and .F. for VFP
*-- There are two cursors (for the sake of demo) working in this procedure c_table1 and c_table2

*-- This one is for VFP database
BEGIN TRANSACTION

if lSqlServer
   *-- This one is for SQL Server database  
   nRetVal = SQLSETPROP( oApp.conn_handle, "transactions", 2) 
endif 


lok = tableupdate( 0, .T., c_table1 )
if !lOk
	aerror( aErrorInfo )
	*-- store error description is some properties
endif 

if lok
   lok = tableupdate( 0, .T., c_table1 )
   if !lOk
	aerror( aErrorInfo )
	*-- store error description is some properties
   endif 
endif 

*-- Roll back changes if one of the tableupdates fails
if !lOk
   *-- Roll back changes to the cursors
   ROLLBACK
   tablerevert(.T., c_table1 )
   tablerevert(.T., c_table2 )

   if lSqlServer
      *-- Roll back changes to the SQL tables   
      SQLROLLBACK(oApp.conn_handle)
   endif

else
   
   *-- Commit changes for VFP data
   END TRANSACTION

   if lSqlServer
      *-- Commit changes for SQL Server database
      SQLCOMMIT ( oApp.conn_handle )
   endif

endif
Do you see any problem(s) with above code?
"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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform