Skip to content

Instantly share code, notes, and snippets.

@SIFAR786
SIFAR786 / sendgrid_eid.sql
Created April 11, 2018 15:16 — forked from emiel/sendgrid_eid.sql
Decode SendGrid Event ID in Postgres
create or replace function sendgrid_eid24_to_uuid(eid text)
returns uuid language sql immutable strict parallel safe
as $function$
select encode(decode(translate(eid, '-_', '+/'), 'base64'), 'hex')::uuid;
$function$;
create or replace function sendgrid_eid48_to_uuid(eid text)
returns uuid language sql immutable strict parallel safe
as $function$