Have you ever found a need to check the records within two Notes databases (say two versions of your mail file)? The below code will do that and place the differences into a folder called NOTFOUND. You run this code from your source database against the target that you think is missing data. Be sure to set this again to run against all records (i.e. not selected documents).
%REM
Agent CompareMyDocs
Created Nov 10, 2011 by David Scott
Description:
This agent will run from a source db and see if there are matching
records in the destination db. If not, a folder call NOTFOUND will
be populated with these documents.
%END REM
Option Public
Option Declare
Sub Initialize
Dim ses As New NotesSession
Dim srcdb As NotesDatabase
Dim srcnote As NotesDocument
Dim srcview As NotesView
Dim destdb As New NotesDatabase("", "mylocalfile.nsf")
Dim destnote As NotesDocument
Dim destview As NotesView
Dim DocsRead As Integer
Dim DocsNotFound As Integer
Dim key As String
DocsRead = 0
DocsNotFound = 0
Set destview = destdb.GetView("($All)")
Set srcdb = ses.CurrentDatabase 'Run from the source file
Set srcview = srcdb.GetView("($All)")
Set srcnote = srcview.GetFirstDocument
While Not(srcnote Is Nothing)
DocsRead = DocsRead + 1
key = srcnote.UniversalId
Set destnote = Nothing
On Error Resume Next
Set destnote = destdb.GetDocumentByUNID(key$)
If (destnote Is Nothing) Or (destnote.Isdeleted ) Then 'Not found or is a delete stub
Call srcnote.PutInFolder( "NOTFOUND",True )
DocsNotFound = DocsNotFound + 1
Print "No Matching record #" & DocsNotFound & " for UNID " & key$
End If
Set srcnote = srcview.GetNextDocument(srcnote) 'Go to the next document
Wend
MsgBox " Total Documents Read " & DocsRead & " Total Documents Not Found " & DocsNotFound
End Sub
If it's tech related...I'll post it here. Lotus Notes/Domino, AS400 or iSeries, PC's, PDA's, iPods, Android -- Whatever.
Friday, November 11, 2011
Subscribe to:
Post Comments (Atom)
1 comment:
Hi, very nice post
How do could do to compare many databases?
thank you
Post a Comment