RE: Looking for some Documentation

2002-10-23 Thread shawn_milochik

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]




RE: Looking for some Documentation

2002-10-23 Thread Beau E. Cox
I have used ODBC against Acess 97 with no major problems.
That might be easier than OLE because you can manipulate
the data with plain ol DBI (just don't do anything
fancy).

Aloha => Beau.

-Original Message-
From: Chris Benco [mailto:Chris.Benco@;austinpowder.com]
Sent: Wednesday, October 23, 2002 7:07 AM
To: [EMAIL PROTECTED]
Subject: Looking for some Documentation


Trying to get a script to read information from an old access 97 database.
Just looking for a place to start.  Is this going to be a DBI/ODBC issue?
or OLE?  Just looking for a point in the right direction.

Chris Benco
[EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Looking for some Documentation

2002-10-23 Thread Hanson, Rob
> Is this going to be a DBI/ODBC issue?
> or OLE?

Either one.

There is also another way, OLE/ADO if you are familiar with ADO.  My
preference would be to stay away from the straight OLE approach unless you
are already familiar with the fairly complex Access API.  ...On the other
hand the OLE only approach lets you do anything that you can do in access,
so it is a lot more powerful than the DBI or ADO approach (at the cost of
complexity).

Rob

-Original Message-
From: Chris Benco [mailto:Chris.Benco@;austinpowder.com]
Sent: Wednesday, October 23, 2002 1:07 PM
To: [EMAIL PROTECTED]
Subject: Looking for some Documentation


Trying to get a script to read information from an old access 97 database.
Just looking for a place to start.  Is this going to be a DBI/ODBC issue?
or OLE?  Just looking for a point in the right direction.

Chris Benco
[EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Looking for some Documentation

2002-10-23 Thread Chris Benco
Trying to get a script to read information from an old access 97 database.
Just looking for a place to start.  Is this going to be a DBI/ODBC issue?
or OLE?  Just looking for a point in the right direction.

Chris Benco
[EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]