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

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

    my $collectd_typ = $wert;
    unless ( defined $collectd_typ ) {
        content( $collectd_typ = line_in 'Collectd Typ (Freitext):' ) or return;
    }
    return problem "Das ist ein Pflichtfeld und kann daher nicht gelöscht werden."
      if $collectd_typ eq '-';

    $collectd_typ = qquote $collectd_typ
      unless ( defined $wert );
    return $collectd_typ unless defined $idi;

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

1;
