pears.Base36
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
CREATE FUNCTION "pears"."Base36"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ IN "seed" INTEGER,IN "digits" SMALLINT ) RETURNS CHAR(20) BEGIN DECLARE "rv" CHAR(20); DECLARE "m" INTEGER; SET "rv" = ''; IF(("digits" > 20) OR("digits" < 1)) THEN SET "digits" = 20 END IF; while "seed" > 0 loop SET "m" = "mod"("seed",36); IF "m" < 10 THEN SET "rv" = "char"("m"+48) || "rv" ELSE SET "rv" = "char"("m"+55) || "rv" END IF; SET "seed" = "seed"/36 END loop; while "length"("rv") < "digits" loop SET "rv" = '0' || "rv" END loop; RETURN("rv") END