#!/usr/local/bin/perl use strict; use DBI; my $ORACLE_HOME = "/usr/local/libexec/oracle/app/oracle/product/11.2.0/client_1"; my $ORACLE_SID ="orcl"; $ENV{ORACLE_HOME} = $ORACLE_HOME; $ENV{ORACLE_SID} = $ORACLE_SID; $ENV{TNS_ADMIN} = "$ORACLE_HOME/network/admin"; my $dbh = DBI->connect("DBI:Oracle:orcl", "username", "password"); my $sth = $dbh->prepare("SELECT * FROM tablename") || die "Error in DBI::prepare: $!"; $sth->execute || die "Error in sth::execute: $!"; print "Content-type: text/html\n\n"; while (my $row = $sth->fetchrow_arrayref) { print "@$row\n"; } # # VERY important to close Oracle Database Connections and free statements! # $sth->finish; $dbh->disconnect;