General information
Category:
Coding, syntax & commands
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
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only