Revision 6ff01fdb
Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt
SL/IR.pm | ||
---|---|---|
1187 | 1187 |
|
1188 | 1188 |
my ($self, $form, $dbh) = @_; |
1189 | 1189 |
|
1190 |
my @delete_oids;
|
|
1190 |
my @delete_acc_trans_ids;
|
|
1191 | 1191 |
|
1192 | 1192 |
# Delete old payment entries from acc_trans. |
1193 | 1193 |
my $query = |
1194 |
qq|SELECT oid
|
|
1194 |
qq|SELECT acc_trans_id
|
|
1195 | 1195 |
FROM acc_trans |
1196 | 1196 |
WHERE (trans_id = ?) AND fx_transaction |
1197 | 1197 |
|
1198 | 1198 |
UNION |
1199 | 1199 |
|
1200 |
SELECT at.oid
|
|
1200 |
SELECT at.acc_trans_id
|
|
1201 | 1201 |
FROM acc_trans at |
1202 | 1202 |
LEFT JOIN chart c ON (at.chart_id = c.id) |
1203 | 1203 |
WHERE (trans_id = ?) AND (c.link LIKE '%AP_paid%')|; |
1204 |
push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
|
|
1204 |
push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
|
|
1205 | 1205 |
|
1206 | 1206 |
$query = |
1207 |
qq|SELECT at.oid
|
|
1207 |
qq|SELECT at.acc_trans_id
|
|
1208 | 1208 |
FROM acc_trans at |
1209 | 1209 |
LEFT JOIN chart c ON (at.chart_id = c.id) |
1210 | 1210 |
WHERE (trans_id = ?) |
1211 | 1211 |
AND ((c.link = 'AP') OR (c.link LIKE '%:AP') OR (c.link LIKE 'AP:%')) |
1212 |
ORDER BY at.oid
|
|
1212 |
ORDER BY at.acc_trans_id
|
|
1213 | 1213 |
OFFSET 1|; |
1214 |
push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
|
|
1214 |
push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
|
|
1215 | 1215 |
|
1216 |
if (@delete_oids) {
|
|
1217 |
$query = qq|DELETE FROM acc_trans WHERE oid IN (| . join(", ", @delete_oids) . qq|)|;
|
|
1216 |
if (@delete_acc_trans_ids) {
|
|
1217 |
$query = qq|DELETE FROM acc_trans WHERE acc_trans_id IN (| . join(", ", @delete_acc_trans_ids) . qq|)|;
|
|
1218 | 1218 |
do_query($form, $dbh, $query); |
1219 | 1219 |
} |
1220 | 1220 |
|
... | ... | |
1271 | 1271 |
LEFT JOIN chart c ON (at.chart_id = c.id) |
1272 | 1272 |
WHERE (trans_id = ?) |
1273 | 1273 |
AND ((c.link = 'AP') OR (c.link LIKE '%:AP') OR (c.link LIKE 'AP:%')) |
1274 |
ORDER BY at.oid
|
|
1274 |
ORDER BY at.acc_trans_id
|
|
1275 | 1275 |
LIMIT 1|; |
1276 | 1276 |
|
1277 | 1277 |
($form->{AP}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{id})); |
Auch abrufbar als: Unified diff
Einführung einer ID-Spalte in acc_trans
Die Benutzung der von PostgreSQL zur Verfügung gestellten
Spalte "oid" hat ihre Tücken. Über diese wird in Lx-Office die
Reihenfolge der Einträge in acc_trans geregelt. Wird aber ein
UPDATE-SQL-Query auf acc_trans ausgeführt, so kann es (anscheinend
je nach Datenbankversion) dazu kommen, dass die Zeile eine neue
oid erhält, wodurch die Reihenfolge nicht mehr stimmt.