Date: Thu, 14 Dec 2000 19:32:09 -0600 (CST) From: Tim Peiffer <peiffer@tim.mutley.mn.org> To: Gleb Shegai <glebo@yahoo.com> Cc: <freebsd-database@FreeBSD.ORG> Subject: Re: Perl <-> Oracle Message-ID: <Pine.BSF.4.30.0012141902010.352-100000@tim.mutley.mn.org> In-Reply-To: <20001214073431.74630.qmail@web10008.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
I believe that one must presuppose that your DBI/DBD installation is correct. Then you need to be able to write to the your DBI API. I think that your key will be setting a database handle that the Oracle database instance was set up. Below is a small snippet that uses DBI to log into an Oracle DB with a handle called 'prod'. Your mileage may vary. This is a working DBI implementation pulling from a Solaris box. Tim Peiffer peiffer@mutley.mn.org use DBI; $host = $ENV{'HOST'}; # Set ORACLE_HOME so it doesn't have to come from the environment. $ENV{'ORACLE_HOME'} = '/usr/local/pkg/oracle'; $handle = 'dbi:Oracle:prod'; $dbh = DBI->connect($handle, "joe", "secret") || die "Unable to connect to database: \"$handle\": $DBI::errstr"; # So we don't have to check every DBI call we set RaiseError. # See the DBI docs now if you're not familiar with RaiseError. $dbh->{RaiseError} = 1; $dbh->{AutoCommit} = 0; $time = time; # current time $query = " select MAC,X500ID from dhcpusers where MAC != '000000000000' and EXPIRETIME > $time "; $sth = $dbh->prepare($query); $sth->execute; while(($mac,$x500id) = $sth->fetchrow_array) { # do something with the data $mac =~ s/(..)/$1:/g; $mac =~ s/:$//; printf DHCP "host %s {\n\thardware ethernet %s;\n}\n", $x500id, $mac; } $sth->finish; $dbh->disconnect; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-database" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.30.0012141902010.352-100000>