#!/usr/bin/perl # Load DBI Module use DBI; # Setup Connection to Oracle8i my $user = 'scott'; my $password = 'tiger'; my $data_source = 'dbi:Oracle:RAB1'; my $empno = 7700; my $dbh = DBI->connect($data_source, $user, $password) || die "Can't connect to $data_source: $DBI::errstr"; # Prepare Statement Handle my $sth = $dbh->prepare(q{ SELECT empno, ename FROM emp WHERE empno >= ? }) || die "Can't prepare statement: $DBI::errstr"; # Execute and Fetch Statement my $rc = $sth->execute($empno) || die "Can't execute statement: $DBI::errstr"; print "Query will return $sth->{NUM_OF_FIELDS} fields.\n\n"; print "Field names: @{ $sth->{NAME} }\n"; while (($empno, $ename) = $sth->fetchrow_array) { print "$empno: $ename\n"; }