Revision 49345708
Von Moritz Bunkus vor fast 12 Jahren hinzugefügt
SL/AP.pm | ||
---|---|---|
395 | 395 |
# connect to database |
396 | 396 |
my $dbh = $form->dbconnect_noauto($myconfig); |
397 | 397 |
|
398 |
# acc_trans entries are deleted by database triggers. |
|
398 | 399 |
my $query = qq|DELETE FROM ap WHERE id = ?|; |
399 | 400 |
do_query($form, $dbh, $query, $form->{id}); |
400 | 401 |
|
401 |
$query = qq|DELETE FROM acc_trans WHERE trans_id = ?|; |
|
402 |
do_query($form, $dbh, $query, $form->{id}); |
|
403 |
|
|
404 |
# commit and redirect |
|
405 | 402 |
my $rc = $dbh->commit; |
406 | 403 |
$dbh->disconnect; |
407 | 404 |
|
SL/AR.pm | ||
---|---|---|
417 | 417 |
# connect to database, turn AutoCommit off |
418 | 418 |
my $dbh = $form->dbconnect_noauto($myconfig); |
419 | 419 |
|
420 |
# acc_trans entries are deleted by database triggers. |
|
420 | 421 |
my $query = qq|DELETE FROM ar WHERE id = ?|; |
421 | 422 |
do_query($form, $dbh, $query, $form->{id}); |
422 | 423 |
|
423 |
$query = qq|DELETE FROM acc_trans WHERE trans_id = ?|; |
|
424 |
do_query($form, $dbh, $query, $form->{id}); |
|
425 |
|
|
426 | 424 |
# commit |
427 | 425 |
my $rc = $dbh->commit; |
428 | 426 |
$dbh->disconnect; |
SL/GL.pm | ||
---|---|---|
51 | 51 |
# connect to database |
52 | 52 |
my $dbh = $form->dbconnect_noauto($myconfig); |
53 | 53 |
|
54 |
my @values = (conv_i($form->{id})); |
|
55 |
do_query($form, $dbh, qq|DELETE FROM acc_trans WHERE trans_id = ?|, @values); |
|
56 |
do_query($form, $dbh, qq|DELETE FROM gl WHERE id = ?|, @values); |
|
54 |
# acc_trans entries are deleted by database triggers. |
|
55 |
do_query($form, $dbh, qq|DELETE FROM gl WHERE id = ?|, conv_i($form->{id})); |
|
57 | 56 |
|
58 | 57 |
# commit and redirect |
59 | 58 |
my $rc = $dbh->commit; |
sql/Pg-upgrade2/ar_ap_gl_delete_triggers_deletion_from_acc_trans.sql | ||
---|---|---|
1 |
-- @tag: ar_ap_gl_delete_triggers_deletion_from_acc_trans |
|
2 |
-- @description: Beim Löschen aus ar, ap, gl per Trigger auch dazugehörige Einträge aus acc_trans löschen |
|
3 |
-- @depends: release_3_0_0 |
|
4 |
-- @charset: utf-8 |
|
5 |
CREATE OR REPLACE FUNCTION clean_up_acc_trans_after_ar_ap_gl_delete() RETURNS trigger AS $$ |
|
6 |
BEGIN |
|
7 |
DELETE FROM acc_trans WHERE trans_id = OLD.id; |
|
8 |
RETURN OLD; |
|
9 |
END; |
|
10 |
$$ LANGUAGE plpgsql; |
|
11 |
|
|
12 |
CREATE TRIGGER after_delete_ar_trigger |
|
13 |
AFTER DELETE ON ar FOR EACH ROW EXECUTE |
|
14 |
PROCEDURE clean_up_acc_trans_after_ar_ap_gl_delete(); |
|
15 |
|
|
16 |
CREATE TRIGGER after_delete_ap_trigger |
|
17 |
AFTER DELETE ON ap FOR EACH ROW EXECUTE |
|
18 |
PROCEDURE clean_up_acc_trans_after_ar_ap_gl_delete(); |
|
19 |
|
|
20 |
CREATE TRIGGER after_delete_gl_trigger |
|
21 |
AFTER DELETE ON gl FOR EACH ROW EXECUTE |
|
22 |
PROCEDURE clean_up_acc_trans_after_ar_ap_gl_delete(); |
Auch abrufbar als: Unified diff
Nach Löschen in ar/ap/gl via DB-Trigger in acc_trans aufräumen