Advertisement
roganhamby

Hold Matrix Matchpoint SQL Report

Mar 26th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- really verbose alternative for getting the rules for in-db holds rules
  2. -- rather than just select * config.hold_matrix_matchpoint
  3. -- almost a necessity for a consortium with varying rules or any library
  4. -- with intricate polices because in-db holds policies are much easier to
  5. -- handle via SQL than through the staff client
  6. -- script has IDs for admins and look ups to names for easy reference
  7. -- tested on 2.1 and 2.4
  8. -- (c) Rogan Hamby, 2012, roganhamby.com
  9. -- Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
  10. select hmm.id AS "Hold Matchpoint ID", hmm.active AS "Active",
  11. hmm.user_home_ou AS "User Home ID", ahou.shortname AS "User Home Library",
  12. hmm.request_ou AS "Requesting Org ID", arou.shortname AS "Requesting Library",
  13. hmm.pickup_ou AS "Pickup Org ID", apou.shortname AS "Pickup Library",
  14. hmm.item_owning_ou AS "Item Owning Org ID", aoou.shortname AS "Item Owning Library",
  15. hmm.item_circ_ou AS "Item Circ Org ID", acou.shortname AS "Item Circulating Library",
  16. hmm.usr_grp AS "User Group ID", upgt.name AS "User Group",
  17. hmm.requestor_grp AS "Requestor Group ID", rpgt.name AS "Requestor Group",
  18. hmm.circ_modifier AS "Circulation Modifier",
  19. hmm.marc_type AS "MARC Type",
  20. hmm.marc_form AS "MARC Form",
  21. hmm.marc_vr_format AS "MARC Video Format",
  22. hmm.marc_bib_level AS "MARC Bib Level",
  23. hmm.ref_flag AS "Reference Flag",
  24. hmm.juvenile_flag AS "Juvenile Flag",
  25. hmm.age_hold_protect_rule AS "Age Hold Rule ID", rap.name AS "Age Hold Rule Name", rap.age AS "Age Hold Interval", rap.prox AS "Age Hold Prox",
  26. hmm.holdable AS "Holdable Flag",
  27. hmm.distance_is_from_owner AS "Distance is from Owner",
  28. hmm.transit_range AS "Transit Range ID", aout.depth AS "Transit Range Depth",
  29. hmm.max_holds AS "Max Holds",
  30. hmm.include_frozen_holds AS "Include Frozen Holds Flag",
  31. hmm.stop_blocked_user AS "Stop Blocked User Flag",
  32. hmm.strict_ou_match AS "Strict Org Unit Match Flag"
  33. from config.hold_matrix_matchpoint hmm
  34. left outer join actor.org_unit AS ahou ON ahou.id = hmm.user_home_ou
  35. left outer join actor.org_unit AS arou ON arou.id = hmm.request_ou
  36. left outer join actor.org_unit AS apou ON apou.id = hmm.pickup_ou
  37. left outer join actor.org_unit AS aoou ON aoou.id = hmm.item_owning_ou
  38. left outer join actor.org_unit AS acou ON acou.id = hmm.item_circ_ou
  39. left outer join permission.grp_tree AS upgt ON upgt.id = hmm.usr_grp
  40. left outer join permission.grp_tree AS rpgt ON rpgt.id = hmm.requestor_grp
  41. left outer join config.rule_age_hold_protect rap ON rap.id = hmm.age_hold_protect_rule
  42. left outer join actor.org_unit_type aout ON aout.id = hmm.transit_range
  43. ;
  44.  
  45.  
  46. -- shorter version
  47. SELECT hmm.id AS "Hold Matchpoint ID", hmm.active AS "Active",
  48. hmm.user_home_ou AS "User Home ID", ahou.shortname AS "User Home Library",
  49. hmm.item_owning_ou AS "Item Owning Org ID", aoou.shortname AS "Item Owning Library",
  50. hmm.usr_grp AS "User Group ID", upgt.NAME AS "User Group",
  51. hmm.requestor_grp AS "Requestor Group ID", rpgt.NAME AS "Requestor Group",
  52. hmm.circ_modifier AS "Circulation Modifier", hmm.ref_flag AS "Reference Flag",
  53. hmm.holdable AS "Holdable Flag", hmm.distance_is_from_owner AS "Distance is from Owner",
  54. hmm.transit_range AS "Transit Range ID", aout.depth AS "Transit Range Depth",
  55. hmm.max_holds AS "Max Holds", hmm.stop_blocked_user AS "Stop Blocked User Flag",
  56. hmm.strict_ou_match AS "Strict Org Unit Match Flag"
  57. FROM config.hold_matrix_matchpoint hmm
  58. LEFT OUTER JOIN actor.org_unit AS ahou ON ahou.id = hmm.user_home_ou
  59. LEFT OUTER JOIN actor.org_unit AS arou ON arou.id = hmm.request_ou
  60. LEFT OUTER JOIN actor.org_unit AS apou ON apou.id = hmm.pickup_ou
  61. LEFT OUTER JOIN actor.org_unit AS aoou ON aoou.id = hmm.item_owning_ou
  62. LEFT OUTER JOIN actor.org_unit AS acou ON acou.id = hmm.item_circ_ou
  63. LEFT OUTER JOIN permission.grp_tree AS upgt ON upgt.id = hmm.usr_grp
  64. LEFT OUTER JOIN permission.grp_tree AS rpgt ON rpgt.id = hmm.requestor_grp
  65. LEFT OUTER JOIN config.rule_age_hold_protect rap ON rap.id = hmm.age_hold_protect_rule
  66. LEFT OUTER JOIN actor.org_unit_type aout ON aout.id = hmm.transit_range
  67. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement