perl dbi test connection - ghdrako/doc_snipets GitHub Wiki

use DBI;
use DBD:Oracle;

if (!($dbh = DBI->connect ('DBI:Oracle:SLOGCOPY',"slog","Nawa!90kszut#")))
{
  die ("Failed to connect to database: " . DBI->errstr);
};

$sql = "SELECT COUNT(*) FROM dual";
($count) = $dbh->selectrow_array ($sql);
printf ("Count = %d\n",$count);

$dbh->disconnect;