Contacts are coming from a file called
‘VMTEL.TXT’. This file is updated every day. Therefore
this script will run every day. This script will result in two
files. One file (‘update.txt’) will update existing
users. A second file will import new users into
USD.
This script are adapted once moved over to server
‘Lofty’.
Used script file:
# Created by Wim Van der Planken
(Synstar CS)
# Modified by Daniel Paessens (Synstar CoE CS)
# Version 0.1
#use strict;
use DBI;
my $insertfile = "insert.txt";
my $updatefile = "update.txt";
my $dbh =
DBI->connect("dbi:Oracle:paradigm","paradigm","Passw0rd") ||
die("Can't connect to Oracle database: $DBI::errstr");
open(FILE,"VMTEL.TXT") || die("Can't open VMTEL.TXT: $!");
open(INFILE,">$insertfile") || die("Can't open $insertfile:
$!");
open(UPFILE,">$updatefile") || die("Can't open $updatefile:
$!");
print UPFILE "TABLE Contact\n\tid c_public_phone c_userid
c_contact_num c_dept c_expense c_last_name c_first_name
c_e-mail_addr\n";
print INFILE "TABLE Contact\n\tc_public_phone c_userid
c_contact_num c_dept c_expense c_last_name c_first_name
c_ctp_id c_e-mail_addr\n";
foreach(readline(FILE))
{
chomp;
my $first =
substr($_,0,4);$first =~ s/\s+$//;
my $second =
substr($_,5,8);$second =~ s/\s+$//;
my $third =
substr($_,14,4);$third =~ s/\s+$//;
my $fourth =
substr($_,19,3);$fourth =~ s/\s+$//;
my $fifth =
substr($_,23,4);$fifth =~ s/\s+$//;
my $sixth =
substr($_,28,20);$sixth =~ s/\s+$//;
my $seventh =
substr($_,48);
if($seventh =~
/^\)/)
{
$sixth
.= ')';
$seventh
= substr($seventh,1);
}
my $sth =
$dbh->prepare("select id from paradigm.ctct where c_userid =
'$second'") ||die("Can't prepare SQL statement:
$DBI::errstr");
$sth->execute ||
die("Can't execute SQL statement: $DBI::errstr");
my $id =
$sth->fetchrow_array();
if($id)
{
print
UPFILE "\t{ \"$id\", \"$first\", \"$second\", \"$third\",
\"$fourth\", \"$fifth\", \"$sixth\", \"$seventh\",
\"$second\@bei.org\" }\n";
}
else
{
print
INFILE "\t{ \"$first\", \"$second\", \"$third\", \"$fourth\",
\"$fifth\", \"$sixth\", \"$seventh\", \"2305\",
\"$second\@bei.org\" }\n";
}
}
close(FILE);
close(INFILE);
close(UPFILE);
$dbh->disconnect() || die("Error disconnecting:
$DBI::errstr");
For importing the follow command lines are
used:
Pdm_userload –f c:\temp\update.txt
(ÞHas been removed on
request)
Pdm_load –I –f c:\temp\insert.txt