gpt4 book ai didi

mysql - mysql workbench 8.0中将列中每个单词大写的函数

转载 作者:行者123 更新时间:2023-11-29 17:17:57 24 4
gpt4 key购买 nike

我正在尝试创建一个函数来大写 mysql 工作台中的每个单词,但不断出现语法错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以了解在“确定性开始声明 len INT;”附近使用的正确语法。声明 i INT;在行

处设置 len = cha'

这是我的代码:

delimiter ;;

CREATE FUNCTION caps_first (input varbinary(100))
RETURNS varbinary(100) deterministic

Begin
declare len INT;
declare i INT;

set len = char_len(input);
set input = lower(input);
set i = 0;

while (i<len) do
if (mid(input,i,1) = '' or i = 0) then
if (i < len) then
set input = concat(
left(input,i),
upper(mid(input, i+1,1)),
right(input, len-i-1)
);
end if;
end if;
set i = i+1;
end while;

return input;
end;

最佳答案

大约一个月前,我编写了一个与此类似的存储过程。引用this post here对于脚本。如果您想直接使用它,则需要花费一些精力来修改以满足您的需求,但它应该为您提供一个不错的起点。

我知道这不是像您所要求的那样直接调试,但比较代码可能会帮助您解决问题。

关于mysql - mysql workbench 8.0中将列中每个单词大写的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51444950/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com