Auftrags-Controller: Preisquellen in oberer Eingabezeile besser berücksichtigen
[kivitendo-erp.git] / sql / Pg-upgrade2 / invoice_positions.pl
index 18ea9e9..fea63da 100644 (file)
@@ -1,7 +1,6 @@
 # @tag: invoice_positions
 # @description: Spalte für Positionen der Einträge in Rechnungen
 # @depends: release_3_1_0
-# @encoding: utf-8
 package SL::DBUpgrade2::invoice_positions;
 
 use strict;
@@ -17,11 +16,13 @@ sub run {
 
 
   $query = qq|SELECT * FROM invoice ORDER BY trans_id, id|;
+  my $query2 = qq|UPDATE invoice SET position = ? WHERE id = ?|;
 
   my $sth = $self->dbh->prepare($query);
+  my $sth2 = $self->dbh->prepare($query2);
   $sth->execute || $::form->dberror($query);
 
-  # set new posittion field in order of ids, starting by one for each invoice
+  # set new position field in order of ids, starting by one for each invoice
   my $last_invoice_id;
   my $position;
   while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
@@ -32,10 +33,10 @@ sub run {
     }
     $last_invoice_id = $ref->{trans_id};
 
-    $query = qq|UPDATE invoice SET position = ? WHERE id = ?|;
-    $self->db_query($query, bind => [ $position, $ref->{id} ]);
+    $sth2->execute($position, $ref->{id});
   }
   $sth->finish;
+  $sth2->finish;
 
   $query = qq|ALTER TABLE invoice ALTER COLUMN position SET NOT NULL|;
   $self->db_query($query);