use utf8;
use warnings; no warnings "redefine";
use strict;
use Dbase::Help qw(DoFn Do qquote);
use Dbase::Globals qw(content);
use Fehler qw(problem);
use Loader qw(line_in log_update);

sub set_messtyp_rrd_max($;$) {
    my ( $idi, $kn ) = @_;

    content( my $rrd_max = line_in 'RRD Maximum: ' )
      or return 'NULL';

    return problem( qq(Das ist kein gültiger Maximum Wert (Dezimalformat).) )
      if $rrd_max !~ /^(?:-)?\d+(?:.\d+)?\z/ and $rrd_max ne '-';

    $rrd_max = $rrd_max eq '-' ? 'NULL' : qquote $rrd_max;
    return $rrd_max unless defined $idi;

    log_update mess_typ => id => $idi, undef, 'rrd_max', undef,
        DoFn("SELECT rrd_max FROM mess_typ WHERE id = $idi");
    Do("UPDATE mess_typ SET rrd_max = $rrd_max WHERE id = $idi");
}

1;
