Wednesday, November 27, 2013

Oracle - CONNECT_PERL_CMD


use strict;
use warnings;


my $connect_string = 'username/password@server'; # connection to the DB
my $file = 'test.sql'; # location of SQL file. The file must end with "exit"

my $sqlcmd = "sqlplus -S $connect_string \@$file"; # sqlcommand
system $sqlcmd; # executes command

-

use warnings;
use DBI;
use strict;

my $user = 'system';
my $passwd = 'pass';
my $dbh = DBI->connect("dbi:Oracle:host=192.168.0.208;sid=ORAPRD;  port=1521", $user, $passwd)  || die "Database connection not made: $DBI::errstr";
$dbh->disconnect;

0 comentários:

Post a Comment