Revision 24319,
953 bytes
checked in by broder, 14 years ago
(diff) |
New Moira snapshot from SVN.
|
-
Property svn:executable set to
*
|
Rev | Line | |
---|
[24250] | 1 | #!/moira/bin/perl -Tw |
---|
[23095] | 2 | # |
---|
[24319] | 3 | # $Id: warehouse.gen 3956 2010-01-05 20:56:56Z zacheiss $ |
---|
[23095] | 4 | # Generate a database extract from the users table for the MIT Data Warehouse. |
---|
| 5 | $MR_DBMS_ERR = 47836421; |
---|
| 6 | $MR_OCONFIG = 47836460; |
---|
| 7 | |
---|
| 8 | $outfile = '/moira/dcm/warehouse.out'; |
---|
| 9 | |
---|
| 10 | use DBI; |
---|
| 11 | |
---|
| 12 | $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") || exit $MR_DBMS_ERR; |
---|
| 13 | |
---|
| 14 | $sth = $dbh->prepare("SELECT login, clearid, first, last, middle " . |
---|
| 15 | "FROM users WHERE (status = 1 OR status = 2 OR " . |
---|
| 16 | "status = 5 OR status = 6 OR status = 7 OR status = 9)"); |
---|
| 17 | |
---|
| 18 | $sth->execute || exit $MR_DBMS_ERR; |
---|
| 19 | |
---|
| 20 | umask 022; |
---|
| 21 | open(OUT, ">$outfile") || exit $MR_OCONFIG; |
---|
| 22 | |
---|
| 23 | while (($login, $clearid, $first, $last, $middle) = $sth->fetchrow_array) { |
---|
| 24 | next if (length($clearid) < 2); |
---|
| 25 | next if ($clearid eq "0" || $clearid eq "\0" || $clearid =~ /^.\D/); |
---|
| 26 | $row = "$login\t$clearid\t$first\t$last\t$middle\n"; |
---|
| 27 | $row =~ s/\0//g; |
---|
| 28 | print OUT $row; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | close(OUT); |
---|
| 32 | $dbh->disconnect; |
---|
| 33 | |
---|
| 34 | exit 0; |
---|
Note: See
TracBrowser
for help on using the repository browser.