# @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;
$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")) {
}
$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);