Vyzkoušejte tuto funkci -
DELIMITER $$
CREATE FUNCTION cnt_up_case(str VARCHAR(255))
RETURNS VARCHAR(255)
NOT DETERMINISTIC
CONTAINS SQL
BEGIN
SET @cnt = 0;
SET @len = length(str);
SET @i = 1;
WHILE @i <= @len
DO
SET @c = substring(str, @i, 1);
IF ascii(@c) > 64 AND ascii(@c) < 91 THEN
SET @cnt = @cnt + 1;
END IF;
SET @i = @i + 1;
END WHILE;
RETURN @cnt;
END
$$
DELIMITER ;
Příklad:
SET @Param1 = 'AbCdE';
SET @ResultValue = cnt_up_case(@Param1);
SELECT @ResultValue;
--------------
3