By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE a (ab BIGINT)
INSERT INTO a VALUEs(34543),(53749),(19123)
CREATE FUNCTION hello (s CHAR(20))
RETURNS CHAR(50) DETERMINISTIC
BEGIN
DECLARE counter INT DEFAULT 1;
DECLARE strlen int DEFAULT 0;
SET strlen = CHAR_LENGTH(s);
DROP TEMPORARY TABLE IF Exists singlechar;
CREATe TEMPORARY TABLE singlechar(c int);
WHILE counter <= strlen DO
INSERT INTO singlechar VALUES (SUBSTRING(s, counter, 1));
SET counter := counter +1;
END WHILE;
RETURN (SELECT GROUP_CONCAT(c ORDER BY c ASC SEPARATOR '') FROM singlechar);
END
SELECT hello(ab) FROM a
hello(ab) |
---|
33445 |
34579 |
11239 |