Chris,
I'm still new to Perl, but here's some code that writes to an Access
database. Maybe it will be a starting point. You will need the
module 'DBD::ODBC', which you can find at search.cpan.org, or, if you have
ppm installed, run ppm and type "install DBD::ODBC".
You will also need to set up an ODBC connection to the Access database. I
did this in Windows. If you're trying to do it on another OS, then I don't
know how that is done. Hope this is helpful.
Shawn
BEGINNING OF CODE
#!/usr/bin/perl
use DBI;
$data_source = "dbi:ODBC:rtsales";
$driver_name = "ODBC";
@driver_names = DBI->available_drivers;
@data_sources = DBI->data_sources($driver_name, \%attr);
$dbh = DBI->connect($data_source, $username, $auth, \%attr);
$log = "db_log.log";
if (@ARGV[0] ne ""){
$log = @ARGV[0];
}
open (LOG, ">>$log");
print LOG "Database write script launched.\n";
@inFile = ("rtstr", "rtslsd", "rtsal", "rtsales", "rtweek", "rtwhist",
"rtrates");
foreach $inFile (@inFile){
open (IN, "<$inFile" . ".csv") || die "Could not open $inFile.\n";
$count = 0;
$errors = 0;
print LOG "\nBeginning insert into table $inFile... \n";
while (){
$_ =~ s/\'/\''/g;
$_ =~ s/\"/\'/g;
#$statement = "insert into rtstr
(regon,name,mangr,store,sname,design,area,smngr,sphon,smgr,sopen,sadd1,sadd2,scity,sstat,szipc)
values ($_)";
$statement = "insert into $inFile values ($_)";
$result = $dbh->do($statement);
if ($result != 1){
print LOG "Result of $statement is: $result.\n";
$errors++;
}
$count++;
break;
}
print LOG "Completed insert of $count records into table $inFile,
$errors errors.\n";
close IN;
}
$statement = "UPDATE RTSAL INNER JOIN RTSALES ON (RTSAL.STORE =
RTSALES.STORE) AND (RTSAL.FISMM = RTSALES.FISMM) AND (RTSAL.FISYY =
RTSALES.FISYY) SET RTSAL.SALESTY = [rtsales].[salesty], RTSAL.SALESBUDTY
= [rtsales].[salesbudty]";
$result = $dbh->do($statement);
print LOG "Result of $statement is: $result.\n";
$dbh->disconnect;
print LOG "Writing rttime.html now.\n";
$result = `rttime.pl`;
print LOG "Launching Epix & AS/400 FTPs now.\n";
$result = `epix_ftp.pl $log`;
END OF CODE
**
This e-mail and any files transmitted with it may contain
confidential information and is intended solely for use by
the individual to whom it is addressed. If you received
this e-mail in error, please notify the sender, do not
disclose its contents to others and delete it from your
system.
**
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]