From 7ee6ee66bf7aa33355f1c57b48a416dea46582c2 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 26 Jul 2005 16:44:37 +0000 Subject: [PATCH] trigger tweak git-svn-id: svn://svn.open-ils.org/ILS/trunk@1490 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/090.schema.action.sql | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index 25e2ea6cc5..bcb0a3c3f5 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -88,11 +88,13 @@ CREATE OR REPLACE VIEW action.billable_cirulations AS CREATE OR REPLACE FUNCTION action.circulation_claims_returned () RETURNS TRIGGER AS $$ BEGIN - IF NEW.stop_fines = 'CLAIMSRETURNED' THEN - UPDATE actor.usr SET claims_returned_count = claims_returned_count + 1 WHERE id = NEW.usr; - END IF; - IF NEW.stop_fines = 'LOST' THEN - UPDATE asset.copy SET status = 3 WHERE id = NEW.target_copy; + IF OLD.stop_fines IS NULL OR OLD.stop_fines <> NEW.stop_fines THEN + IF NEW.stop_fines = 'CLAIMSRETURNED' THEN + UPDATE actor.usr SET claims_returned_count = claims_returned_count + 1 WHERE id = NEW.usr; + END IF; + IF NEW.stop_fines = 'LOST' THEN + UPDATE asset.copy SET status = 3 WHERE id = NEW.target_copy; + END IF; END IF; RETURN NEW; END; -- 2.43.2