Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / sql / Pg-upgrade2 / invoice_positions.pl
index f8bc911..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,8 +16,10 @@ 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 position field in order of ids, starting by one for each invoice
@@ -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);