Skip to content

Instantly share code, notes, and snippets.

Avatar
i'm a teapot

edward sharp edwardsharp

i'm a teapot
View GitHub Profile
@edwardsharp
edwardsharp / base36_encode_decode.sql
Created Dec 14, 2017 — forked from btbytes/base36_encode_decode.sql
Base36 Conversion in PostgreSQL
View base36_encode_decode.sql
-- source: http://www.jamiebegin.com/base36-conversion-in-postgresql/
CREATE OR REPLACE FUNCTION base36_encode(IN digits bigint, IN min_width int = 0)
RETURNS varchar AS $$
DECLARE
chars char[];
ret varchar;
val bigint;
BEGIN
chars := ARRAY['0','1','2','3','4','5','6','7','8','9'
,'A','B','C','D','E','F','G','H','I','J','K','L','M'
You can’t perform that action at this time.