Update data with lsx

Hi lsx experts,

I am not really new to this theme, but until now I did use it just as a method to get records from external relational Databases… and did the rest in “normal ls script” :wink:

but now I want to treat the notes data also with LCConnections, to use it as a sort of general data sync pump:

fetch threw the data of table/view 1 in db1 (source),

get the corresponding data set in db2 (target)

update the data set (= notes doc) if sth is different.

I understand that I can update this way:

Dim flSrc As New LCFieldList

Dim flDest As New LCFieldlist

Dim fldEmpNo As LCField

'— … define the field lists somehow …

'— and do the mapping

Call flDest.MapName(flSrc, “EmpNo,Salary”, “EmpID,Pay”)

'— set a key field

Set fldEmpNo = flSrc.Lookup(“EmpNo”)

fldEmpNo.Flags = LCFIELDF_KEY

'— but before updating the flDest like this:

While lcconSrc.Fetch(flSrc)

Call lcconDest.Update(flDest) ‘ keyed update with EmpID as the key

Wend

'— I want to check if the field lists differ in any field values, because I do not want all docs in the target db to be saved each time this agent run.

Is there an “elegant” way to do this (using the lsx classes)?

thanks in advance for any help

Uwe

=======================================

(in my former scripts i do this like:

'— get the searchkey from the LCFieldList

'…

'— and then:

Set dc = view.GetAllDocumentsByKey(searchkey, True)

If dc.count = 0 Then

Set doc = New NotesDocument (db)

'— create new doc and assign values from fieldlist

'…

Elseif dc.count = 1 Then

Set doc = dc.GetFirstDocument

For i = 1 To fldLstRecord.FieldCount

'— fields have the same name, no mapping necessary

EXTvalue = fldLstRecord.GetField(i).text(0)

notesvalue = doc.GetItemValue (fldLstRecord.GetName (i))

If Ucase$(EXTvalue ) <> Ucase$(Cstr (notesvalue(0))) Then

Set item = doc.ReplaceItemValue (fldLstRecord.GetName (i), EXTvalue )

saveflag% = True '— save only (done later) when fields have changed

End If

Next

Else

'— handle case dc.count > 1 somehow

end if

Subject: sync agent using LC LSX

This download contains an agent named “5. Replicate Pirates,” with a reusable replication engine that reads one record at a time from two LC LSX result sets and compares the keys and data values to decide whether or not there’s a difference between the records, synchronizing the data one-way.