[OPEN-ILS-GENERAL] how to delete the record physically

Jason Etheridge jason at esilibrary.com
Tue Feb 10 12:49:32 EST 2009

> after deleting the bibliographic record from the Evergreen database, is
> seems that the record is remaining in the system. How can I remove (destroy)
> the record physically from the database?

Hi Tigran,

Evergreen keeps things around for referential integrity even when
they're flagged as deleted.  For most intents and purposes, a record
flagged as deleted behaves as if it does not exist.

However, if you _really_ want to delete a bib record from the
database, the first step is to drop the protect_bib_rec_delete rule on
the biblio.record_entry table, like so:

DROP RULE protect_bib_rec_delete ON biblio.record_entry;

At this point you can play a game of hunt the references, and start with:

DELETE FROM biblio.record_entry CASCADE WHERE id = blah;

We don't appear to be using ON DELETE CASCADE in all the table
definitions to make this easy.  You'll very likely run into
constraints from the call number and item tables, and
metabib.metarecord and will have to remove rows from those tables
before the delete on biblio.record_entry succeeds.

To re-create the bib protection rule, do:

CREATE RULE protect_bib_rec_delete AS ON DELETE TO biblio.record_entry
DO INSTEAD UPDATE biblio.record_entry SET deleted = TRUE WHERE OLD.id
= biblio.record_entry.id;

I hope this helps, but be careful! :)

Jason Etheridge
 | VP, Community Support and Advocacy
 | Equinox Software, Inc. / The Evergreen Experts
 | phone:  1-877-OPEN-ILS (673-6457)
 | email:  jason at esilibrary.com
 | web:  http://www.esilibrary.com

More information about the Open-ils-general mailing list