On 09/04/2012 14:24, Vyacheslav wrote:
My code
my %attr = (
PrintError => 0,
RaiseError => 0
);
my $dbh = DBI->connect($dsn, $user, $pass, \%attr);
unless ($dbh) {
next;
}
my $query = "SHOW DATABASES";
I use
unless ($dbh) {
next;
} and this work fine.
Thanks
09.04.2012 01:22, Jim Gibson напи
My code
my %attr = (
PrintError => 0,
RaiseError => 0
);
my $dbh = DBI->connect($dsn, $user, $pass, \%attr);
unless ($dbh) {
next;
}
my $query = "SHOW DATABASES";
I use
unless ($dbh) {
next;
} and this work fine.
Thanks
09.04.2012 01:22, Jim Gibson написал:
At 12:50 AM + 4/9/12, Vyachesl
At 12:50 AM + 4/9/12, Vyacheslav wrote:
I enabled RaiserError, then script die.
...
my %attr = (
PrintError => 0,
RaiseError => 1
);
Use:
RaiseError => 0
instead so that your script will not raise an exception and die. Then
check $dbh->err.
--
To unsubscribe, e-mail: beginne
I enabled RaiserError, then script die.
...
my %attr = (
PrintError => 0,
RaiseError => 1
);
my $dbh = DBI->connect($dsn, $user, $pass, \%attr); # or die "Can't
connect to the DB: $DBI::errstr\n";
my $query = "SHOW DATABASES";
my $sth = $dbh->prepare($query) or die "Can't prepare SQL st
On 2012-04-08 17:10, Vyacheslav wrote:
using eval helped me.
You should not use exceptions for normal code flow.
Read the DBI docs (perldoc DBI).
If a failed connection must be an exception, set RaiseError to true.
But if it isn't an exception, leave it false, and test $dbh->err (or the
glob
Hi Vyacheslav,
On Sun, 08 Apr 2012 15:10:06 +
Vyacheslav wrote:
> Thanks all.
>
> using eval helped me.
>
The problem with eval in Perl 5 is that it catches any and all thrown exceptions
. I.e: by default, it doesn't do Object-Oriented exceptions like Java, Ruby,
Python and other language
Thanks all.
using eval helped me.
08.04.2012 09:43, Shlomi Fish пишет:
Hi Vyacheslav,
On Sun, 08 Apr 2012 06:12:53 +
Vyacheslav wrote:
Hello all.
My english bad and i have a problem.
I am connected to databases in a cycle foreach and the script die, if
one of database is not available.
Hi Vyacheslav,
On Sun, 08 Apr 2012 06:12:53 +
Vyacheslav wrote:
> Hello all.
> My english bad and i have a problem.
>
> I am connected to databases in a cycle foreach and the script die, if
> one of database is not available.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use DBI;
"host $db - not ok";
} else {
print "host $db - ok";
}
http://www.gnome.org/friends/banners/associate.png"; alt="Become a
Friend of GNOME" border="0" />
From: Vyacheslav
To: beginners@perl.org
Sent: Sund
Hello all.
My english bad and i have a problem.
I am connected to databases in a cycle foreach and the script die, if
one of database is not available.
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use DBD::mysql;
foreach $db (&hostdb("$project")) {
my $server = "$db";
my $dbname = "in
10 matches
Mail list logo