+ Fix mssql version bug

This commit is contained in:
garnier-quentin 2018-12-20 12:03:50 +01:00
parent 387a9e3f73
commit 5880e09d72
2 changed files with 7 additions and 2 deletions

View File

@ -262,18 +262,23 @@ sub fetchrow_hashref {
sub query {
my ($self, %options) = @_;
my $continue_error = defined($options{continue_error}) && $options{continue_error} == 1 ? 1 : 0;
$self->{statement_handle} = $self->{instance}->prepare($options{query});
if (!defined($self->{statement_handle})) {
return 1 if ($continue_error == 1);
$self->{output}->add_option_msg(short_msg => "Cannot execute query: " . $self->{instance}->errstr);
$self->{output}->option_exit(exit_litteral => $self->{sql_errors_exit});
}
my $rv = $self->{statement_handle}->execute;
if (!$rv) {
return 1 if ($continue_error == 1);
$self->{output}->add_option_msg(short_msg => "Cannot execute query: " . $self->{statement_handle}->errstr);
$self->{output}->option_exit(exit_litteral => $self->{sql_errors_exit});
}
}
return 0;
}
1;

View File

@ -31,7 +31,7 @@ sub set_version {
$self->{version} = $self->{instance}->get_info(18); # SQL_DBMS_VER
return if (defined($self->{version}) && $self->{version} ne '');
$self->query(query => q{select SERVERPROPERTY('productversion') as product_version});
return if ($self->query(query => q{select SERVERPROPERTY('productversion') as product_version}, continue_error => 1) == 1);
my $row = $self->fetchrow_hashref();
$self->{version} = $row->{product_version};
}