# Remove Collection Agency Block for Patrons in Record Set

**URL:** https://forum.innovativeusers.org/t/remove-collection-agency-block-for-patrons-in-record-set/1633
**Category:** Polaris Repository
**Created:** [December 19, 2023, 7:51pm UTC](https://forum.innovativeusers.org/t/remove-collection-agency-block-for-patrons-in-record-set/1633 "2023-12-19T19:51:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mfields](https://forum.innovativeusers.org/letter_avatar_proxy/v4/letter/m/bc8723/32.png) [@mfields](https://forum.innovativeusers.org/u/mfields)
#### Post date: [December 19, 2023, 7:51pm UTC](https://forum.innovativeusers.org/t/remove-collection-agency-block-for-patrons-in-record-set/1633/1 "2023-12-19T19:51:48Z")

</div>

By default the report requires a key that is the MD5 value of the library organization id as a failsafe.

Report can be found here: [Bulk Remove Collection Agency Block.rdl](https://forum.innovativeusers.org/uploads/short-url/lHT6YKKxNRxTyUEgHMdfLIjaNax.rdl) (11.4 KB)

* * *

Raw SQL here:

```auto
-- assigned library and record set to remove block for
declare @library int = 0
declare @recordsetid int = 0
-- change above

-- do not change below
declare @patronid int
declare cur CURSOR LOCAL for
	select prs.PatronID
	from Polaris.Polaris.PatronRecordSets prs 
	join Polaris.Polaris.Patrons p on
		prs.PatronID = p.PatronID
	join Polaris.Polaris.Organizations o on
		p.OrganizationID = o.OrganizationID
	where RecordSetID = @recordsetid and p.SystemBlocks & 1024 = 1024 and o.ParentOrganizationID = @library

open cur

fetch next from cur into @patronid

while @@FETCH_STATUS = 0 BEGIN
	exec Polaris.Circ_RemoveCABlockByPatronID @patronid
	fetch next from cur into @patronid
END

close cur
deallocate cur

select 'done' [status]

```
