ORDER BY
are.id;
-
--- OPTIONAL PORTION
-
-\qecho If an edit date changes in the asset.call_number or asset.copy and you want this to persist to an OAI2 datestamp,
-\qecho then add these stored procedures and triggers:
-\qecho
-\qecho 'CREATE OR REPLACE FUNCTION oai.datestamp(rid BIGINT)'
-\qecho ' RETURNS VOID AS $$'
-\qecho 'BEGIN'
-\qecho ' UPDATE biblio.record_entry AS bre'
-\qecho ' SET edit_date = now()'
-\qecho ' WHERE bre.id = rid;'
-\qecho 'END'
-\qecho '$$ LANGUAGE plpgsql;'
-\qecho
-\qecho 'CREATE OR REPLACE FUNCTION oai.call_number_datestamp()'
-\qecho ' RETURNS TRIGGER AS $$'
-\qecho 'BEGIN'
-\qecho ' IF TG_OP = ''DELETE'''
-\qecho ' THEN'
-\qecho ' PERFORM oai.datestamp(OLD.record);'
-\qecho ' RETURN OLD;'
-\qecho ' END IF;'
-\qecho
-\qecho ' PERFORM oai.datestamp(NEW.record);'
-\qecho ' RETURN NEW;'
-\qecho
-\qecho 'END'
-\qecho '$$ LANGUAGE plpgsql;'
-\qecho
-\qecho 'CREATE OR REPLACE FUNCTION oai.copy_datestamp()'
-\qecho ' RETURNS TRIGGER AS $$'
-\qecho 'BEGIN'
-\qecho ' IF TG_OP = ''DELETE'''
-\qecho ' THEN'
-\qecho ' PERFORM oai.datestamp((SELECT acn.record FROM asset.call_number as acn WHERE acn.id = OLD.call_number));'
-\qecho ' RETURN OLD;'
-\qecho ' END IF;'
-\qecho
-\qecho ' PERFORM oai.datestamp((SELECT acn.record FROM asset.call_number as acn WHERE acn.id = NEW.call_number));'
-\qecho ' RETURN NEW;'
-\qecho
-\qecho 'END'
-\qecho '$$ LANGUAGE plpgsql;'
-\qecho
-\qecho 'CREATE TRIGGER call_number_datestamp AFTER INSERT OR UPDATE OR DELETE ON asset.call_number FOR EACH ROW EXECUTE PROCEDURE oai.call_number_datestamp();'
-\qecho 'CREATE TRIGGER copy_datestamp AFTER INSERT OR UPDATE OR DELETE ON asset.copy FOR EACH ROW EXECUTE PROCEDURE oai.copy_datestamp();'
-
COMMIT;
#</Location>
----
-Optional: Setting the datestamp
-+++++++++++++++++++++++++++++++
-
-The edit date of the bibliographic and authority record is used as
-datestamp. If you want the date for editorial updates of bibliographic
-assets (i.e. copies, call numbers) reflected in the datestamp, then add the
-triggers shown below.
-
-```sql
-
-CREATE OR REPLACE FUNCTION oai.datestamp(rid BIGINT)
- RETURNS VOID AS $$
-BEGIN
- UPDATE biblio.record_entry AS bre
- SET edit_date = now()
- WHERE bre.id = rid;
-END
-$$ LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION oai.call_number_datestamp()
- RETURNS TRIGGER AS $$
-BEGIN
- IF TG_OP = 'DELETE'
- THEN
- PERFORM oai.datestamp(OLD.record);
- RETURN OLD;
- END IF;
-
- PERFORM oai.datestamp(NEW.record);
- RETURN NEW;
-
-END
-$$ LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION oai.copy_datestamp()
- RETURNS TRIGGER AS $$
-BEGIN
- IF TG_OP = 'DELETE'
- THEN
- PERFORM oai.datestamp((SELECT acn.record FROM asset.call_number as acn WHERE acn.id = OLD.call_number));
- RETURN OLD;
- END IF;
-
- PERFORM oai.datestamp((SELECT acn.record FROM asset.call_number as acn WHERE acn.id = NEW.call_number));
- RETURN NEW;
-
-END
-$$ LANGUAGE plpgsql;
-
-CREATE TRIGGER call_number_datestamp AFTER INSERT OR UPDATE OR DELETE ON asset.call_number FOR EACH ROW EXECUTE PROCEDURE oai.call_number_datestamp();
-CREATE TRIGGER copy_datestamp AFTER INSERT OR UPDATE OR DELETE ON asset.copy FOR EACH ROW EXECUTE PROCEDURE oai.copy_datestamp();
-```
-