[1962] in Moira
Re: calendar.gen
daemon@ATHENA.MIT.EDU (Mark Silis)
Thu May 16 00:48:33 2002
Date: Thu, 16 May 2002 00:48:32 -0400
From: Mark Silis <mark@MIT.EDU>
To: Garry Zacheiss <zacheiss@MIT.EDU>
Cc: Mark Silis <mark@MIT.EDU>, Jonathon Weiss <jweiss@MIT.EDU>,
moiradev@MIT.EDU
Message-ID: <20020516044832.GB24226@I-fear-reorgs.MIT.EDU>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200205160444.AAA03563@riff-raff.mit.edu>
Oh good catch on unique, thanks. Here you go.
-- Mark
#!/moira/bin/perl -Tw
# $Id$
# The following exit codes are defined and MUST BE CONSISTENT withh the
# error codes the library uses:
$MR_DBMS_ERR = 47836421;
$MR_OCONFIG = 47836460;
$outfile = '/moira/dcm/calendar.out';
use DBI;
$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
|| exit $MR_DBMS_ERR;
$sth = $dbh->prepare("SELECT UNIQUE u.clearid, u.login, u.first, u.middle, " .
"u.last FROM users u, list l, imembers i " .
"WHERE l.name = 'calendar-acl' " .
"AND l.list_id = i.list_id AND l.list_id = i.list_id " .
"AND i.member_type='USER' AND i.member_id = u.users_id")
|| exit $MR_DBMS_ERR;
$sth->execute || exit $MR_DBMS_ERR;
umask 022;
open(OUT, ">$outfile") || exit $MR_OCONFIG;
while (($clearid, $login, $first, $middle, $last) = $sth->fetchrow_array) {
$row = "$clearid^UID=$login/S=$last/G=$first/I=$middle/";
$row .= "EMAIL=$login\@mit.edu\n";
$row =~ s/\0//g;
print OUT $row;
}
close OUT;
exit 0;
On Thu, May 16, 2002 at 12:44:51AM -0400, Garry Zacheiss wrote:
> This looks better.
>
> >> +$sth = $dbh->prepare("SELECT u.clearid, u.login, u.first, u.middle, u.last " .
> >> + "FROM users u, list l, imembers i " .
> >> + "WHERE l.name = 'calendar-acl' " .
> >> + "AND l.list_id = i.list_id AND l.list_id = i.list_id " .
> >> + "AND i.member_type='USER' AND i.member_id = u.users_id")
> >> + || exit $MR_DBMS_ERR;
> >> +$sth->execute || exit $MR_DBMS_ERR;
>
> You might want this to be a SELECT UNIQUE, since you're not checking
> the direct column in the imembers table. As things stand now, if you
> had a user directly on calendar-acl and also indirectly a member (by
> being on a list that's on calendar-acl), you'd get two rows returned
> from your select for that user, which might be a problem for your
> application.
>
> Garry
>