From: miker Date: Wed, 14 May 2008 16:23:42 +0000 (+0000) Subject: use a RECORD for LOOP for postgres 8.1 compat X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b3eaee75e966be5cfadb820d3847edd897d309d2;p=Evergreen.git use a RECORD for LOOP for postgres 8.1 compat git-svn-id: svn://svn.open-ils.org/ILS/trunk@9599 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/100.circ_matrix.sql b/Open-ILS/src/sql/Pg/100.circ_matrix.sql index bb21ae420d..3a7b122db0 100644 --- a/Open-ILS/src/sql/Pg/100.circ_matrix.sql +++ b/Open-ILS/src/sql/Pg/100.circ_matrix.sql @@ -228,7 +228,7 @@ DECLARE items_overdue INT; current_fines NUMERIC(8,2) := 0.0; tmp_fines NUMERIC(8,2); - tmp_xact BIGINT; + tmp_xact RECORD; done BOOL := FALSE; BEGIN result.success := TRUE; @@ -352,10 +352,10 @@ BEGIN -- Fail if the user has a high fine balance IF circ_test.max_fines IS NOT NULL THEN - FOR tmp_xact IN SELECT id FROM money.billable_xact WHERE usr = match_usr AND xact_finish IS NULL LOOP - SELECT INTO tmp_fines SUM( amount ) FROM money.billing WHERE xact = tmp_xact AND NOT voided; + FOR tmp_xact IN SELECT * FROM money.billable_xact WHERE usr = match_usr AND xact_finish IS NULL LOOP + SELECT INTO tmp_fines SUM( amount ) FROM money.billing WHERE xact = tmp_xact.id AND NOT voided; current_fines = current_fines + COALESCE(tmp_fines, 0.0); - SELECT INTO tmp_fines SUM( amount ) FROM money.payment WHERE xact = tmp_xact AND NOT voided; + SELECT INTO tmp_fines SUM( amount ) FROM money.payment WHERE xact = tmp_xact.id AND NOT voided; current_fines = current_fines - COALESCE(tmp_fines, 0.0); END LOOP;