Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Perl with an Access Database

Status
Not open for further replies.

peterv6

Programmer
Sep 10, 2005
70
US
I'm trying to figure out how to use Perl to manipulate (read, update, add, delete, etc.) records in an Access 2000 or 2003 database. I've looked up the DBI package, but it's a little confusing, as I'm quite new to this. What I'm looking for is a simple example of a Perl script that uses DBI to use as a kind of guide. Does anyone know where I might be able to find something like this?
Thanks....

PETERV
Syracuse, NY &
Boston, MA
 
Your kind of asking a very general statement..
in it's simplest

$data_source will be you db.. like DBD::pg for postgres or DBD::eek:racle for oracle, and if your not local usual contains a host statement and maybe a port statement like DBD::pg;host=yourdbserver;port=1234

$username = well I'm sure you know this one
$pass = password

$statement can be any SQL statement you want..
$statement = "drop table x"
$statement = "select id,firstname,last from userlist"

@row_ary will contain your data if there something returned..

This doesn't really show you how to read data back out..
use DBI;
$dbh = DBI->connect($data_source, $username, $pass);
$sth = $dbh->prepare($statement);
$sth->execute;
@row_ary = $sth->fetchrow_array;
$dbh->disconnect;
 
oops.. I added reading.. so ignore that "This doesn't really show you how to read data back out.." statement.. how come we don't have a edit button here anyway?
 
I know it's a general question, that was the intent. The information you provided is helpful. You mentioned postgres & oracle databases, but I need to know if this can be done for ACCESS databases, and if so, how to connect to one.

PETERV
Syracuse, NY &
Boston, MA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top