WHERE id = ?|;
push(@values, $form->{id});
} else {
- $query = qq|SELECT MAX(sortkey) + 1 FROM buchungsgruppen|;
+ $query = qq|SELECT COALESCE(MAX(sortkey) + 1, 1) FROM buchungsgruppen|;
my ($sortkey) = $dbh->selectrow_array($query);
$form->dberror($query) if ($dbh->err);
push(@values, $sortkey);
my $query;
if (!$form->{id}) {
- $query = qq|SELECT nextval('id'), MAX(sortkey) + 1 FROM payment_terms|;
+ $query = qq|SELECT nextval('id'), COALESCE(MAX(sortkey) + 1, 1) | .
+ qq|FROM payment_terms|;
my $sortkey;
($form->{id}, $sortkey) = selectrow_query($form, $dbh, $query);
# connect to database
my $dbh = $form->dbconnect_noauto($myconfig);
- my $query = qq|DELETE FROM payment_terms WHERE id = ?|;
+ my $query =
+ qq|DELETE FROM translation_payment_terms WHERE payment_terms_id = ?|;
do_query($form, $dbh, $query, $form->{"id"});
- $query =
- qq|DELETE FROM translation_payment_terms WHERE payment_terms_id = ?|;
+ $query = qq|DELETE FROM payment_terms WHERE id = ?|;
do_query($form, $dbh, $query, $form->{"id"});
$dbh->commit();