rasti.hil@hilandco.com +41 79 367-9677

Search This Blog

Oracle & Perl

Connect to Oracle Database with DBD::Oracle


use strict;
use DBI;

my $user = 'username';
my $passwd = 'password';
my $SID = 'xxxx';
my $port = 'xxxx';

my $db = DBI->connect( "dbi:Oracle:localhost:$port/$SID", $user, $passwd )
|| die( $DBI::errstr . "\n" );

$db->{AutoCommit} = 0;
$db->{RaiseError} = 1;
$db->{ora_check_sql} = 0;
$db->{RowCacheSize} = 16;

END {
$db->disconnect if defined($db);
}


Select data from Oracle Database with DBD::Oracle

my $SQL = "select 1 from dual"; # SQL SELECT
my $sth = $db->prepare($SQL); # Prepare SELECT
$sth->execute(); # Execute SELECT