• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Connectivity of Perl to Oracle

How will I connect my Oracle database to Perl?How will I run the said database with perl?Can I have an sample code for this?
0
keziah0815
Asked:
keziah0815
1 Solution
 
andreifCommented:
Hi,
here are some parts of my working code, hope it helps

use DBI;
$dbh = DBI->connect("DBI:Oracle:host=DB_IP_HERE;sid=ORCL;port=1521",'DB_USER_NAME_HERE','DB_PASSWORD_HERE') or die "Couldn't connect to database: ".$DBI::errstr;

$sql = "select * from mytable";
$sth=$dbh->prepare($sql) or print DBI::error;
$sth->execute or print $DBI::error;

while ($record = $sth->fetchrow_hashref) {
  print "$$record{name} - $$record{email}<br>";
}
$sth->finish;
$dbh->disconnect;
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now