SwVitaliy

Untitled

Feb 2nd, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. delimiter ;
  2. drop function if exists id2short;
  3. delimiter //
  4. create function id2short (id int)
  5. returns varchar(50)
  6. begin
  7. set @digits = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  8. set @short = substring(@digits, mod(id, 62), 1);
  9. set id = floor(id / 62);
  10. while id <> 0 do
  11. set @short = concat(substring(@digits, mod(id, 62), 1), @short);
  12. set id = floor(id / 62);
  13. end while;
  14. return @short;
  15. end//
Advertisement
Add Comment
Please, Sign In to add comment