Limit circ_modifier selection to items owned by submission lib(s)
authorJason Boyer <jboyer1@library.in.gov>
Thu, 13 Feb 2014 20:44:44 +0000 (15:44 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 13 Feb 2014 21:39:58 +0000 (16:39 -0500)
Without limiting the items considered to the submission library
it's possible that the circ_modifier chosen may not be in use
anywhere at that library.

Signed-off-by: Jason Boyer <jboyer1@library.in.gov>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
collectionHQ/functions.sql

index 36925ad..84028da 100644 (file)
@@ -246,7 +246,7 @@ CREATE OR REPLACE FUNCTION collectionHQ.write_bib_rows_to_stdout (TEXT, INT) RET
       FROM biblio.record_entry
       WHERE id = lms_bib_id;
 
-      SELECT circ_modifier INTO lms_item_type FROM asset.copy c, asset.call_number cn WHERE cn.record = lms_bib_id AND cn.id = c.call_number AND NOT cn.deleted AND NOT c.deleted LIMIT 1;
+      SELECT circ_modifier INTO lms_item_type FROM asset.copy c, asset.call_number cn WHERE cn.record = lms_bib_id AND c.circ_lib IN (SELECT id FROM actor.org_unit_descendants(org_unit_id)) AND cn.id = c.call_number AND NOT cn.deleted AND NOT c.deleted LIMIT 1;
       SELECT REPLACE(NOW()::DATE::TEXT, '-', '') INTO extract_date;
   
       output :=