Last active
February 18, 2022 11:18
-
-
Save arxdsilva/55025e8a3e8be0f41b195c61428b54f4 to your computer and use it in GitHub Desktop.
return text if not uuid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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