From c9928d5d8da83140805d4239711af135ab5763a8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 5 Feb 2007 10:57:06 +0000 Subject: [PATCH] =?utf8?q?Beim=20Anlegen=20von=20Buchungsgruppen=20und=20Z?= =?utf8?q?ahlungskonditionen=20nicht=20darauf=20verlassen,=20dass=20schon?= =?utf8?q?=20Eintr=C3=A4ge=20in=20der=20Tabelle=20vorhanden=20sind,=20um?= =?utf8?q?=20den=20n=C3=A4chsten=20sortkey=20zu=20ermitteln.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/AM.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SL/AM.pm b/SL/AM.pm index 162f54fac..866cf7ab7 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1154,7 +1154,7 @@ sub save_buchungsgruppe { 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); @@ -1400,7 +1400,8 @@ sub save_payment { 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); -- 2.20.1