runrig has asked for the wisdom of the Perl Monks concerning the following question:

I posted Lotus Notes documents by Date keys a while ago, and the date keys worked, and the date ranges seemed to work, but later I found that the ranges worked only if all of the documents were from one particular date. If the date range spanned two or more groups of documents, only documents from one particular date were returned. Can anyone confirm or deny whether date ranges in Lotus Notes (from perl) work? Here is some code, the database/view/field names and the date range would have to be adjusted as appropriate:
use strict; use warnings; use Win32::OLE; my $Notes = Win32::OLE->new('Notes.NotesSession') or die "Cannot start Lotus Notes Session object.\n"; my $Database = $Notes->GetDatabase('server', 'dbfile.nsf'); my $View = $Database->GetView("By Start Date"); my $date_range = "03/01/07 - 03/31/07"; my $DateRange = $Notes->CreateDateRange(); $DateRange->{Text} = $date_range; my $Entries = $View->GetAllEntriesByKey($DateRange); my $Entry = $Entries->GetFirstEntry(); while ($Entry) { my $doc = $Entry->Document(); my $subj = $doc->GetFirstItem('Subject')->{Text}; print "Subject: $subject\n"; $Entry = $Entries->GetNextEntry($Entry); }

Replies are listed 'Best First'.
Re: Lotus Notes date ranges not returning all documents
by CountZero (Bishop) on Feb 23, 2009 at 22:21 UTC
    I tried accessing Lotus Notes by Win32::OLE but gave up on it, mainly because of the lack of documentation. Now I access the Lotus Notes e-mail database through the ODBC connector and then I can use DBI and query my e-mails with standard SQL. No need to learn all the methods of the API of Lotus Notes.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      Documentation was a problem for me too until I found it on the IBM site, e.g., the LotusScript COM/OLE Classes PDFs here and here (I just googled. The properties and classes in VB map easily to Perl with properties being hashrefs (->{Property}) and the methods being called just like perl methods. I haven't tried the Lotus ODBC driver and I'm not even sure if I have it or if it's even available and I just have to install it or what...I'll have to investigate and report back.
        Thanks for the links.

        Having looked at them I now remember why I gave up on OLE: reading a few thousand pages of docs for a small script was not really worth the effort then.

        If you are interested to have a look at the ODBC connector, called "NotesSQL": you can find it here.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James