Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to synchronize records between two tables
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00946034
Message ID:
00946390
Vues:
19
I have a little more complex system to do that, but it works.
My problem is similar: sync the info between two or more locations. My database has a triggers that writes the modifications on a journal table. That table is sent to the other computer with a mail message automatically generated and the other system reads the mail, extracts the journal table and commint the changes on the local DB.
And it Works.... without IP Address, ftp servers.....

The function that writes the journal is:
FUNCTION JRN
LPARAMETER lcTabla, lnAccion


*** Flag to stop writing
IF VARTYPE(glStopJournal)="L"
IF glStopJournal = .T.
RETURN .T.
ENDIF
ENDIF


IF VARTYPE(Start) <> "O"
RETURN
ENDIF


IF START.configuracion.Journal = .F.
RETURN
ENDIF

LOCAL ARRAY vctTxsData( 1, 1 )
LOCAL lcOldAlias

*** Parameter verification..
IF EMPTY(lcTabla)
RETURN
ENDIF
IF !USED(lcTabla)
RETURN
ENDIF

lcOldAlias = ALIAS()

*** Select the table passed as parameter
SELECT (lcTabla)
lnNumFields = AFIELDS(vctFields, lcTabla)

DIMENSION vctTxsData( lnNumFields ,2 )
FOR I=1 TO lnNumFields
vctTxsData(I,1) = vctFields(I,1)
vctTxsData(I,2) = EVALUATE(vctFields(I,1))
ENDFOR

IF !USED("Journal")
USE Journal IN 0 ALIAS Journal
ENDIF

lcMachineName = ALLTRIM(MachineName())
lcUserName = ALLTRIM(UserName())
INSERT INTO Journal ;
( FechaHora, Machine, User, Tabla, Accion, Pasado ) ;
VALUES ;
( DATETIME(), lcMachineName, lcUserName, lcTabla, lnAccion, .F. )

SELECT Journal
SAVE TO MEMO TxsData ALL LIKE vctTxsData
RELEASE vctTxsData && Libero la memoria.
RELEASE vctFields && Libero mas memoria
*** Selecciono el area antigua, si procede.
IF !EMPTY(lcOldAlias)
SELECT (lcOldAlias)
ENDIF

ENDFUNC
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform