$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
}
$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);
my $order_id_col = $order_id_cols{ $table };
$query = qq|SELECT * FROM $table ORDER BY $order_id_col, id|;
+ my $query2 = qq|UPDATE $table 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 order
}
$last_order_id = $ref->{ $order_id_col };
- $query = qq|UPDATE $table 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 $table ALTER COLUMN position SET NOT NULL|;