Skip to content

Instantly share code, notes, and snippets.

@LincolnUniLTL
Created April 14, 2014 02:38
Show Gist options
  • Save LincolnUniLTL/10611972 to your computer and use it in GitHub Desktop.
Save LincolnUniLTL/10611972 to your computer and use it in GitHub Desktop.
DSpace handle returning function
-- PostgresSQL pure SQL function to return handle, given an id
-- assumes handle is uniquely in element "identifier(.uri)", uncomment non-standard uri qualifier to enforce that
CREATE OR REPLACE FUNCTION DHandle(p_id INTEGER) RETURNS text AS $$
SELECT text_value
FROM metadatavalue V, metadatafieldregistry R
WHERE R.metadata_field_id = V.metadata_field_id
AND element ILIKE 'identifier'
-- AND qualifier ILIKE 'uri'
AND item_id=$1;
$$ LANGUAGE SQL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment