bibrarian

Holds Activity at a Branch or Library (Polaris ILS)

Jul 21st, 2022 (edited)
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.30 KB | None | 0 0
  1. -- Let's declare variables!
  2. DECLARE @StartDate DATETIME;
  3. DECLARE @EndDate DATETIME;
  4.  
  5. -- Let's set variables!
  6. SET @StartDate = '2022-07-20 00:00:00';
  7. SET @EndDate = '2022-07-20 23:59:59';
  8.  
  9. SELECT
  10.     o.Name AS [Library/Branch],
  11.     itembranch.Name AS [Assigned Branch],
  12.     pr.PatronID AS [Patron ID],
  13.     pr.PatronFullName AS [Patron Name],
  14.     bib.numValue AS [Bib Record ID],
  15.     br.BrowseTitle AS [Title],
  16.     tt.TransactionTypeDescription AS [Hold Action]
  17.  
  18. FROM
  19.     PolarisTransactions.Polaris.TransactionHeaders th WITH (NOLOCK)
  20.  
  21. INNER JOIN -- Convert numerical transaction type codes into proper descriptions
  22.     PolarisTransactions.Polaris.TransactionTypes tt WITH (NOLOCK) on tt.TransactionTypeID = th.TransactionTypeID
  23. INNER JOIN -- Use this join to get the PatronID from TransactionDetails
  24.     PolarisTransactions.Polaris.TransactionDetails patron WITH (NOLOCK) ON th.TransactionID = patron.TransactionID
  25. INNER JOIN -- This join allows us to use that PatronID to get useful goodies from PatronRegistration
  26.     Polaris.Polaris.PatronRegistration pr WITH (NOLOCK) ON pr.PatronID = patron.NumValue
  27. INNER JOIN -- We can pull the OrganizationID out of the TransactionHeaders
  28.     Polaris.Polaris.Organizations o WITH (NOLOCK) ON th.OrganizationID = o.OrganizationID
  29. INNER JOIN -- And use this join to get the BibliographicRecordID from Transaction Details
  30.     PolarisTransactions.Polaris.TransactionDetails bib WITH (NOLOCK) ON th.TransactionID = bib.TransactionID
  31. LEFT OUTER JOIN -- Now use that BibliographicRecordID to get info from the BibliographicRecords table
  32.     Polaris.Polaris.BibliographicRecords br WITH (NOLOCK) ON br.BibliographicRecordID = bib.numValue
  33. INNER JOIN -- Let's get the item's assigned branch OrganizationID
  34.     PolarisTransactions.Polaris.TransactionDetails itemorg WITH (NOLOCK) ON th.TransactionID = itemorg.TransactionID
  35. INNER JOIN -- And we join the Organizations table again to get the item's assigned branch
  36.     Polaris.Polaris.Organizations itembranch WITH (NOLOCK) ON itembranch.OrganizationID = itemorg.numValue
  37.  
  38. WHERE
  39.     th.TransactionTypeID = 6006 -- Set this as needed. See list below for codes.
  40.     -- Or use multiple codes for multiple hold activity types.
  41.     --th.TransactionTypeID IN (6006, 6012) -- Gets holds filled at the branch and holds shipped
  42. AND
  43.     patron.TransactionSubTypeID = 6 -- The numerical code
  44. AND
  45.     bib.TransactionSubTypeID = 36 -- Pulls the bib record ID
  46. AND
  47.     th.TranClientDate BETWEEN @StartDate AND @EndDate
  48. -- To limit the list to items held at a branch that match the assigned branch, make sure the two numbers below are the same.
  49. AND -- The branch where the item was held
  50.     o.OrganizationID = 5
  51. AND -- The item's assigned branch
  52.     itembranch.OrganizationID = 5
  53.  
  54. GROUP BY
  55.     o.Name,
  56.     pr.PatronID,
  57.     pr.PatronFullName,
  58.     bib.numValue,
  59.     br.BrowseTitle,
  60.     itembranch.Name,
  61.     tt.TransactionTypeDescription
  62.  
  63. ORDER BY
  64.     pr.PatronFullName
  65.  
  66.  
  67. /*
  68. Transaction Type IDs for Various Hold Actions
  69. ---------------------------------------------
  70.  
  71. 6005    Hold request created
  72. 6006    Holds become held (item received for hold request)
  73. 6007    Holds become expired
  74. 6008    Holds become unclaimed
  75. 6009    Holds become denied
  76. 6010    Holds become pending
  77. 6011    Holds become not supplied
  78. 6012    Holds become shipped
  79. 6013    Holds become cancelled
  80. */
Add Comment
Please, Sign In to add comment