Revision 6ff01fdb
Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt
SL/IS.pm | ||
---|---|---|
1063 | 1063 |
|
1064 | 1064 |
my ($self, $form, $dbh) = @_; |
1065 | 1065 |
|
1066 |
my @delete_oids;
|
|
1066 |
my @delete_acc_trans_ids;
|
|
1067 | 1067 |
|
1068 | 1068 |
# Delete old payment entries from acc_trans. |
1069 | 1069 |
my $query = |
1070 |
qq|SELECT oid
|
|
1070 |
qq|SELECT acc_trans_id
|
|
1071 | 1071 |
FROM acc_trans |
1072 | 1072 |
WHERE (trans_id = ?) AND fx_transaction |
1073 | 1073 |
|
1074 | 1074 |
UNION |
1075 | 1075 |
|
1076 |
SELECT at.oid
|
|
1076 |
SELECT at.acc_trans_id
|
|
1077 | 1077 |
FROM acc_trans at |
1078 | 1078 |
LEFT JOIN chart c ON (at.chart_id = c.id) |
1079 | 1079 |
WHERE (trans_id = ?) AND (c.link LIKE '%AR_paid%')|; |
1080 |
push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
|
|
1080 |
push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
|
|
1081 | 1081 |
|
1082 | 1082 |
$query = |
1083 |
qq|SELECT at.oid
|
|
1083 |
qq|SELECT at.acc_trans_id
|
|
1084 | 1084 |
FROM acc_trans at |
1085 | 1085 |
LEFT JOIN chart c ON (at.chart_id = c.id) |
1086 | 1086 |
WHERE (trans_id = ?) |
1087 | 1087 |
AND ((c.link = 'AR') OR (c.link LIKE '%:AR') OR (c.link LIKE 'AR:%')) |
1088 |
ORDER BY at.oid
|
|
1088 |
ORDER BY at.acc_trans_id
|
|
1089 | 1089 |
OFFSET 1|; |
1090 |
push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
|
|
1090 |
push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
|
|
1091 | 1091 |
|
1092 |
if (@delete_oids) {
|
|
1093 |
$query = qq|DELETE FROM acc_trans WHERE oid IN (| . join(", ", @delete_oids) . qq|)|;
|
|
1092 |
if (@delete_acc_trans_ids) {
|
|
1093 |
$query = qq|DELETE FROM acc_trans WHERE acc_trans_id IN (| . join(", ", @delete_acc_trans_ids) . qq|)|;
|
|
1094 | 1094 |
do_query($form, $dbh, $query); |
1095 | 1095 |
} |
1096 | 1096 |
|
... | ... | |
1147 | 1147 |
LEFT JOIN chart c ON (at.chart_id = c.id) |
1148 | 1148 |
WHERE (trans_id = ?) |
1149 | 1149 |
AND ((c.link = 'AR') OR (c.link LIKE '%:AR') OR (c.link LIKE 'AR:%')) |
1150 |
ORDER BY at.oid
|
|
1150 |
ORDER BY at.acc_trans_id
|
|
1151 | 1151 |
LIMIT 1|; |
1152 | 1152 |
|
1153 | 1153 |
($form->{AR}) = 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.