+ add option for empty sql result in sql-string mode

This commit is contained in:
garnier-quentin 2019-04-25 17:35:11 +02:00
parent f1ebc9e106
commit 7ab2f795eb

View File

@ -115,6 +115,7 @@ sub new {
"printf-format:s" => { name => 'printf_format' }, "printf-format:s" => { name => 'printf_format' },
"printf-value:s" => { name => 'printf_value' }, "printf-value:s" => { name => 'printf_value' },
"dual-table" => { name => 'dual_table' }, "dual-table" => { name => 'dual_table' },
"empty-sql-string:s" => { name => 'empty_sql_string', default => 'No row returned or --key-column/--value-column do not correctly match selected field' },
}); });
return $self; return $self;
@ -159,7 +160,7 @@ sub manage_selection {
} }
if (scalar(keys %{$self->{rows}}) <= 0) { if (scalar(keys %{$self->{rows}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No row returned or --key-column/--value-column do not correctly match selected field"); $self->{output}->add_option_msg(short_msg => $self->{option_results}->{empty_sql_string});
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
@ -211,6 +212,11 @@ Set critical condition (if statement syntax) for status evaluation.
Set this option to ensure compatibility with dual table and Oracle. Set this option to ensure compatibility with dual table and Oracle.
=item B<--empty-sql-string>
Set this option to change the output message when the sql statement result is empty.
(Default: 'No row returned or --key-column/--value-column do not correctly match selected field')
=back =back
=cut =cut