From owner-freebsd-database Fri Dec 15 9:10:37 2000 From owner-freebsd-database@FreeBSD.ORG Fri Dec 15 09:10:33 2000 Return-Path: Delivered-To: freebsd-database@freebsd.org Received: from ann.skypoint.net (ann.skypoint.net [199.86.32.19]) by hub.freebsd.org (Postfix) with ESMTP id 6DA5737B404 for ; Fri, 15 Dec 2000 09:10:33 -0800 (PST) Received: (from uucp@localhost) by ann.skypoint.net (8.9.3/8.9.3) with UUCP id RAA61905; Fri, 15 Dec 2000 17:09:10 GMT Received: from localhost (peiffer@localhost) by Mutley.MN.Org (8.11.0/8.11.0) with ESMTP id eBF1W9500381; Thu, 14 Dec 2000 19:33:01 -0600 (CST) Date: Thu, 14 Dec 2000 19:32:09 -0600 (CST) From: Tim Peiffer To: Gleb Shegai Cc: Subject: Re: Perl <-> Oracle In-Reply-To: <20001214073431.74630.qmail@web10008.mail.yahoo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-database@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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