Skip to content

Instantly share code, notes, and snippets.

@arxdsilva
Last active February 18, 2022 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arxdsilva/55025e8a3e8be0f41b195c61428b54f4 to your computer and use it in GitHub Desktop.
Save arxdsilva/55025e8a3e8be0f41b195c61428b54f4 to your computer and use it in GitHub Desktop.
return text if not uuid
CREATE OR REPLACE FUNCTION public.null_or_not_uuid(str text)
RETURNS text
LANGUAGE plpgsql
AS $function$
declare
struuid uuid;
begin
struuid = str::uuid;
RETURN null;
EXCEPTION WHEN invalid_text_representation THEN
RETURN str;
END;
$function$
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment