Revision 0630567f
Von Sven Schöling vor mehr als 8 Jahren hinzugefügt
sql/Pg-upgrade2/invoice_positions.pl | ||
---|---|---|
17 | 17 |
|
18 | 18 |
|
19 | 19 |
$query = qq|SELECT * FROM invoice ORDER BY trans_id, id|; |
20 |
my $query2 = qq|UPDATE invoice SET position = ? WHERE id = ?|; |
|
20 | 21 |
|
21 | 22 |
my $sth = $self->dbh->prepare($query); |
23 |
my $sth2 = $self->dbh->prepare($query2); |
|
22 | 24 |
$sth->execute || $::form->dberror($query); |
23 | 25 |
|
24 | 26 |
# set new position field in order of ids, starting by one for each invoice |
... | ... | |
32 | 34 |
} |
33 | 35 |
$last_invoice_id = $ref->{trans_id}; |
34 | 36 |
|
35 |
$query = qq|UPDATE invoice SET position = ? WHERE id = ?|; |
|
36 |
$self->db_query($query, bind => [ $position, $ref->{id} ]); |
|
37 |
$sth2->execute($position, $ref->{id}); |
|
37 | 38 |
} |
38 | 39 |
$sth->finish; |
40 |
$sth2->finish; |
|
39 | 41 |
|
40 | 42 |
$query = qq|ALTER TABLE invoice ALTER COLUMN position SET NOT NULL|; |
41 | 43 |
$self->db_query($query); |
Auch abrufbar als: Unified diff
DB-Upgrade: Queries nicht in der Schleife preparen
Datenbank mit 100k invoice Einträgen braucht Jahre sonst.